diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-10-31 06:24:32 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-11-04 09:09:10 -0500 |
commit | a6cece9d81990e729c1f9da2a5bff2d29f7df649 (patch) | |
tree | 46746842e5039a1ce4e01e1e9de58ccb46f234de /sound/usb | |
parent | 4c8c3a4fcc021677c9a363b4e77f61dd09dbfd1a (diff) |
ALSA: usb-audio: Pass direct struct pointer instead of list_head
Some functions in mixer.c and endpoint.c receive list_head instead of
the object itself. This is not obvious and rather error-prone. Let's
pass the proper object directly instead.
The functions in midi.c still receive list_head and this can't be
changed since the object definition isn't exposed to the outside of
midi.c, so left as is.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/card.c | 20 | ||||
-rw-r--r-- | sound/usb/endpoint.c | 7 | ||||
-rw-r--r-- | sound/usb/endpoint.h | 2 | ||||
-rw-r--r-- | sound/usb/mixer.c | 5 | ||||
-rw-r--r-- | sound/usb/mixer.h | 2 |
5 files changed, 15 insertions, 21 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c index be16bdc53c2a..fa6c0972aa23 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c | |||
@@ -114,13 +114,11 @@ static struct usb_driver usb_audio_driver; | |||
114 | * disconnect streams | 114 | * disconnect streams |
115 | * called from usb_audio_disconnect() | 115 | * called from usb_audio_disconnect() |
116 | */ | 116 | */ |
117 | static void snd_usb_stream_disconnect(struct list_head *head) | 117 | static void snd_usb_stream_disconnect(struct snd_usb_stream *as) |
118 | { | 118 | { |
119 | int idx; | 119 | int idx; |
120 | struct snd_usb_stream *as; | ||
121 | struct snd_usb_substream *subs; | 120 | struct snd_usb_substream *subs; |
122 | 121 | ||
123 | as = list_entry(head, struct snd_usb_stream, list); | ||
124 | for (idx = 0; idx < 2; idx++) { | 122 | for (idx = 0; idx < 2; idx++) { |
125 | subs = &as->substream[idx]; | 123 | subs = &as->substream[idx]; |
126 | if (!subs->num_formats) | 124 | if (!subs->num_formats) |
@@ -307,10 +305,10 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif) | |||
307 | 305 | ||
308 | static int snd_usb_audio_free(struct snd_usb_audio *chip) | 306 | static int snd_usb_audio_free(struct snd_usb_audio *chip) |
309 | { | 307 | { |
310 | struct list_head *p, *n; | 308 | struct snd_usb_endpoint *ep, *n; |
311 | 309 | ||
312 | list_for_each_safe(p, n, &chip->ep_list) | 310 | list_for_each_entry_safe(ep, n, &chip->ep_list, list) |
313 | snd_usb_endpoint_free(p); | 311 | snd_usb_endpoint_free(ep); |
314 | 312 | ||
315 | mutex_destroy(&chip->mutex); | 313 | mutex_destroy(&chip->mutex); |
316 | kfree(chip); | 314 | kfree(chip); |
@@ -609,12 +607,14 @@ static void usb_audio_disconnect(struct usb_interface *intf) | |||
609 | mutex_lock(®ister_mutex); | 607 | mutex_lock(®ister_mutex); |
610 | chip->num_interfaces--; | 608 | chip->num_interfaces--; |
611 | if (chip->num_interfaces <= 0) { | 609 | if (chip->num_interfaces <= 0) { |
610 | struct snd_usb_stream *as; | ||
612 | struct snd_usb_endpoint *ep; | 611 | struct snd_usb_endpoint *ep; |
612 | struct usb_mixer_interface *mixer; | ||
613 | 613 | ||
614 | snd_card_disconnect(card); | 614 | snd_card_disconnect(card); |
615 | /* release the pcm resources */ | 615 | /* release the pcm resources */ |
616 | list_for_each(p, &chip->pcm_list) { | 616 | list_for_each_entry(as, &chip->pcm_list, list) { |
617 | snd_usb_stream_disconnect(p); | 617 | snd_usb_stream_disconnect(as); |
618 | } | 618 | } |
619 | /* release the endpoint resources */ | 619 | /* release the endpoint resources */ |
620 | list_for_each_entry(ep, &chip->ep_list, list) { | 620 | list_for_each_entry(ep, &chip->ep_list, list) { |
@@ -625,8 +625,8 @@ static void usb_audio_disconnect(struct usb_interface *intf) | |||
625 | snd_usbmidi_disconnect(p); | 625 | snd_usbmidi_disconnect(p); |
626 | } | 626 | } |
627 | /* release mixer resources */ | 627 | /* release mixer resources */ |
628 | list_for_each(p, &chip->mixer_list) { | 628 | list_for_each_entry(mixer, &chip->mixer_list, list) { |
629 | snd_usb_mixer_disconnect(p); | 629 | snd_usb_mixer_disconnect(mixer); |
630 | } | 630 | } |
631 | usb_chip[chip->index] = NULL; | 631 | usb_chip[chip->index] = NULL; |
632 | mutex_unlock(®ister_mutex); | 632 | mutex_unlock(®ister_mutex); |
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 114e3e7ff511..167d0c1643e1 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c | |||
@@ -1002,15 +1002,12 @@ void snd_usb_endpoint_release(struct snd_usb_endpoint *ep) | |||
1002 | /** | 1002 | /** |
1003 | * snd_usb_endpoint_free: Free the resources of an snd_usb_endpoint | 1003 | * snd_usb_endpoint_free: Free the resources of an snd_usb_endpoint |
1004 | * | 1004 | * |
1005 | * @ep: the list header of the endpoint to free | 1005 | * @ep: the endpoint to free |
1006 | * | 1006 | * |
1007 | * This free all resources of the given ep. | 1007 | * This free all resources of the given ep. |
1008 | */ | 1008 | */ |
1009 | void snd_usb_endpoint_free(struct list_head *head) | 1009 | void snd_usb_endpoint_free(struct snd_usb_endpoint *ep) |
1010 | { | 1010 | { |
1011 | struct snd_usb_endpoint *ep; | ||
1012 | |||
1013 | ep = list_entry(head, struct snd_usb_endpoint, list); | ||
1014 | kfree(ep); | 1011 | kfree(ep); |
1015 | } | 1012 | } |
1016 | 1013 | ||
diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h index e61ee5c356a3..6428392d8f62 100644 --- a/sound/usb/endpoint.h +++ b/sound/usb/endpoint.h | |||
@@ -24,7 +24,7 @@ void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep); | |||
24 | int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); | 24 | int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); |
25 | void snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep); | 25 | void snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep); |
26 | void snd_usb_endpoint_release(struct snd_usb_endpoint *ep); | 26 | void snd_usb_endpoint_release(struct snd_usb_endpoint *ep); |
27 | void snd_usb_endpoint_free(struct list_head *head); | 27 | void snd_usb_endpoint_free(struct snd_usb_endpoint *ep); |
28 | 28 | ||
29 | int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep); | 29 | int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep); |
30 | int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep); | 30 | int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep); |
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 63a8adb1705e..e4aaa21baed2 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c | |||
@@ -2483,11 +2483,8 @@ _error: | |||
2483 | return err; | 2483 | return err; |
2484 | } | 2484 | } |
2485 | 2485 | ||
2486 | void snd_usb_mixer_disconnect(struct list_head *p) | 2486 | void snd_usb_mixer_disconnect(struct usb_mixer_interface *mixer) |
2487 | { | 2487 | { |
2488 | struct usb_mixer_interface *mixer; | ||
2489 | |||
2490 | mixer = list_entry(p, struct usb_mixer_interface, list); | ||
2491 | usb_kill_urb(mixer->urb); | 2488 | usb_kill_urb(mixer->urb); |
2492 | usb_kill_urb(mixer->rc_urb); | 2489 | usb_kill_urb(mixer->rc_urb); |
2493 | } | 2490 | } |
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h index 73b1f649447b..2c7b9c9c2aa6 100644 --- a/sound/usb/mixer.h +++ b/sound/usb/mixer.h | |||
@@ -57,7 +57,7 @@ struct usb_mixer_elem_info { | |||
57 | 57 | ||
58 | int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | 58 | int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, |
59 | int ignore_error); | 59 | int ignore_error); |
60 | void snd_usb_mixer_disconnect(struct list_head *p); | 60 | void snd_usb_mixer_disconnect(struct usb_mixer_interface *mixer); |
61 | 61 | ||
62 | void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid); | 62 | void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid); |
63 | 63 | ||