summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2014-08-27 19:09:05 +0200
committerFelipe Balbi <balbi@ti.com>2014-09-02 09:17:06 -0500
commit254b3bf68b65ac8f82da1c7e0c1a2bb17012aa7d (patch)
treebdf33e966254ca8ec9870985ca4242f6ae672388 /drivers/usb/gadget
parenta8147dabe56f7e7a4975e60abb613f7e62277577 (diff)
downloadlinux-254b3bf68b65ac8f82da1c7e0c1a2bb17012aa7d.tar.bz2
usb: gadget: f_uac2: introduce agdev_to_uac2_opts
Add a simple container_of() wrapper to get a struct f_uac2_opts from a struct struct audio_dev. Use it in two places where it is currently open-coded. Signed-off-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/function/f_uac2.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index efe8add29670..9c8831d74f5b 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -140,6 +140,12 @@ struct snd_uac2_chip *pdev_to_uac2(struct platform_device *p)
}
static inline
+struct f_uac2_opts *agdev_to_uac2_opts(struct audio_dev *agdev)
+{
+ return container_of(agdev->func.fi, struct f_uac2_opts, func_inst);
+}
+
+static inline
uint num_channels(uint chanmask)
{
uint num = 0;
@@ -1168,7 +1174,7 @@ in_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr)
int value = -EOPNOTSUPP;
int p_srate, c_srate;
- opts = container_of(agdev->func.fi, struct f_uac2_opts, func_inst);
+ opts = agdev_to_uac2_opts(agdev);
p_srate = opts->p_srate;
c_srate = opts->c_srate;
@@ -1210,7 +1216,7 @@ in_rq_range(struct usb_function *fn, const struct usb_ctrlrequest *cr)
int value = -EOPNOTSUPP;
int p_srate, c_srate;
- opts = container_of(agdev->func.fi, struct f_uac2_opts, func_inst);
+ opts = agdev_to_uac2_opts(agdev);
p_srate = opts->p_srate;
c_srate = opts->c_srate;