Skip to contentSkip to conversation

usb: drivers/usb/gadget/composite.c fails to build

U-Boot Heinrich Schuchardt 3 participants 3 messages Nov 21, 2019

lore
Share & tools
lore
#0 lore raw

Hello Marek,

I tried to reproduce the problem with tbs2910_defconfig but unfortunately the USB sub-system does not build at all with GCC 9.2.1.

The comments in include/linux/usb/ch9.h say that the __packed attribute is needed.

The problem could be solved by replacing cpu_to_le16() by a function working on byte buffers. What are your thoughts?

In file included from drivers/usb/gadget/g_dnl.c:24:
drivers/usb/gadget/composite.c: In function ‘get_string’:
drivers/usb/gadget/composite.c:545:23: error: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Werror=address-of-packed-member]

   545 |    collect_langs(sp, s->wData);
       |                      ~^~~~~~~
drivers/usb/gadget/composite.c:550:24: error: taking address of packed
member of ‘struct usb_string_descriptor’ may result in an unaligned
pointer value [-Werror=address-of-packed-member]
   550 |     collect_langs(sp, s->wData);
       |                       ~^~~~~~~
drivers/usb/gadget/composite.c:555:25: error: taking address of packed
member of ‘struct usb_string_descriptor’ may result in an unaligned
pointer value [-Werror=address-of-packed-member]
   555 |      collect_langs(sp, s->wData);
       |                        ~^~~~~~~

drivers/usb/gadget/composite.c: In function ‘bos_desc’:
drivers/usb/gadget/composite.c:708:15: error: taking address of packed member of ‘struct usb_bos_descriptor’ may result in an unaligned pointer value [-Werror=address-of-packed-member]

   708 |  le16_add_cpu(&bos->wTotalLength, USB_DT_USB_EXT_CAP_SIZE);
       |               ^~~~~~~~~~~~~~~~~~
drivers/usb/gadget/composite.c:724:16: error: taking address of packed
member of ‘struct usb_bos_descriptor’ may result in an unaligned pointer
value [-Werror=address-of-packed-member]
   724 |   le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SS_CAP_SIZE);
       |

Best regards

Heinrich

#1 lore raw
Quoted 1 line · Heinrich Schuchardt

Hello Marek,

Hi,

Quoted 2 lines

I tried to reproduce the problem with tbs2910_defconfig but unfortunately the USB sub-system does not build at all with GCC 9.2.1.

I think you enabled -Werror somewhere, which is not the default.

Quoted 5 lines

The comments in include/linux/usb/ch9.h say that the __packed attribute is needed.

The problem could be solved by replacing cpu_to_le16() by a function working on byte buffers. What are your thoughts?

Please send a patch and CC Lukasz, he's the gadget maintainer.

#2 lore raw
Quoted 11 lines · Marek Vasut
Quoted 1 line · Heinrich Schuchardt

Hello Marek,

Hi,

Quoted 2 lines

I tried to reproduce the problem with tbs2910_defconfig but unfortunately the USB sub-system does not build at all with GCC 9.2.1.

I think you enabled -Werror somewhere, which is not the default.

Quoted 7 lines
Quoted 5 lines

The comments in include/linux/usb/ch9.h say that the __packed attribute is needed.

The problem could be solved by replacing cpu_to_le16() by a function working on byte buffers. What are your thoughts?

Please send a patch and CC Lukasz, he's the gadget maintainer.

I've already sent a patch for this (and a similar error in dwc2):

https://patchwork.ozlabs.org/project/uboot/list/?series=142441

Regards,
Simon