Commit 88766f04 authored by Eldad Zack's avatar Eldad Zack Committed by Takashi Iwai

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: default avatarEldad Zack <eldad@fogrefinery.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 7c517465
...@@ -645,7 +645,6 @@ void snd_usb_autosuspend(struct snd_usb_audio *chip) ...@@ -645,7 +645,6 @@ void snd_usb_autosuspend(struct snd_usb_audio *chip)
static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
{ {
struct snd_usb_audio *chip = usb_get_intfdata(intf); struct snd_usb_audio *chip = usb_get_intfdata(intf);
struct list_head *p;
struct snd_usb_stream *as; struct snd_usb_stream *as;
struct usb_mixer_interface *mixer; struct usb_mixer_interface *mixer;
...@@ -655,8 +654,7 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -655,8 +654,7 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
if (!PMSG_IS_AUTO(message)) { if (!PMSG_IS_AUTO(message)) {
snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
if (!chip->num_suspended_intf++) { if (!chip->num_suspended_intf++) {
list_for_each(p, &chip->pcm_list) { list_for_each_entry(as, &chip->pcm_list, list) {
as = list_entry(p, struct snd_usb_stream, list);
snd_pcm_suspend_all(as->pcm); snd_pcm_suspend_all(as->pcm);
as->substream[0].need_setup_ep = as->substream[0].need_setup_ep =
as->substream[1].need_setup_ep = true; as->substream[1].need_setup_ep = true;
......
...@@ -415,14 +415,12 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip, ...@@ -415,14 +415,12 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip,
struct usb_host_interface *alts, struct usb_host_interface *alts,
int ep_num, int direction, int type) int ep_num, int direction, int type)
{ {
struct list_head *p;
struct snd_usb_endpoint *ep; struct snd_usb_endpoint *ep;
int is_playback = direction == SNDRV_PCM_STREAM_PLAYBACK; int is_playback = direction == SNDRV_PCM_STREAM_PLAYBACK;
mutex_lock(&chip->mutex); mutex_lock(&chip->mutex);
list_for_each(p, &chip->ep_list) { list_for_each_entry(ep, &chip->ep_list, list) {
ep = list_entry(p, struct snd_usb_endpoint, list);
if (ep->ep_num == ep_num && if (ep->ep_num == ep_num &&
ep->iface == alts->desc.bInterfaceNumber && ep->iface == alts->desc.bInterfaceNumber &&
ep->alt_idx == alts->desc.bAlternateSetting) { ep->alt_idx == alts->desc.bAlternateSetting) {
......
...@@ -1465,10 +1465,9 @@ static void snd_usbmidi_rawmidi_free(struct snd_rawmidi *rmidi) ...@@ -1465,10 +1465,9 @@ static void snd_usbmidi_rawmidi_free(struct snd_rawmidi *rmidi)
static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi* umidi, static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi* umidi,
int stream, int number) int stream, int number)
{ {
struct list_head* list; struct snd_rawmidi_substream *substream;
list_for_each(list, &umidi->rmidi->streams[stream].substreams) { list_for_each_entry(substream, &umidi->rmidi->streams[stream].substreams, list) {
struct snd_rawmidi_substream *substream = list_entry(list, struct snd_rawmidi_substream, list);
if (substream->number == number) if (substream->number == number)
return substream; return substream;
} }
......
...@@ -94,13 +94,11 @@ static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream ...@@ -94,13 +94,11 @@ static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream
*/ */
static struct audioformat *find_format(struct snd_usb_substream *subs) static struct audioformat *find_format(struct snd_usb_substream *subs)
{ {
struct list_head *p; struct audioformat *fp;
struct audioformat *found = NULL; struct audioformat *found = NULL;
int cur_attr = 0, attr; int cur_attr = 0, attr;
list_for_each(p, &subs->fmt_list) { list_for_each_entry(fp, &subs->fmt_list, list) {
struct audioformat *fp;
fp = list_entry(p, struct audioformat, list);
if (!(fp->formats & (1uLL << subs->pcm_format))) if (!(fp->formats & (1uLL << subs->pcm_format)))
continue; continue;
if (fp->channels != subs->channels) if (fp->channels != subs->channels)
...@@ -809,7 +807,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params, ...@@ -809,7 +807,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params,
struct snd_pcm_hw_rule *rule) struct snd_pcm_hw_rule *rule)
{ {
struct snd_usb_substream *subs = rule->private; struct snd_usb_substream *subs = rule->private;
struct list_head *p; struct audioformat *fp;
struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
unsigned int rmin, rmax; unsigned int rmin, rmax;
int changed; int changed;
...@@ -817,9 +815,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params, ...@@ -817,9 +815,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params,
hwc_debug("hw_rule_rate: (%d,%d)\n", it->min, it->max); hwc_debug("hw_rule_rate: (%d,%d)\n", it->min, it->max);
changed = 0; changed = 0;
rmin = rmax = 0; rmin = rmax = 0;
list_for_each(p, &subs->fmt_list) { list_for_each_entry(fp, &subs->fmt_list, list) {
struct audioformat *fp;
fp = list_entry(p, struct audioformat, list);
if (!hw_check_valid_format(subs, params, fp)) if (!hw_check_valid_format(subs, params, fp))
continue; continue;
if (changed++) { if (changed++) {
...@@ -863,7 +859,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params, ...@@ -863,7 +859,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params,
struct snd_pcm_hw_rule *rule) struct snd_pcm_hw_rule *rule)
{ {
struct snd_usb_substream *subs = rule->private; struct snd_usb_substream *subs = rule->private;
struct list_head *p; struct audioformat *fp;
struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
unsigned int rmin, rmax; unsigned int rmin, rmax;
int changed; int changed;
...@@ -871,9 +867,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params, ...@@ -871,9 +867,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params,
hwc_debug("hw_rule_channels: (%d,%d)\n", it->min, it->max); hwc_debug("hw_rule_channels: (%d,%d)\n", it->min, it->max);
changed = 0; changed = 0;
rmin = rmax = 0; rmin = rmax = 0;
list_for_each(p, &subs->fmt_list) { list_for_each_entry(fp, &subs->fmt_list, list) {
struct audioformat *fp;
fp = list_entry(p, struct audioformat, list);
if (!hw_check_valid_format(subs, params, fp)) if (!hw_check_valid_format(subs, params, fp))
continue; continue;
if (changed++) { if (changed++) {
...@@ -916,7 +910,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params, ...@@ -916,7 +910,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params,
struct snd_pcm_hw_rule *rule) struct snd_pcm_hw_rule *rule)
{ {
struct snd_usb_substream *subs = rule->private; struct snd_usb_substream *subs = rule->private;
struct list_head *p; struct audioformat *fp;
struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
u64 fbits; u64 fbits;
u32 oldbits[2]; u32 oldbits[2];
...@@ -924,9 +918,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params, ...@@ -924,9 +918,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params,
hwc_debug("hw_rule_format: %x:%x\n", fmt->bits[0], fmt->bits[1]); hwc_debug("hw_rule_format: %x:%x\n", fmt->bits[0], fmt->bits[1]);
fbits = 0; fbits = 0;
list_for_each(p, &subs->fmt_list) { list_for_each_entry(fp, &subs->fmt_list, list) {
struct audioformat *fp;
fp = list_entry(p, struct audioformat, list);
if (!hw_check_valid_format(subs, params, fp)) if (!hw_check_valid_format(subs, params, fp))
continue; continue;
fbits |= fp->formats; fbits |= fp->formats;
...@@ -1034,7 +1026,7 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime, ...@@ -1034,7 +1026,7 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime,
static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs) static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs)
{ {
struct list_head *p; struct audioformat *fp;
unsigned int pt, ptmin; unsigned int pt, ptmin;
int param_period_time_if_needed; int param_period_time_if_needed;
int err; int err;
...@@ -1048,9 +1040,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre ...@@ -1048,9 +1040,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
runtime->hw.rates = 0; runtime->hw.rates = 0;
ptmin = UINT_MAX; ptmin = UINT_MAX;
/* check min/max rates and channels */ /* check min/max rates and channels */
list_for_each(p, &subs->fmt_list) { list_for_each_entry(fp, &subs->fmt_list, list) {
struct audioformat *fp;
fp = list_entry(p, struct audioformat, list);
runtime->hw.rates |= fp->rates; runtime->hw.rates |= fp->rates;
if (runtime->hw.rate_min > fp->rate_min) if (runtime->hw.rate_min > fp->rate_min)
runtime->hw.rate_min = fp->rate_min; runtime->hw.rate_min = fp->rate_min;
......
...@@ -73,15 +73,14 @@ void snd_usb_audio_create_proc(struct snd_usb_audio *chip) ...@@ -73,15 +73,14 @@ void snd_usb_audio_create_proc(struct snd_usb_audio *chip)
*/ */
static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct snd_info_buffer *buffer) static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct snd_info_buffer *buffer)
{ {
struct list_head *p; struct audioformat *fp;
static char *sync_types[4] = { static char *sync_types[4] = {
"NONE", "ASYNC", "ADAPTIVE", "SYNC" "NONE", "ASYNC", "ADAPTIVE", "SYNC"
}; };
list_for_each(p, &subs->fmt_list) { list_for_each_entry(fp, &subs->fmt_list, list) {
struct audioformat *fp;
snd_pcm_format_t fmt; snd_pcm_format_t fmt;
fp = list_entry(p, struct audioformat, list);
snd_iprintf(buffer, " Interface %d\n", fp->iface); snd_iprintf(buffer, " Interface %d\n", fp->iface);
snd_iprintf(buffer, " Altset %d\n", fp->altsetting); snd_iprintf(buffer, " Altset %d\n", fp->altsetting);
snd_iprintf(buffer, " Format:"); snd_iprintf(buffer, " Format:");
......
...@@ -42,12 +42,11 @@ ...@@ -42,12 +42,11 @@
*/ */
static void free_substream(struct snd_usb_substream *subs) static void free_substream(struct snd_usb_substream *subs)
{ {
struct list_head *p, *n; struct audioformat *fp, *n;
if (!subs->num_formats) if (!subs->num_formats)
return; /* not initialized */ return; /* not initialized */
list_for_each_safe(p, n, &subs->fmt_list) { list_for_each_entry_safe(fp, n, &subs->fmt_list, list) {
struct audioformat *fp = list_entry(p, struct audioformat, list);
kfree(fp->rate_table); kfree(fp->rate_table);
kfree(fp->chmap); kfree(fp->chmap);
kfree(fp); kfree(fp);
...@@ -313,14 +312,12 @@ int snd_usb_add_audio_stream(struct snd_usb_audio *chip, ...@@ -313,14 +312,12 @@ int snd_usb_add_audio_stream(struct snd_usb_audio *chip,
int stream, int stream,
struct audioformat *fp) struct audioformat *fp)
{ {
struct list_head *p;
struct snd_usb_stream *as; struct snd_usb_stream *as;
struct snd_usb_substream *subs; struct snd_usb_substream *subs;
struct snd_pcm *pcm; struct snd_pcm *pcm;
int err; int err;
list_for_each(p, &chip->pcm_list) { list_for_each_entry(as, &chip->pcm_list, list) {
as = list_entry(p, struct snd_usb_stream, list);
if (as->fmt_type != fp->fmt_type) if (as->fmt_type != fp->fmt_type)
continue; continue;
subs = &as->substream[stream]; subs = &as->substream[stream];
...@@ -332,8 +329,7 @@ int snd_usb_add_audio_stream(struct snd_usb_audio *chip, ...@@ -332,8 +329,7 @@ int snd_usb_add_audio_stream(struct snd_usb_audio *chip,
} }
} }
/* look for an empty stream */ /* look for an empty stream */
list_for_each(p, &chip->pcm_list) { list_for_each_entry(as, &chip->pcm_list, list) {
as = list_entry(p, struct snd_usb_stream, list);
if (as->fmt_type != fp->fmt_type) if (as->fmt_type != fp->fmt_type)
continue; continue;
subs = &as->substream[stream]; subs = &as->substream[stream];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment