Commit 88766f04c4142c0a388a1de354616c3deafba513

Authored by Eldad Zack
Committed by Takashi Iwai
1 parent 7c51746517

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>

Showing 6 changed files with 21 additions and 41 deletions Side-by-side Diff

... ... @@ -645,7 +645,6 @@
645 645 static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
646 646 {
647 647 struct snd_usb_audio *chip = usb_get_intfdata(intf);
648   - struct list_head *p;
649 648 struct snd_usb_stream *as;
650 649 struct usb_mixer_interface *mixer;
651 650  
... ... @@ -655,8 +654,7 @@
655 654 if (!PMSG_IS_AUTO(message)) {
656 655 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
657 656 if (!chip->num_suspended_intf++) {
658   - list_for_each(p, &chip->pcm_list) {
659   - as = list_entry(p, struct snd_usb_stream, list);
  657 + list_for_each_entry(as, &chip->pcm_list, list) {
660 658 snd_pcm_suspend_all(as->pcm);
661 659 as->substream[0].need_setup_ep =
662 660 as->substream[1].need_setup_ep = true;
sound/usb/endpoint.c
... ... @@ -415,14 +415,12 @@
415 415 struct usb_host_interface *alts,
416 416 int ep_num, int direction, int type)
417 417 {
418   - struct list_head *p;
419 418 struct snd_usb_endpoint *ep;
420 419 int is_playback = direction == SNDRV_PCM_STREAM_PLAYBACK;
421 420  
422 421 mutex_lock(&chip->mutex);
423 422  
424   - list_for_each(p, &chip->ep_list) {
425   - ep = list_entry(p, struct snd_usb_endpoint, list);
  423 + list_for_each_entry(ep, &chip->ep_list, list) {
426 424 if (ep->ep_num == ep_num &&
427 425 ep->iface == alts->desc.bInterfaceNumber &&
428 426 ep->alt_idx == alts->desc.bAlternateSetting) {
... ... @@ -1465,10 +1465,9 @@
1465 1465 static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi* umidi,
1466 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) {
1471   - struct snd_rawmidi_substream *substream = list_entry(list, struct snd_rawmidi_substream, list);
  1470 + list_for_each_entry(substream, &umidi->rmidi->streams[stream].substreams, list) {
1472 1471 if (substream->number == number)
1473 1472 return substream;
1474 1473 }
... ... @@ -94,13 +94,11 @@
94 94 */
95 95 static struct audioformat *find_format(struct snd_usb_substream *subs)
96 96 {
97   - struct list_head *p;
  97 + struct audioformat *fp;
98 98 struct audioformat *found = NULL;
99 99 int cur_attr = 0, attr;
100 100  
101   - list_for_each(p, &subs->fmt_list) {
102   - struct audioformat *fp;
103   - fp = list_entry(p, struct audioformat, list);
  101 + list_for_each_entry(fp, &subs->fmt_list, list) {
104 102 if (!(fp->formats & (1uLL << subs->pcm_format)))
105 103 continue;
106 104 if (fp->channels != subs->channels)
... ... @@ -809,7 +807,7 @@
809 807 struct snd_pcm_hw_rule *rule)
810 808 {
811 809 struct snd_usb_substream *subs = rule->private;
812   - struct list_head *p;
  810 + struct audioformat *fp;
813 811 struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
814 812 unsigned int rmin, rmax;
815 813 int changed;
... ... @@ -817,9 +815,7 @@
817 815 hwc_debug("hw_rule_rate: (%d,%d)\n", it->min, it->max);
818 816 changed = 0;
819 817 rmin = rmax = 0;
820   - list_for_each(p, &subs->fmt_list) {
821   - struct audioformat *fp;
822   - fp = list_entry(p, struct audioformat, list);
  818 + list_for_each_entry(fp, &subs->fmt_list, list) {
823 819 if (!hw_check_valid_format(subs, params, fp))
824 820 continue;
825 821 if (changed++) {
... ... @@ -863,7 +859,7 @@
863 859 struct snd_pcm_hw_rule *rule)
864 860 {
865 861 struct snd_usb_substream *subs = rule->private;
866   - struct list_head *p;
  862 + struct audioformat *fp;
867 863 struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
868 864 unsigned int rmin, rmax;
869 865 int changed;
... ... @@ -871,9 +867,7 @@
871 867 hwc_debug("hw_rule_channels: (%d,%d)\n", it->min, it->max);
872 868 changed = 0;
873 869 rmin = rmax = 0;
874   - list_for_each(p, &subs->fmt_list) {
875   - struct audioformat *fp;
876   - fp = list_entry(p, struct audioformat, list);
  870 + list_for_each_entry(fp, &subs->fmt_list, list) {
877 871 if (!hw_check_valid_format(subs, params, fp))
878 872 continue;
879 873 if (changed++) {
... ... @@ -916,7 +910,7 @@
916 910 struct snd_pcm_hw_rule *rule)
917 911 {
918 912 struct snd_usb_substream *subs = rule->private;
919   - struct list_head *p;
  913 + struct audioformat *fp;
920 914 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
921 915 u64 fbits;
922 916 u32 oldbits[2];
... ... @@ -924,9 +918,7 @@
924 918  
925 919 hwc_debug("hw_rule_format: %x:%x\n", fmt->bits[0], fmt->bits[1]);
926 920 fbits = 0;
927   - list_for_each(p, &subs->fmt_list) {
928   - struct audioformat *fp;
929   - fp = list_entry(p, struct audioformat, list);
  921 + list_for_each_entry(fp, &subs->fmt_list, list) {
930 922 if (!hw_check_valid_format(subs, params, fp))
931 923 continue;
932 924 fbits |= fp->formats;
... ... @@ -1034,7 +1026,7 @@
1034 1026  
1035 1027 static 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 1030 unsigned int pt, ptmin;
1039 1031 int param_period_time_if_needed;
1040 1032 int err;
... ... @@ -1048,9 +1040,7 @@
1048 1040 runtime->hw.rates = 0;
1049 1041 ptmin = UINT_MAX;
1050 1042 /* check min/max rates and channels */
1051   - list_for_each(p, &subs->fmt_list) {
1052   - struct audioformat *fp;
1053   - fp = list_entry(p, struct audioformat, list);
  1043 + list_for_each_entry(fp, &subs->fmt_list, list) {
1054 1044 runtime->hw.rates |= fp->rates;
1055 1045 if (runtime->hw.rate_min > fp->rate_min)
1056 1046 runtime->hw.rate_min = fp->rate_min;
... ... @@ -73,15 +73,14 @@
73 73 */
74 74 static 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 77 static char *sync_types[4] = {
78 78 "NONE", "ASYNC", "ADAPTIVE", "SYNC"
79 79 };
80 80  
81   - list_for_each(p, &subs->fmt_list) {
82   - struct audioformat *fp;
  81 + list_for_each_entry(fp, &subs->fmt_list, list) {
83 82 snd_pcm_format_t fmt;
84   - fp = list_entry(p, struct audioformat, list);
  83 +
85 84 snd_iprintf(buffer, " Interface %d\n", fp->iface);
86 85 snd_iprintf(buffer, " Altset %d\n", fp->altsetting);
87 86 snd_iprintf(buffer, " Format:");
... ... @@ -42,12 +42,11 @@
42 42 */
43 43 static void free_substream(struct snd_usb_substream *subs)
44 44 {
45   - struct list_head *p, *n;
  45 + struct audioformat *fp, *n;
46 46  
47 47 if (!subs->num_formats)
48 48 return; /* not initialized */
49   - list_for_each_safe(p, n, &subs->fmt_list) {
50   - struct audioformat *fp = list_entry(p, struct audioformat, list);
  49 + list_for_each_entry_safe(fp, n, &subs->fmt_list, list) {
51 50 kfree(fp->rate_table);
52 51 kfree(fp->chmap);
53 52 kfree(fp);
54 53  
... ... @@ -313,14 +312,12 @@
313 312 int stream,
314 313 struct audioformat *fp)
315 314 {
316   - struct list_head *p;
317 315 struct snd_usb_stream *as;
318 316 struct snd_usb_substream *subs;
319 317 struct snd_pcm *pcm;
320 318 int err;
321 319  
322   - list_for_each(p, &chip->pcm_list) {
323   - as = list_entry(p, struct snd_usb_stream, list);
  320 + list_for_each_entry(as, &chip->pcm_list, list) {
324 321 if (as->fmt_type != fp->fmt_type)
325 322 continue;
326 323 subs = &as->substream[stream];
... ... @@ -332,8 +329,7 @@
332 329 }
333 330 }
334 331 /* look for an empty stream */
335   - list_for_each(p, &chip->pcm_list) {
336   - as = list_entry(p, struct snd_usb_stream, list);
  332 + list_for_each_entry(as, &chip->pcm_list, list) {
337 333 if (as->fmt_type != fp->fmt_type)
338 334 continue;
339 335 subs = &as->substream[stream];