aboutsummaryrefslogtreecommitdiff
path: root/include/usb.h
diff options
context:
space:
mode:
authorMarkus Klotzbuecher <mk@denx.de>2006-11-27 11:46:46 +0100
committerMarkus Klotzbuecher <mk@pollux.denx.de>2006-11-27 11:46:46 +0100
commitae3b770e4eae8e98b6e9e29662e18c47fdf0171f (patch)
tree902aa56bab47d79b5b67e55bc13cb92a168236df /include/usb.h
parent7b59b3c7a8ce2e4b567abf99c1cd667bf35b9418 (diff)
Fix some endianness issues related to the generic ohci driver
Diffstat (limited to 'include/usb.h')
-rw-r--r--include/usb.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/include/usb.h b/include/usb.h
index fafac8934..419a7e364 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -230,16 +230,12 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);
/* big endian -> little endian conversion */
/* some CPUs are already little endian e.g. the ARM920T */
-#ifdef LITTLEENDIAN
-#define swap_16(x) ((unsigned short)(x))
-#define swap_32(x) ((unsigned long)(x))
-#else
-#define swap_16(x) \
+#define __swap_16(x) \
({ unsigned short x_ = (unsigned short)x; \
(unsigned short)( \
((x_ & 0x00FFU) << 8) | ((x_ & 0xFF00U) >> 8) ); \
})
-#define swap_32(x) \
+#define __swap_32(x) \
({ unsigned long x_ = (unsigned long)x; \
(unsigned long)( \
((x_ & 0x000000FFUL) << 24) | \
@@ -247,6 +243,13 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);
((x_ & 0x00FF0000UL) >> 8) | \
((x_ & 0xFF000000UL) >> 24) ); \
})
+
+#ifdef LITTLEENDIAN
+# define swap_16(x) (x)
+# define swap_32(x) (x)
+#else
+# define swap_16(x) __swap_16(x)
+# define swap_32(x) __swap_32(x)
#endif /* LITTLEENDIAN */
/*