mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/5] scripts: <linux/bitops.h>: fix references to undefined __BITS_PER_LONG
Date: Sat, 30 Oct 2021 16:17:36 +0200	[thread overview]
Message-ID: <20211030141739.2207431-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20211030141739.2207431-1-a.fatoum@pengutronix.de>

No where do we define __BITS_PER_LONG, but we know about BITS_PER_LONG.
Fix it.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 scripts/include/asm-generic/bitops/__ffs.h  |  3 ++-
 scripts/include/asm-generic/bitops/atomic.h |  9 +++++----
 scripts/include/asm-generic/bitsperlong.h   | 12 ++++++++++++
 scripts/include/linux/bitops.h              |  7 +------
 4 files changed, 20 insertions(+), 11 deletions(-)
 create mode 100644 scripts/include/asm-generic/bitsperlong.h

diff --git a/scripts/include/asm-generic/bitops/__ffs.h b/scripts/include/asm-generic/bitops/__ffs.h
index c94175015a82..15ffaa12c592 100644
--- a/scripts/include/asm-generic/bitops/__ffs.h
+++ b/scripts/include/asm-generic/bitops/__ffs.h
@@ -2,6 +2,7 @@
 #define _TOOLS_LINUX_ASM_GENERIC_BITOPS___FFS_H_
 
 #include <asm/types.h>
+#include <asm-generic/bitsperlong.h>
 
 /**
  * __ffs - find first bit in word.
@@ -13,7 +14,7 @@ static __always_inline unsigned long __ffs(unsigned long word)
 {
 	int num = 0;
 
-#if __BITS_PER_LONG == 64
+#if BITS_PER_LONG == 64
 	if ((word & 0xffffffff) == 0) {
 		num += 32;
 		word >>= 32;
diff --git a/scripts/include/asm-generic/bitops/atomic.h b/scripts/include/asm-generic/bitops/atomic.h
index 4bccd7c3d5d6..03fe804024df 100644
--- a/scripts/include/asm-generic/bitops/atomic.h
+++ b/scripts/include/asm-generic/bitops/atomic.h
@@ -2,21 +2,22 @@
 #define _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_
 
 #include <asm/types.h>
+#include <asm-generic/bitsperlong.h>
 
 static inline void set_bit(int nr, unsigned long *addr)
 {
-	addr[nr / __BITS_PER_LONG] |= 1UL << (nr % __BITS_PER_LONG);
+	addr[nr / BITS_PER_LONG] |= 1UL << (nr % BITS_PER_LONG);
 }
 
 static inline void clear_bit(int nr, unsigned long *addr)
 {
-	addr[nr / __BITS_PER_LONG] &= ~(1UL << (nr % __BITS_PER_LONG));
+	addr[nr / BITS_PER_LONG] &= ~(1UL << (nr % BITS_PER_LONG));
 }
 
 static __always_inline int test_bit(unsigned int nr, const unsigned long *addr)
 {
-	return ((1UL << (nr % __BITS_PER_LONG)) &
-		(((unsigned long *)addr)[nr / __BITS_PER_LONG])) != 0;
+	return ((1UL << (nr % BITS_PER_LONG)) &
+		(((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0;
 }
 
 #endif /* _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_ */
diff --git a/scripts/include/asm-generic/bitsperlong.h b/scripts/include/asm-generic/bitsperlong.h
new file mode 100644
index 000000000000..eb2dfd9065a7
--- /dev/null
+++ b/scripts/include/asm-generic/bitsperlong.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __BITS_PER_LONG_H_
+#define __BITS_PER_LONG_H_
+
+#ifndef __WORDSIZE
+#define __WORDSIZE (__SIZEOF_LONG__ * 8)
+#endif
+
+#define BITS_PER_LONG __WORDSIZE
+
+#endif
diff --git a/scripts/include/linux/bitops.h b/scripts/include/linux/bitops.h
index c9ec614e0db6..60f5c5b4f927 100644
--- a/scripts/include/linux/bitops.h
+++ b/scripts/include/linux/bitops.h
@@ -4,12 +4,7 @@
 #include <asm/types.h>
 #include <linux/kernel.h>
 #include <linux/compiler.h>
-
-#ifndef __WORDSIZE
-#define __WORDSIZE (__SIZEOF_LONG__ * 8)
-#endif
-
-#define BITS_PER_LONG __WORDSIZE
+#include <asm-generic/bitsperlong.h>
 
 #define BIT_MASK(nr)		(1UL << ((nr) % BITS_PER_LONG))
 #define BIT_WORD(nr)		((nr) / BITS_PER_LONG)
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-10-30 14:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-30 14:17 [PATCH 1/5] include: <linux/bitops.h>: discard left-over hweight code Ahmad Fatoum
2021-10-30 14:17 ` Ahmad Fatoum [this message]
2021-10-30 14:17 ` [PATCH 3/5] include: add dedicated header for printf/printk Ahmad Fatoum
2021-10-30 14:17 ` [PATCH 4/5] include: <asm-generic/bug.h>: make self-contained Ahmad Fatoum
2021-10-30 14:17 ` [PATCH 5/5] include: move ARRAY_AND_SIZE to <linux/kernel.h> Ahmad Fatoum
2021-11-01  9:08 ` [PATCH 1/5] include: <linux/bitops.h>: discard left-over hweight code Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211030141739.2207431-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox