From 345f1259a08b4f0f942b0a66ee79e98212158a29 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 13 May 2021 09:11:28 +0200 Subject: [PATCH] Revert "UPSTREAM: usb: gadget: f_uac2: validate input parameters" This reverts commit 5abbf3968552cc93bc91e61959f1327a29bae287 as it is coming in through the 5.10.36 LTS release and causes a build error when that is merged into here. Bug: 187332233 Cc: Jack Pham Signed-off-by: Greg Kroah-Hartman Change-Id: Ibd70fc1b1260bdf1da5070e80df3066606a1d45e --- drivers/usb/gadget/function/f_uac2.c | 39 ++-------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index 7aa4c8bc5a1a..409741ed88b1 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c @@ -14,9 +14,6 @@ #include "u_audio.h" #include "u_uac2.h" -/* UAC2 spec: 4.1 Audio Channel Cluster Descriptor */ -#define UAC2_CHANNEL_MASK 0x07FFFFFF - /* * The driver implements a simple UAC_2 topology. * USB-OUT -> IT_1 -> OT_3 -> ALSA_Capture @@ -680,36 +677,6 @@ static void setup_descriptor(struct f_uac2_opts *opts) setup_headers(opts, ss_audio_desc, USB_SPEED_SUPER); } -static int afunc_validate_opts(struct g_audio *agdev, struct device *dev) -{ - struct f_uac2_opts *opts = g_audio_to_uac2_opts(agdev); - - if (!opts->p_chmask && !opts->c_chmask) { - dev_err(dev, "Error: no playback and capture channels\n"); - return -EINVAL; - } else if (opts->p_chmask & ~UAC2_CHANNEL_MASK) { - dev_err(dev, "Error: unsupported playback channels mask\n"); - return -EINVAL; - } else if (opts->c_chmask & ~UAC2_CHANNEL_MASK) { - dev_err(dev, "Error: unsupported capture channels mask\n"); - return -EINVAL; - } else if ((opts->p_ssize < 1) || (opts->p_ssize > 4)) { - dev_err(dev, "Error: incorrect playback sample size\n"); - return -EINVAL; - } else if ((opts->c_ssize < 1) || (opts->c_ssize > 4)) { - dev_err(dev, "Error: incorrect capture sample size\n"); - return -EINVAL; - } else if (!opts->p_srate) { - dev_err(dev, "Error: incorrect playback sampling rate\n"); - return -EINVAL; - } else if (!opts->c_srate) { - dev_err(dev, "Error: incorrect capture sampling rate\n"); - return -EINVAL; - } - - return 0; -} - static int afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) { @@ -718,13 +685,11 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) struct usb_composite_dev *cdev = cfg->cdev; struct usb_gadget *gadget = cdev->gadget; struct device *dev = &gadget->dev; - struct f_uac2_opts *uac2_opts = g_audio_to_uac2_opts(agdev); + struct f_uac2_opts *uac2_opts; struct usb_string *us; int ret; - ret = afunc_validate_opts(agdev, dev); - if (ret) - return ret; + uac2_opts = container_of(fn->fi, struct f_uac2_opts, func_inst); us = usb_gstrings_attach(cdev, fn_strings, ARRAY_SIZE(strings_fn)); if (IS_ERR(us))