lkml.org 
[lkml]   [2018]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] bitops: Introduce BITS_PER_TYPE
From
Date
On 07/06/18 11:00, Chris Wilson wrote:
> Quoting Randy Dunlap (2018-07-06 18:55:57)
>> On 07/06/18 10:51, Chris Wilson wrote:
>>> Quoting Randy Dunlap (2018-07-06 18:48:55)
>>>>
>>>> On 07/06/18 02:44, Chris Wilson wrote:
>>>>> net_dim.h has a rather useful extension to BITS_PER_BYTE to compute the
>>>>> number of bits in a type (BITS_PER_BYTE * sizeof(T)), so promote the
>>>>> macro to bitops.h, alongside BITS_PER_BYTE, for wider usage.
>>>>>
>>>>> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>>>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>>>> Cc: Andy Gospodarek <gospo@broadcom.com>
>>>>> Cc: David S. Miller <davem@davemloft.net>
>>>>> Cc: Thomas Gleixner <tglx@linutronix.de>
>>>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>>>> Cc: Ingo Molnar <mingo@kernel.org>
>>>>> ---
>>>>> include/linux/bitops.h | 3 ++-
>>>>> include/linux/net_dim.h | 1 -
>>>>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/include/linux/bitops.h b/include/linux/bitops.h
>>>>> index 4cac4e1a72ff..091cb17d1a9b 100644
>>>>> --- a/include/linux/bitops.h
>>>>> +++ b/include/linux/bitops.h
>>>>> @@ -11,7 +11,8 @@
>>>>> #define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG))
>>>>> #define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG)
>>>>> #define BITS_PER_BYTE 8
>>>>> -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
>>>>> +#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
>>>>> +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(long))
>>>>> #endif
>>>>>
>>>>> /*
>>>>
>>>> doesn't <linux/net_dim.h> need to #include <linux/bitops.h> ?
>>>
>>> It already has to in order to obtain BITS_PER_BYTE. Just doesn't do so
>>> directly.
>>
>> Right. and does that work on all $ARCHes?
>
> It's a pre-existing dependency in the header, net_dim.h cannot
> compile unless BITS_PER_BYTE is defined i.e. bitops.h is included.
> The patch does not affect that.

Yes, I see. net_dim.h should have #included bits.h and/or bitops.h previously.

thanks,
--
~Randy

\
 
 \ /
  Last update: 2018-07-06 20:38    [W:0.043 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site