public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/1] usb: avoid -Werror=address-of-packed-member
@ 2019-12-17  9:27 Heinrich Schuchardt
  2019-12-17 10:00 ` Marek Vasut
  0 siblings, 1 reply; 10+ messages in thread
From: Heinrich Schuchardt @ 2019-12-17  9:27 UTC (permalink / raw)
  To: u-boot

With GCC 9.2.1 errors of type -Werror=address-of-packed-member occur when
passing a member of a packed structure to le16_to_cpus() on a big endian
system (e.g. P2041RDB_defconfig).

Replace le16_to_cpus() by get_unaligned_le16(). Check defined(__BIG_ENDIAN)
to avoid the introduction of unnecessary instructions on little endian
systems as seen on aarch64.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 common/usb.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/common/usb.c b/common/usb.c
index d9bcb5a57e..de6f7a3bf4 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -1078,10 +1078,16 @@ int usb_select_config(struct usb_device *dev)
 		return err;

 	/* correct le values */
-	le16_to_cpus(&dev->descriptor.bcdUSB);
-	le16_to_cpus(&dev->descriptor.idVendor);
-	le16_to_cpus(&dev->descriptor.idProduct);
-	le16_to_cpus(&dev->descriptor.bcdDevice);
+#if defined(__BIG_ENDIAN)
+	dev->descriptor.bcdUSB =
+		get_unaligned_le16(&dev->descriptor.bcdUSB);
+	dev->descriptor.idVendor =
+		get_unaligned_le16(&dev->descriptor.idVendor);
+	dev->descriptor.idProduct =
+		get_unaligned_le16(&dev->descriptor.idProduct);
+	dev->descriptor.bcdDevice =
+		get_unaligned_le16(&dev->descriptor.bcdDevice);
+#endif

 	/*
 	 * Kingston DT Ultimate 32GB USB 3.0 seems to be extremely sensitive
--
2.24.0

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

end of thread, other threads:[~2019-12-31  4:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-17  9:27 [PATCH 1/1] usb: avoid -Werror=address-of-packed-member Heinrich Schuchardt
2019-12-17 10:00 ` Marek Vasut
2019-12-17 11:14   ` Heinrich Schuchardt
2019-12-17 11:19     ` Marek Vasut
2019-12-17 11:59       ` Heinrich Schuchardt
2019-12-17 12:19         ` Marek Vasut
2019-12-17 19:32           ` Heinrich Schuchardt
2019-12-17 19:52             ` Marek Vasut
2019-12-30 15:41               ` Tom Rini
2019-12-31  4:00                 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox