Re: [PATCH -next] printk: Use the BITS_PER_LONG macro

From: Jinjie Ruan
Date: Mon Sep 02 2024 - 23:39:42 EST




On 2024/9/2 20:07, John Ogness wrote:
> On 2024-09-02, Jinjie Ruan <ruanjinjie@xxxxxxxxxx> wrote:
>> sizeof(unsigned long) * 8 is the number of bits in an unsigned long
>> variable, replace it with BITS_PER_LONG macro to make it simpler.
>>
>> Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
>> ---
>> kernel/printk/printk_ringbuffer.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/printk/printk_ringbuffer.h b/kernel/printk/printk_ringbuffer.h
>> index bd2a892deac1..7433fe477e08 100644
>> --- a/kernel/printk/printk_ringbuffer.h
>> +++ b/kernel/printk/printk_ringbuffer.h
>> @@ -122,7 +122,7 @@ enum desc_state {
>>
>> #define _DATA_SIZE(sz_bits) (1UL << (sz_bits))
>> #define _DESCS_COUNT(ct_bits) (1U << (ct_bits))
>> -#define DESC_SV_BITS (sizeof(unsigned long) * 8)
>> +#define DESC_SV_BITS BITS_PER_LONG
>
> We should also add:
>
> #include <linux/bits.h>

maybe #include <asm/bitsperlong.h> ?

>
> John Ogness