diff mbox series

[U-Boot,v3,02/20] bitops: Fix GENMASK definition for Sandbox

Message ID 20190129055007.17376-3-vigneshr@ti.com
State Changes Requested
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series SF: Migrate to Linux SPI NOR framework | expand

Commit Message

Raghavendra, Vignesh Jan. 29, 2019, 5:49 a.m. UTC
In arch/sandbox/include/asm/types.h we have
Therefore for 32 bit Sandbox build BITS_PER_LONG turns out to be 32 as
CONFIG_PHYS64 is not set

This messes up the current logic of GENMASK macro due to mismatch b/w
size of unsigned long (64 bit) and that of BITS_PER_LONG.
Fix this by using CONFIG_SANDBOX_BITS_PER_LONG which is set to 64/32
based on the host machine on which its being compiled.

Without this patch:
GENMASK(14,0) => 0x7fffffffffff
After this patch:
GENMASK(14,0) => 0x7fff

Signed-off-by: Vignesh R <vigneshr@ti.com>
---
 include/linux/bitops.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Simon Glass Jan. 31, 2019, 12:41 a.m. UTC | #1
On Mon, 28 Jan 2019 at 22:49, Vignesh R <vigneshr@ti.com> wrote:
>
> In arch/sandbox/include/asm/types.h we have
> Therefore for 32 bit Sandbox build BITS_PER_LONG turns out to be 32 as
> CONFIG_PHYS64 is not set
>
> This messes up the current logic of GENMASK macro due to mismatch b/w
> size of unsigned long (64 bit) and that of BITS_PER_LONG.
> Fix this by using CONFIG_SANDBOX_BITS_PER_LONG which is set to 64/32
> based on the host machine on which its being compiled.
>
> Without this patch:
> GENMASK(14,0) => 0x7fffffffffff
> After this patch:
> GENMASK(14,0) => 0x7fff
>
> Signed-off-by: Vignesh R <vigneshr@ti.com>
> ---
>  include/linux/bitops.h | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
Raghavendra, Vignesh Jan. 31, 2019, 1:34 p.m. UTC | #2
On 31/01/19 6:11 AM, Simon Glass wrote:
> On Mon, 28 Jan 2019 at 22:49, Vignesh R <vigneshr@ti.com> wrote:
>>
>> In arch/sandbox/include/asm/types.h we have
>> Therefore for 32 bit Sandbox build BITS_PER_LONG turns out to be 32 as
>> CONFIG_PHYS64 is not set
>>
>> This messes up the current logic of GENMASK macro due to mismatch b/w
>> size of unsigned long (64 bit) and that of BITS_PER_LONG.
>> Fix this by using CONFIG_SANDBOX_BITS_PER_LONG which is set to 64/32
>> based on the host machine on which its being compiled.
>>
>> Without this patch:
>> GENMASK(14,0) => 0x7fffffffffff
>> After this patch:
>> GENMASK(14,0) => 0x7fff
>>
>> Signed-off-by: Vignesh R <vigneshr@ti.com>
>> ---
>>  include/linux/bitops.h | 5 +++++
>>  1 file changed, 5 insertions(+)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 

I realised this patch is already merged to u-boot-dm when I posted it as
an RFC. Please ignore. Thanks!
diff mbox series

Patch

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index a47f6d17bb5f..259df43fb00f 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -21,8 +21,13 @@ 
  * position @h. For example
  * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
  */
+#ifdef CONFIG_SANDBOX
+#define GENMASK(h, l) \
+	(((~0UL) << (l)) & (~0UL >> (CONFIG_SANDBOX_BITS_PER_LONG - 1 - (h))))
+#else
 #define GENMASK(h, l) \
 	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+#endif
 
 #define GENMASK_ULL(h, l) \
 	(((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))