aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEldad Zack <eldad@fogrefinery.com>2013-04-03 17:18:49 -0400
committerTakashi Iwai <tiwai@suse.de>2013-04-04 02:30:06 -0400
commit88766f04c4142c0a388a1de354616c3deafba513 (patch)
treee99293557513f294c5a703f449ca871b17be27bc
parent7c51746517e46806c59da6d780e7a14e8ae2bf78 (diff)
ALSA: usb-audio: convert list_for_each to entry variant
Change occurances of list_for_each into list_for_each_entry where applicable. Signed-off-by: Eldad Zack <eldad@fogrefinery.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/usb/card.c4
-rw-r--r--sound/usb/endpoint.c4
-rw-r--r--sound/usb/midi.c5
-rw-r--r--sound/usb/pcm.c30
-rw-r--r--sound/usb/proc.c7
-rw-r--r--sound/usb/stream.c12
6 files changed, 21 insertions, 41 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 2da8ad75fd96..8bab36cdf2ea 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -645,7 +645,6 @@ void snd_usb_autosuspend(struct snd_usb_audio *chip)
645static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) 645static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
646{ 646{
647 struct snd_usb_audio *chip = usb_get_intfdata(intf); 647 struct snd_usb_audio *chip = usb_get_intfdata(intf);
648 struct list_head *p;
649 struct snd_usb_stream *as; 648 struct snd_usb_stream *as;
650 struct usb_mixer_interface *mixer; 649 struct usb_mixer_interface *mixer;
651 650
@@ -655,8 +654,7 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
655 if (!PMSG_IS_AUTO(message)) { 654 if (!PMSG_IS_AUTO(message)) {
656 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); 655 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
657 if (!chip->num_suspended_intf++) { 656 if (!chip->num_suspended_intf++) {
658 list_for_each(p, &chip->pcm_list) { 657 list_for_each_entry(as, &chip->pcm_list, list) {
659 as = list_entry(p, struct snd_usb_stream, list);
660 snd_pcm_suspend_all(as->pcm); 658 snd_pcm_suspend_all(as->pcm);
661 as->substream[0].need_setup_ep = 659 as->substream[0].need_setup_ep =
662 as->substream[1].need_setup_ep = true; 660 as->substream[1].need_setup_ep = true;
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 21049b882ee6..b1f687f57ba5 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -415,14 +415,12 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip,
415 struct usb_host_interface *alts, 415 struct usb_host_interface *alts,
416 int ep_num, int direction, int type) 416 int ep_num, int direction, int type)
417{ 417{
418 struct list_head *p;
419 struct snd_usb_endpoint *ep; 418 struct snd_usb_endpoint *ep;
420 int is_playback = direction == SNDRV_PCM_STREAM_PLAYBACK; 419 int is_playback = direction == SNDRV_PCM_STREAM_PLAYBACK;
421 420
422 mutex_lock(&chip->mutex); 421 mutex_lock(&chip->mutex);
423 422
424 list_for_each(p, &chip->ep_list) { 423 list_for_each_entry(ep, &chip->ep_list, list) {
425 ep = list_entry(p, struct snd_usb_endpoint, list);
426 if (ep->ep_num == ep_num && 424 if (ep->ep_num == ep_num &&
427 ep->iface == alts->desc.bInterfaceNumber && 425 ep->iface == alts->desc.bInterfaceNumber &&
428 ep->alt_idx == alts->desc.bAlternateSetting) { 426 ep->alt_idx == alts->desc.bAlternateSetting) {
diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index 34b9bb7fe87c..1cf943d86bcd 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -1465,10 +1465,9 @@ static void snd_usbmidi_rawmidi_free(struct snd_rawmidi *rmidi)
1465static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi* umidi, 1465static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi* umidi,
1466 int stream, int number) 1466 int stream, int number)
1467{ 1467{
1468 struct list_head* list; 1468 struct snd_rawmidi_substream *substream;
1469 1469
1470 list_for_each(list, &umidi->rmidi->streams[stream].substreams) { 1470 list_for_each_entry(substream, &umidi->rmidi->streams[stream].substreams, list) {
1471 struct snd_rawmidi_substream *substream = list_entry(list, struct snd_rawmidi_substream, list);
1472 if (substream->number == number) 1471 if (substream->number == number)
1473 return substream; 1472 return substream;
1474 } 1473 }
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index c263991b3b9d..652724c12235 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -94,13 +94,11 @@ static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream
94 */ 94 */
95static struct audioformat *find_format(struct snd_usb_substream *subs) 95static struct audioformat *find_format(struct snd_usb_substream *subs)
96{ 96{
97 struct list_head *p; 97 struct audioformat *fp;
98 struct audioformat *found = NULL; 98 struct audioformat *found = NULL;
99 int cur_attr = 0, attr; 99 int cur_attr = 0, attr;
100 100
101 list_for_each(p, &subs->fmt_list) { 101 list_for_each_entry(fp, &subs->fmt_list, list) {
102 struct audioformat *fp;
103 fp = list_entry(p, struct audioformat, list);
104 if (!(fp->formats & (1uLL << subs->pcm_format))) 102 if (!(fp->formats & (1uLL << subs->pcm_format)))
105 continue; 103 continue;
106 if (fp->channels != subs->channels) 104 if (fp->channels != subs->channels)
@@ -809,7 +807,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params,
809 struct snd_pcm_hw_rule *rule) 807 struct snd_pcm_hw_rule *rule)
810{ 808{
811 struct snd_usb_substream *subs = rule->private; 809 struct snd_usb_substream *subs = rule->private;
812 struct list_head *p; 810 struct audioformat *fp;
813 struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 811 struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
814 unsigned int rmin, rmax; 812 unsigned int rmin, rmax;
815 int changed; 813 int changed;
@@ -817,9 +815,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params,
817 hwc_debug("hw_rule_rate: (%d,%d)\n", it->min, it->max); 815 hwc_debug("hw_rule_rate: (%d,%d)\n", it->min, it->max);
818 changed = 0; 816 changed = 0;
819 rmin = rmax = 0; 817 rmin = rmax = 0;
820 list_for_each(p, &subs->fmt_list) { 818 list_for_each_entry(fp, &subs->fmt_list, list) {
821 struct audioformat *fp;
822 fp = list_entry(p, struct audioformat, list);
823 if (!hw_check_valid_format(subs, params, fp)) 819 if (!hw_check_valid_format(subs, params, fp))
824 continue; 820 continue;
825 if (changed++) { 821 if (changed++) {
@@ -863,7 +859,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params,
863 struct snd_pcm_hw_rule *rule) 859 struct snd_pcm_hw_rule *rule)
864{ 860{
865 struct snd_usb_substream *subs = rule->private; 861 struct snd_usb_substream *subs = rule->private;
866 struct list_head *p; 862 struct audioformat *fp;
867 struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); 863 struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
868 unsigned int rmin, rmax; 864 unsigned int rmin, rmax;
869 int changed; 865 int changed;
@@ -871,9 +867,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params,
871 hwc_debug("hw_rule_channels: (%d,%d)\n", it->min, it->max); 867 hwc_debug("hw_rule_channels: (%d,%d)\n", it->min, it->max);
872 changed = 0; 868 changed = 0;
873 rmin = rmax = 0; 869 rmin = rmax = 0;
874 list_for_each(p, &subs->fmt_list) { 870 list_for_each_entry(fp, &subs->fmt_list, list) {
875 struct audioformat *fp;
876 fp = list_entry(p, struct audioformat, list);
877 if (!hw_check_valid_format(subs, params, fp)) 871 if (!hw_check_valid_format(subs, params, fp))
878 continue; 872 continue;
879 if (changed++) { 873 if (changed++) {
@@ -916,7 +910,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params,
916 struct snd_pcm_hw_rule *rule) 910 struct snd_pcm_hw_rule *rule)
917{ 911{
918 struct snd_usb_substream *subs = rule->private; 912 struct snd_usb_substream *subs = rule->private;
919 struct list_head *p; 913 struct audioformat *fp;
920 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 914 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
921 u64 fbits; 915 u64 fbits;
922 u32 oldbits[2]; 916 u32 oldbits[2];
@@ -924,9 +918,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params,
924 918
925 hwc_debug("hw_rule_format: %x:%x\n", fmt->bits[0], fmt->bits[1]); 919 hwc_debug("hw_rule_format: %x:%x\n", fmt->bits[0], fmt->bits[1]);
926 fbits = 0; 920 fbits = 0;
927 list_for_each(p, &subs->fmt_list) { 921 list_for_each_entry(fp, &subs->fmt_list, list) {
928 struct audioformat *fp;
929 fp = list_entry(p, struct audioformat, list);
930 if (!hw_check_valid_format(subs, params, fp)) 922 if (!hw_check_valid_format(subs, params, fp))
931 continue; 923 continue;
932 fbits |= fp->formats; 924 fbits |= fp->formats;
@@ -1034,7 +1026,7 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime,
1034 1026
1035static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs) 1027static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs)
1036{ 1028{
1037 struct list_head *p; 1029 struct audioformat *fp;
1038 unsigned int pt, ptmin; 1030 unsigned int pt, ptmin;
1039 int param_period_time_if_needed; 1031 int param_period_time_if_needed;
1040 int err; 1032 int err;
@@ -1048,9 +1040,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
1048 runtime->hw.rates = 0; 1040 runtime->hw.rates = 0;
1049 ptmin = UINT_MAX; 1041 ptmin = UINT_MAX;
1050 /* check min/max rates and channels */ 1042 /* check min/max rates and channels */
1051 list_for_each(p, &subs->fmt_list) { 1043 list_for_each_entry(fp, &subs->fmt_list, list) {
1052 struct audioformat *fp;
1053 fp = list_entry(p, struct audioformat, list);
1054 runtime->hw.rates |= fp->rates; 1044 runtime->hw.rates |= fp->rates;
1055 if (runtime->hw.rate_min > fp->rate_min) 1045 if (runtime->hw.rate_min > fp->rate_min)
1056 runtime->hw.rate_min = fp->rate_min; 1046 runtime->hw.rate_min = fp->rate_min;
diff --git a/sound/usb/proc.c b/sound/usb/proc.c
index d218f763501f..0182ef634d8b 100644
--- a/sound/usb/proc.c
+++ b/sound/usb/proc.c
@@ -73,15 +73,14 @@ void snd_usb_audio_create_proc(struct snd_usb_audio *chip)
73 */ 73 */
74static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct snd_info_buffer *buffer) 74static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct snd_info_buffer *buffer)
75{ 75{
76 struct list_head *p; 76 struct audioformat *fp;
77 static char *sync_types[4] = { 77 static char *sync_types[4] = {
78 "NONE", "ASYNC", "ADAPTIVE", "SYNC" 78 "NONE", "ASYNC", "ADAPTIVE", "SYNC"
79 }; 79 };
80 80
81 list_for_each(p, &subs->fmt_list) { 81 list_for_each_entry(fp, &subs->fmt_list, list) {
82 struct audioformat *fp;
83 snd_pcm_format_t fmt; 82 snd_pcm_format_t fmt;
84 fp = list_entry(p, struct audioformat, list); 83
85 snd_iprintf(buffer, " Interface %d\n", fp->iface); 84 snd_iprintf(buffer, " Interface %d\n", fp->iface);
86 snd_iprintf(buffer, " Altset %d\n", fp->altsetting); 85 snd_iprintf(buffer, " Altset %d\n", fp->altsetting);
87 snd_iprintf(buffer, " Format:"); 86 snd_iprintf(buffer, " Format:");
diff --git a/sound/usb/stream.c b/sound/usb/stream.c
index ad0704656fe5..74beea237801 100644
--- a/sound/usb/stream.c
+++ b/sound/usb/stream.c
@@ -42,12 +42,11 @@
42 */ 42 */
43static void free_substream(struct snd_usb_substream *subs) 43static void free_substream(struct snd_usb_substream *subs)
44{ 44{
45 struct list_head *p, *n; 45 struct audioformat *fp, *n;
46 46
47 if (!subs->num_formats) 47 if (!subs->num_formats)
48 return; /* not initialized */ 48 return; /* not initialized */
49 list_for_each_safe(p, n, &subs->fmt_list) { 49 list_for_each_entry_safe(fp, n, &subs->fmt_list, list) {
50 struct audioformat *fp = list_entry(p, struct audioformat, list);
51 kfree(fp->rate_table); 50 kfree(fp->rate_table);
52 kfree(fp->chmap); 51 kfree(fp->chmap);
53 kfree(fp); 52 kfree(fp);
@@ -313,14 +312,12 @@ int snd_usb_add_audio_stream(struct snd_usb_audio *chip,
313 int stream, 312 int stream,
314 struct audioformat *fp) 313 struct audioformat *fp)
315{ 314{
316 struct list_head *p;
317 struct snd_usb_stream *as; 315 struct snd_usb_stream *as;
318 struct snd_usb_substream *subs; 316 struct snd_usb_substream *subs;
319 struct snd_pcm *pcm; 317 struct snd_pcm *pcm;
320 int err; 318 int err;
321 319
322 list_for_each(p, &chip->pcm_list) { 320 list_for_each_entry(as, &chip->pcm_list, list) {
323 as = list_entry(p, struct snd_usb_stream, list);
324 if (as->fmt_type != fp->fmt_type) 321 if (as->fmt_type != fp->fmt_type)
325 continue; 322 continue;
326 subs = &as->substream[stream]; 323 subs = &as->substream[stream];
@@ -332,8 +329,7 @@ int snd_usb_add_audio_stream(struct snd_usb_audio *chip,
332 } 329 }
333 } 330 }
334 /* look for an empty stream */ 331 /* look for an empty stream */
335 list_for_each(p, &chip->pcm_list) { 332 list_for_each_entry(as, &chip->pcm_list, list) {
336 as = list_entry(p, struct snd_usb_stream, list);
337 if (as->fmt_type != fp->fmt_type) 333 if (as->fmt_type != fp->fmt_type)
338 continue; 334 continue;
339 subs = &as->substream[stream]; 335 subs = &as->substream[stream];