linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: f_uac2: fix AC Interface Header Descriptor wTotalLength
@ 2020-07-03 13:49 Ruslan Bilovol
  2020-07-09  6:38 ` Felipe Balbi
  0 siblings, 1 reply; 4+ messages in thread
From: Ruslan Bilovol @ 2020-07-03 13:49 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: linux-usb

As per UAC2 spec (ch. 4.7.2), wTotalLength of AC Interface
Header Descriptor "includes the combined length of this
descriptor header and all Clock Source, Unit and Terminal
descriptors."

Thus add its size to its wTotalLength.

Also after recent changes wTotalLength is calculated
dynamically, update static definition of uac2_ac_header_descriptor
accordingly

Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
---
 drivers/usb/gadget/function/f_uac2.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index db2d4980cb35..3633df6d7610 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -215,10 +215,7 @@ static struct uac2_ac_header_descriptor ac_hdr_desc = {
 	.bDescriptorSubtype = UAC_MS_HEADER,
 	.bcdADC = cpu_to_le16(0x200),
 	.bCategory = UAC2_FUNCTION_IO_BOX,
-	.wTotalLength = cpu_to_le16(sizeof in_clk_src_desc
-			+ sizeof out_clk_src_desc + sizeof usb_out_it_desc
-			+ sizeof io_in_it_desc + sizeof usb_in_ot_desc
-			+ sizeof io_out_ot_desc),
+	/* .wTotalLength = DYNAMIC */
 	.bmControls = 0,
 };
 
@@ -501,7 +498,7 @@ static void setup_descriptor(struct f_uac2_opts *opts)
 	as_in_hdr_desc.bTerminalLink = usb_in_ot_desc.bTerminalID;
 
 	iad_desc.bInterfaceCount = 1;
-	ac_hdr_desc.wTotalLength = 0;
+	ac_hdr_desc.wTotalLength = cpu_to_le16(sizeof(ac_hdr_desc));
 
 	if (EPIN_EN(opts)) {
 		u16 len = le16_to_cpu(ac_hdr_desc.wTotalLength);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: gadget: f_uac2: fix AC Interface Header Descriptor wTotalLength
  2020-07-03 13:49 [PATCH] usb: gadget: f_uac2: fix AC Interface Header Descriptor wTotalLength Ruslan Bilovol
@ 2020-07-09  6:38 ` Felipe Balbi
  2020-07-09 12:07   ` Ruslan Bilovol
  0 siblings, 1 reply; 4+ messages in thread
From: Felipe Balbi @ 2020-07-09  6:38 UTC (permalink / raw)
  To: Ruslan Bilovol; +Cc: linux-usb

[-- Attachment #1: Type: text/plain, Size: 547 bytes --]

Ruslan Bilovol <ruslan.bilovol@gmail.com> writes:

> As per UAC2 spec (ch. 4.7.2), wTotalLength of AC Interface
> Header Descriptor "includes the combined length of this
> descriptor header and all Clock Source, Unit and Terminal
> descriptors."
>
> Thus add its size to its wTotalLength.
>
> Also after recent changes wTotalLength is calculated
> dynamically, update static definition of uac2_ac_header_descriptor
> accordingly
>
> Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>

Missing a Fixes tag here.

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: gadget: f_uac2: fix AC Interface Header Descriptor wTotalLength
  2020-07-09  6:38 ` Felipe Balbi
@ 2020-07-09 12:07   ` Ruslan Bilovol
  2020-07-23 11:36     ` Felipe Balbi
  0 siblings, 1 reply; 4+ messages in thread
From: Ruslan Bilovol @ 2020-07-09 12:07 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: Linux USB

On Thu, Jul 9, 2020 at 9:38 AM Felipe Balbi <balbi@kernel.org> wrote:
>
> Ruslan Bilovol <ruslan.bilovol@gmail.com> writes:
>
> > As per UAC2 spec (ch. 4.7.2), wTotalLength of AC Interface
> > Header Descriptor "includes the combined length of this
> > descriptor header and all Clock Source, Unit and Terminal
> > descriptors."
> >
> > Thus add its size to its wTotalLength.
> >
> > Also after recent changes wTotalLength is calculated
> > dynamically, update static definition of uac2_ac_header_descriptor
> > accordingly
> >
> > Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
>
> Missing a Fixes tag here.

The issue is present since this driver introduction in 2012 in the
commit 132fcb460839 "usb: gadget: Add Audio Class 2.0 Driver",
but in older version of the driver it should be fixed in the
uac2_ac_header_descriptor structure initialization

Should I resend this patch or you'll add this tag to the commit message
by yourself:
Fixes: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver")

Thanks,
Ruslan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: gadget: f_uac2: fix AC Interface Header Descriptor wTotalLength
  2020-07-09 12:07   ` Ruslan Bilovol
@ 2020-07-23 11:36     ` Felipe Balbi
  0 siblings, 0 replies; 4+ messages in thread
From: Felipe Balbi @ 2020-07-23 11:36 UTC (permalink / raw)
  To: Ruslan Bilovol; +Cc: Linux USB

[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]

Ruslan Bilovol <ruslan.bilovol@gmail.com> writes:

> On Thu, Jul 9, 2020 at 9:38 AM Felipe Balbi <balbi@kernel.org> wrote:
>>
>> Ruslan Bilovol <ruslan.bilovol@gmail.com> writes:
>>
>> > As per UAC2 spec (ch. 4.7.2), wTotalLength of AC Interface
>> > Header Descriptor "includes the combined length of this
>> > descriptor header and all Clock Source, Unit and Terminal
>> > descriptors."
>> >
>> > Thus add its size to its wTotalLength.
>> >
>> > Also after recent changes wTotalLength is calculated
>> > dynamically, update static definition of uac2_ac_header_descriptor
>> > accordingly
>> >
>> > Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
>>
>> Missing a Fixes tag here.
>
> The issue is present since this driver introduction in 2012 in the
> commit 132fcb460839 "usb: gadget: Add Audio Class 2.0 Driver",
> but in older version of the driver it should be fixed in the
> uac2_ac_header_descriptor structure initialization
>
> Should I resend this patch or you'll add this tag to the commit message
> by yourself:
> Fixes: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver")

added, thanks

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-23 11:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03 13:49 [PATCH] usb: gadget: f_uac2: fix AC Interface Header Descriptor wTotalLength Ruslan Bilovol
2020-07-09  6:38 ` Felipe Balbi
2020-07-09 12:07   ` Ruslan Bilovol
2020-07-23 11:36     ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).