[U-Boot] [PATCH] linux/compat.h: port lower_32_bits and upper_32_bits from Linux

lower_32_bits and upper_32_bits are very useful while programming. Port these two functions here from Linux:include/linux/kernel.h, also remove the definition in drivers/usb/host/xhci.h. Later on, developers could include linux/compat.h if they want to use these two functions.
Signed-off-by: Lijun Pan Lijun.Pan@freescale.com --- drivers/usb/host/xhci.h | 4 +--- include/linux/compat.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index ceb1573..6381596 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -20,9 +20,7 @@ #include <asm/cache.h> #include <asm/io.h> #include <linux/list.h> - -#define upper_32_bits(n) (u32)((n) >> 32) -#define lower_32_bits(n) (u32)(n) +#include <linux/compat.h>
#define MAX_EP_CTX_NUM 31 #define XHCI_ALIGNMENT 64 diff --git a/include/linux/compat.h b/include/linux/compat.h index 3fdfb39..bc51dd1 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -57,4 +57,21 @@ , __FILE__, __LINE__); }
#define PAGE_SIZE 4096 + +/** + * upper_32_bits - return bits 32-63 of a number + * @n: the number we're accessing + * + * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress + * the "right shift count >= width of type" warning when that quantity is + * 32-bits. + */ +#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) + +/** + * lower_32_bits - return bits 0-31 of a number + * @n: the number we're accessing + */ +#define lower_32_bits(n) ((u32)(n)) + #endif

On Fri, Jun 06, 2014 at 03:05:08PM -0500, Lijun Pan wrote:
lower_32_bits and upper_32_bits are very useful while programming. Port these two functions here from Linux:include/linux/kernel.h, also remove the definition in drivers/usb/host/xhci.h. Later on, developers could include linux/compat.h if they want to use these two functions.
Signed-off-by: Lijun Pan Lijun.Pan@freescale.com
Per http://www.denx.de/wiki/view/U-Boot/Patches#Attributing_Code_Copyrights_Sign you need to say what git hash or tag this comes from in the kernel.

Dear Lijun Pan,
In message 1402085108-11841-1-git-send-email-Lijun.Pan@freescale.com you wrote:
lower_32_bits and upper_32_bits are very useful while programming.
"is very useful" is not enough reason to add any code.
Where are the actual users of these functions? We will not add dead code.
+/**
- upper_32_bits - return bits 32-63 of a number
- @n: the number we're accessing
Hm... This comment is definitely wrong for the Power Architecture, where bit 0 is always the most significan bit, so upper_32_bits would reutn bits 0...31.
Best regards,
Wolfgang Denk
participants (3)
-
Lijun Pan
-
Tom Rini
-
Wolfgang Denk