]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
usb: gadget: f_uac2: introduce agdev_to_uac2_opts
authorDaniel Mack <zonque@gmail.com>
Wed, 27 Aug 2014 17:09:05 +0000 (19:09 +0200)
committerFelipe Balbi <balbi@ti.com>
Tue, 2 Sep 2014 14:17:06 +0000 (09:17 -0500)
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>
drivers/usb/gadget/function/f_uac2.c

index efe8add29670043656beb0e883a895481f234777..9c8831d74f5b18a899968596ef99c2a05bc92def 100644 (file)
@@ -139,6 +139,12 @@ struct snd_uac2_chip *pdev_to_uac2(struct platform_device *p)
        return container_of(p, struct snd_uac2_chip, pdev);
 }
 
+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)
 {
@@ -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;