Re: [PATCH v2 1/2 RESEND] usb: gadget: u_audio: pass channel counts explicitly

From: Francesco Lavra

Date: Fri Oct 23 2026 - 06:40:12 EST


On Fri, 2026-10-16 at 09:25 -0700, Kyle Farrell wrote:
> u_audio currently derives the channel count from the channel mask in
> struct uac_params in several places.  Instead, pass the resolved count
> explicitly, so the shared audio implementation does not depend on how
> an individual USB audio function represents its channel configuration.
>
> Initialize the new channel count fields from the existing channel masks.
> This preserves generated descriptors and makes no change to user-visible
> behavior.
>
> Assisted-by: LLM
> Signed-off-by: Kyle Farrell <kaf@xxxxxxxxxx>
> ---
...
> diff --git a/drivers/usb/gadget/function/u_audio.h
> b/drivers/usb/gadget/function/u_audio.h
> index 9512b8fccfaa..46e1d6b5ca4e 100644
> --- a/drivers/usb/gadget/function/u_audio.h
> +++ b/drivers/usb/gadget/function/u_audio.h
> @@ -41,12 +41,14 @@ struct uac_fu_params {
>  struct uac_params {
>         /* playback */
>         int p_chmask;   /* channel mask */

With these changes, the channel masks are no longer used in u_audio.c, so
we can remove them.

> +       unsigned int p_channels;        /* resolved number of channels */
>         int p_srate;    /* rate in Hz */
>         int p_ssize;    /* sample size */
>         struct uac_fu_params p_fu;      /* Feature Unit parameters */
>  
>         /* capture */
>         int c_chmask;   /* channel mask */
> +       unsigned int c_channels;        /* resolved number of channels */
>         int c_srate;    /* rate in Hz */
>         int c_ssize;    /* sample size */
>         struct uac_fu_params c_fu;      /* Feature Unit parameters */