diff options
author | Takashi Iwai <tiwai@suse.de> | 2018-05-03 12:33:32 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-05-03 12:35:19 +0200 |
commit | 8c558076c740e8009a96c6fdc3d4245dde62be77 (patch) | |
tree | 361e87f1a346bff4a243a2538fb109665978317b /sound/usb/mixer.h | |
parent | 207459a2804a64d0f0f05c8aba04e0b0844661f2 (diff) |
ALSA: usb-audio: Clean up mixer element list traverse
Introduce a new macro for iterating over mixer element list for
avoiding the open codes in many places. Also the open-coded
container_of() and the forced cast to struct usb_mixer_elem_info are
replaced with another simple macro, too.
No functional changes but just readability improvement.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/mixer.h')
-rw-r--r-- | sound/usb/mixer.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h index ba27f7ade670..e02653465e29 100644 --- a/sound/usb/mixer.h +++ b/sound/usb/mixer.h @@ -53,6 +53,12 @@ struct usb_mixer_elem_list { usb_mixer_elem_resume_func_t resume; }; +/* iterate over mixer element list of the given unit id */ +#define for_each_mixer_elem(list, mixer, id) \ + for ((list) = (mixer)->id_elems[id]; (list); (list) = (list)->next_id_elem) +#define mixer_elem_list_to_info(list) \ + container_of(list, struct usb_mixer_elem_info, head) + struct usb_mixer_elem_info { struct usb_mixer_elem_list head; unsigned int control; /* CS or ICN (high byte) */ |