public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] printk: Use the BITS_PER_LONG macro
@ 2024-09-02 11:09 Jinjie Ruan
  2024-09-02 12:07 ` John Ogness
  0 siblings, 1 reply; 4+ messages in thread
From: Jinjie Ruan @ 2024-09-02 11:09 UTC (permalink / raw)
  To: pmladek, rostedt, john.ogness, senozhatsky, linux-kernel; +Cc: ruanjinjie

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@huawei.com>
---
 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
 #define DESC_FLAGS_SHIFT	(DESC_SV_BITS - 2)
 #define DESC_FLAGS_MASK		(3UL << DESC_FLAGS_SHIFT)
 #define DESC_STATE(sv)		(3UL & (sv >> DESC_FLAGS_SHIFT))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] printk: Use the BITS_PER_LONG macro
  2024-09-02 11:09 [PATCH -next] printk: Use the BITS_PER_LONG macro Jinjie Ruan
@ 2024-09-02 12:07 ` John Ogness
  2024-09-03  3:39   ` Jinjie Ruan
  0 siblings, 1 reply; 4+ messages in thread
From: John Ogness @ 2024-09-02 12:07 UTC (permalink / raw)
  To: Jinjie Ruan, pmladek, rostedt, senozhatsky, linux-kernel; +Cc: ruanjinjie

On 2024-09-02, Jinjie Ruan <ruanjinjie@huawei.com> 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@huawei.com>
> ---
>  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>

John Ogness

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] printk: Use the BITS_PER_LONG macro
  2024-09-02 12:07 ` John Ogness
@ 2024-09-03  3:39   ` Jinjie Ruan
  0 siblings, 0 replies; 4+ messages in thread
From: Jinjie Ruan @ 2024-09-03  3:39 UTC (permalink / raw)
  To: John Ogness, pmladek, rostedt, senozhatsky, linux-kernel



On 2024/9/2 20:07, John Ogness wrote:
> On 2024-09-02, Jinjie Ruan <ruanjinjie@huawei.com> 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@huawei.com>
>> ---
>>  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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH -next] printk: Use the BITS_PER_LONG macro
@ 2024-09-03  3:53 Jinjie Ruan
  0 siblings, 0 replies; 4+ messages in thread
From: Jinjie Ruan @ 2024-09-03  3:53 UTC (permalink / raw)
  To: pmladek, rostedt, john.ogness, senozhatsky, linux-kernel; +Cc: ruanjinjie

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@huawei.com>
---
v2:
- Add include.
---
 kernel/printk/printk_ringbuffer.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/printk/printk_ringbuffer.h b/kernel/printk/printk_ringbuffer.h
index bd2a892deac1..8de6c495cf2b 100644
--- a/kernel/printk/printk_ringbuffer.h
+++ b/kernel/printk/printk_ringbuffer.h
@@ -4,6 +4,7 @@
 #define _KERNEL_PRINTK_RINGBUFFER_H
 
 #include <linux/atomic.h>
+#include <linux/bits.h>
 #include <linux/dev_printk.h>
 #include <linux/stddef.h>
 #include <linux/types.h>
@@ -122,7 +123,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
 #define DESC_FLAGS_SHIFT	(DESC_SV_BITS - 2)
 #define DESC_FLAGS_MASK		(3UL << DESC_FLAGS_SHIFT)
 #define DESC_STATE(sv)		(3UL & (sv >> DESC_FLAGS_SHIFT))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-09-03  3:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-02 11:09 [PATCH -next] printk: Use the BITS_PER_LONG macro Jinjie Ruan
2024-09-02 12:07 ` John Ogness
2024-09-03  3:39   ` Jinjie Ruan
  -- strict thread matches above, loose matches on Subject: below --
2024-09-03  3:53 Jinjie Ruan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox