linux-brain/tools/usb
Peter Senna Tschudin 7b85bc4bea tools: usb: ffs-test: Fix build on big endian systems
[ Upstream commit a2b22dddc7 ]

The tools/usb/ffs-test.c file defines cpu_to_le16/32 by using the C
library htole16/32 function calls. However, cpu_to_le16/32 are used when
initializing structures, i.e in a context where a function call is not
allowed.

It works fine on little endian systems because htole16/32 are defined by
the C library as no-ops. But on big-endian systems, they are actually
doing something, which might involve calling a function, causing build
failures, such as:

   ffs-test.c:48:25: error: initializer element is not constant
    #define cpu_to_le32(x)  htole32(x)
                            ^~~~~~~
   ffs-test.c:128:12: note: in expansion of macro ‘cpu_to_le32’
      .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2),
               ^~~~~~~~~~~

To solve this, we code cpu_to_le16/32 in a way that allows them to be
used when initializing structures. This fix was imported from
meta-openembedded/android-tools/fix-big-endian-build.patch written by
Thomas Petazzoni <thomas.petazzoni@free-electrons.com>.

CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-05 09:18:34 +02:00
..
ffs-aio-example tools: ffs-aio-example: use endpoint addresses from descriptors 2015-01-15 09:41:49 -06:00
usbip usbip: usbip_detach: Fix memory, udev context and udev leak 2018-08-06 16:24:31 +02:00
ffs-test.c tools: usb: ffs-test: Fix build on big endian systems 2018-09-05 09:18:34 +02:00
hcd-tests.sh USB: usbtest - add alignment tests to test script 2011-01-22 19:42:14 -08:00
Makefile Revert "tools: ffs-test: convert to new descriptor format fixing compilation error" 2014-06-27 10:41:00 -05:00
testusb.c tools: usb: testusb: change the default value for length from 512 to 1024 2015-09-27 10:54:31 -05:00