linux/compat.h: port lower_32_bits and upper_32_bits from Linux
Subsystems (2)
PATCH v2 1/1 linux/compat.h: port lower_32_bits and upper_32_bits from Linux
[backport from linux commit 204b885e and 218e180e7] 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.
---
Change log
v2: add git SHA of linux kernel tree.
drivers/usb/host/xhci.h | 4 +--- include/linux/compat.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-)
drivers/usb/host/xhci.h +1 -3
@@ -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
include/linux/compat.h +17 -0
@@ -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
Signature · 1 line
1.9.0
PATCH v2 1/1 linux/compat.h: port lower_32_bits and upper_32_bits from Linux
Dear Lijun Pan,
In message <[email protected]> you wrote:
...
Quoted 2 lines
+ *
upper_32_bits- return bits 32-63 of a number
+ * @n: the number we're accessing
Comments wrong on Power Architecture.
Quoted 2 lines
+ *
lower_32_bits- return bits 0-31 of a number
+ * @n: the number we're accessing
Ditto.
BTW: what exactly are the license terms for this code?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "Life is a garment we continuously alter, but which never seems to fit." - David McCord
A message that is not in the archive (sent off-list or not yet received): 31b1cf51fd954208b6140035eb705888@DM2PR03MB368.namprd03.prod.outlook.com
PATCH v2 1/1 linux/compat.h: port lower_32_bits and upper_32_bits from Linux
Dear Lijun Pan,
Quoted 4 lines · In message <31b1cf51fd954208b6140035eb705888@DM2PR03MB368.namprd03.prod.outlook…
Quoted 2 lines
BTW: what exactly are the license terms for this code?
The code taken from Linux is using GPLv2.
Are you sure about this?
I think these functions were copied from include/linux/kernel.h - is this correct? In this case there would be no explicit license terms (there is no license header in that file), so we assume the global project wide license applies?
Especially as include/linux/compat.h contains no license tag either we should clearly document this.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de You can't have everything... where would you put it? - Steven Wright