mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/5] include: <linux/bitops.h>: discard left-over hweight code
@ 2021-10-30 14:17 Ahmad Fatoum
  2021-10-30 14:17 ` [PATCH 2/5] scripts: <linux/bitops.h>: fix references to undefined __BITS_PER_LONG Ahmad Fatoum
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2021-10-30 14:17 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

There are no definitions for __sw_hweight*, so no point in keeping the
prototypes around. The scripts version of the header also ultimately
tries to access non-existing normal headers, so fix that up as well.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/linux/bitops.h                             | 5 -----
 scripts/include/asm-generic/bitops/arch_hweight.h  | 1 -
 scripts/include/asm-generic/bitops/const_hweight.h | 1 -
 scripts/include/asm-generic/bitops/hweight.h       | 3 +--
 scripts/include/linux/bitops.h                     | 4 ----
 5 files changed, 1 insertion(+), 13 deletions(-)
 delete mode 100644 scripts/include/asm-generic/bitops/arch_hweight.h
 delete mode 100644 scripts/include/asm-generic/bitops/const_hweight.h

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 31345c219d33..dd13bf93118c 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -24,11 +24,6 @@
 #define GENMASK_ULL(h, l) \
 	(((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
 
-extern unsigned int __sw_hweight8(unsigned int w);
-extern unsigned int __sw_hweight16(unsigned int w);
-extern unsigned int __sw_hweight32(unsigned int w);
-extern unsigned long __sw_hweight64(__u64 w);
-
 /*
  * Include this here because some architectures need generic_ffs/fls in
  * scope
diff --git a/scripts/include/asm-generic/bitops/arch_hweight.h b/scripts/include/asm-generic/bitops/arch_hweight.h
deleted file mode 100644
index 318bb2b202b0..000000000000
--- a/scripts/include/asm-generic/bitops/arch_hweight.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../../../include/asm-generic/bitops/arch_hweight.h"
diff --git a/scripts/include/asm-generic/bitops/const_hweight.h b/scripts/include/asm-generic/bitops/const_hweight.h
deleted file mode 100644
index 0afd644aff83..000000000000
--- a/scripts/include/asm-generic/bitops/const_hweight.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../../../include/asm-generic/bitops/const_hweight.h"
diff --git a/scripts/include/asm-generic/bitops/hweight.h b/scripts/include/asm-generic/bitops/hweight.h
index 290120c01a8e..eb95ca33d5c0 100644
--- a/scripts/include/asm-generic/bitops/hweight.h
+++ b/scripts/include/asm-generic/bitops/hweight.h
@@ -1,7 +1,6 @@
 #ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_HWEIGHT_H_
 #define _TOOLS_LINUX_ASM_GENERIC_BITOPS_HWEIGHT_H_
 
-#include <asm-generic/bitops/arch_hweight.h>
-#include <asm-generic/bitops/const_hweight.h>
+#include "../../../../include/asm-generic/bitops/hweight.h"
 
 #endif /* _TOOLS_LINUX_ASM_GENERIC_BITOPS_HWEIGHT_H_ */
diff --git a/scripts/include/linux/bitops.h b/scripts/include/linux/bitops.h
index 5ad9ee1dd7f6..c9ec614e0db6 100644
--- a/scripts/include/linux/bitops.h
+++ b/scripts/include/linux/bitops.h
@@ -19,10 +19,6 @@
 #define BITS_TO_U32(nr)		DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32))
 #define BITS_TO_BYTES(nr)	DIV_ROUND_UP(nr, BITS_PER_BYTE)
 
-extern unsigned int __sw_hweight8(unsigned int w);
-extern unsigned int __sw_hweight16(unsigned int w);
-extern unsigned int __sw_hweight32(unsigned int w);
-extern unsigned long __sw_hweight64(__u64 w);
 
 /*
  * Include this here because some architectures need generic_ffs/fls in
-- 
2.30.2


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


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

* [PATCH 2/5] scripts: <linux/bitops.h>: fix references to undefined __BITS_PER_LONG
  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
  2021-10-30 14:17 ` [PATCH 3/5] include: add dedicated header for printf/printk Ahmad Fatoum
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2021-10-30 14:17 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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


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

* [PATCH 3/5] include: add dedicated header for printf/printk
  2021-10-30 14:17 [PATCH 1/5] include: <linux/bitops.h>: discard left-over hweight code Ahmad Fatoum
  2021-10-30 14:17 ` [PATCH 2/5] scripts: <linux/bitops.h>: fix references to undefined __BITS_PER_LONG Ahmad Fatoum
@ 2021-10-30 14:17 ` Ahmad Fatoum
  2021-10-30 14:17 ` [PATCH 4/5] include: <asm-generic/bug.h>: make self-contained Ahmad Fatoum
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2021-10-30 14:17 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Including <stdio.h> for printf is a bit problematic, because it pulls in
other headers for <console.h>, which includes quite a few more headers
as well. To make it easier to share code between barebox and host tools
make <printk.h> the new minimal header for printf and move the extra
logging stuff into <linux/printk.h>.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/boards/netgear-rn2120/board.c  |   2 +-
 arch/arm/mach-mvebu/kwb_bbu.c           |   2 +-
 common/bootchooser.c                    |   2 +-
 common/optee.c                          |   2 +-
 common/state/backend_bucket_direct.c    |   2 +-
 common/state/backend_storage.c          |   2 +-
 common/state/state_variables.c          |   2 +-
 drivers/clk/analogbits/wrpll-cln28hpc.c |   2 +-
 drivers/clk/at91/pmc.h                  |   2 +-
 drivers/clk/sifive/sifive-prci.c        |   2 +-
 drivers/gpio/gpio-sifive.c              |   2 +-
 drivers/gpio/gpio-starfive-vic.c        |   2 +-
 drivers/pwm/pwm-atmel.c                 |   2 +-
 drivers/soc/sifive/sifive_l2_cache.c    |   2 +-
 drivers/watchdog/f71808e_wdt.c          |   2 +-
 fs/pstore/platform.c                    |   2 +-
 fs/pstore/ram.c                         |   2 +-
 fs/squashfs/squashfs.h                  |   2 +-
 include/common.h                        |   2 +-
 include/linux/barebox-wrapper.h         |  15 +-
 include/linux/mtd/mtd.h                 |   2 +-
 include/linux/printk.h                  | 173 ++++++++++++++++++++++++
 include/printk.h                        | 168 ++---------------------
 include/stdio.h                         |   8 +-
 lib/hexdump.c                           |   2 +-
 lib/kasan/report.c                      |   2 +-
 pbl/fdt.c                               |   2 +-
 27 files changed, 211 insertions(+), 199 deletions(-)
 create mode 100644 include/linux/printk.h

diff --git a/arch/arm/boards/netgear-rn2120/board.c b/arch/arm/boards/netgear-rn2120/board.c
index caf106af50d6..d5756e09694b 100644
--- a/arch/arm/boards/netgear-rn2120/board.c
+++ b/arch/arm/boards/netgear-rn2120/board.c
@@ -2,7 +2,7 @@
 #include <init.h>
 #include <of.h>
 #include <gpio.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <linux/kernel.h>
 #include <asm/armlinux.h>
 #include <generated/mach-types.h>
diff --git a/arch/arm/mach-mvebu/kwb_bbu.c b/arch/arm/mach-mvebu/kwb_bbu.c
index f79464fe53e4..3de575740c27 100644
--- a/arch/arm/mach-mvebu/kwb_bbu.c
+++ b/arch/arm/mach-mvebu/kwb_bbu.c
@@ -1,6 +1,6 @@
 #include <bbu.h>
 #include <libfile.h>
-#include <printk.h>
+#include <linux/printk.h>
 
 #include <mach/bbu.h>
 
diff --git a/common/bootchooser.c b/common/bootchooser.c
index 2f22e03c4768..75dfbc6166c2 100644
--- a/common/bootchooser.c
+++ b/common/bootchooser.c
@@ -13,7 +13,7 @@
 #include <libfile.h>
 #include <common.h>
 #include <malloc.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <xfuncs.h>
 #include <envfs.h>
 #include <errno.h>
diff --git a/common/optee.c b/common/optee.c
index d542dde11854..b460fbcd0161 100644
--- a/common/optee.c
+++ b/common/optee.c
@@ -3,7 +3,7 @@
 #define pr_fmt(fmt) "optee: " fmt
 
 #include <tee/optee.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <asm-generic/errno.h>
 
 int optee_verify_header(struct optee_header *hdr)
diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
index 4522f0170f3d..517aec60634b 100644
--- a/common/state/backend_bucket_direct.c
+++ b/common/state/backend_bucket_direct.c
@@ -17,7 +17,7 @@
 #include <libfile.h>
 #include <linux/kernel.h>
 #include <malloc.h>
-#include <printk.h>
+#include <linux/printk.h>
 
 #include "state.h"
 
diff --git a/common/state/backend_storage.c b/common/state/backend_storage.c
index fe7e89e8fb39..7fc7acfdcbc8 100644
--- a/common/state/backend_storage.c
+++ b/common/state/backend_storage.c
@@ -21,7 +21,7 @@
 #include <linux/mtd/mtd-abi.h>
 #include <sys/stat.h>
 #include <malloc.h>
-#include <printk.h>
+#include <linux/printk.h>
 
 #include "state.h"
 
diff --git a/common/state/state_variables.c b/common/state/state_variables.c
index 66c66f38bd45..f112c60bf602 100644
--- a/common/state/state_variables.c
+++ b/common/state/state_variables.c
@@ -21,7 +21,7 @@
 #include <linux/types.h>
 #include <malloc.h>
 #include <net.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <of.h>
 #include <stdio.h>
 
diff --git a/drivers/clk/analogbits/wrpll-cln28hpc.c b/drivers/clk/analogbits/wrpll-cln28hpc.c
index 640af533d606..5a3602649f18 100644
--- a/drivers/clk/analogbits/wrpll-cln28hpc.c
+++ b/drivers/clk/analogbits/wrpll-cln28hpc.c
@@ -23,7 +23,7 @@
 
 #include <linux/kernel.h>
 #include <stdio.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <linux/bug.h>
 #include <linux/err.h>
 #include <linux/log2.h>
diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
index 4e6ec8231eae..f9b2324f6aac 100644
--- a/drivers/clk/at91/pmc.h
+++ b/drivers/clk/at91/pmc.h
@@ -10,7 +10,7 @@
 
 #include <io.h>
 #include <linux/bitops.h>
-#include <printk.h>
+#include <linux/printk.h>
 
 struct pmc_data {
 	unsigned int ncore;
diff --git a/drivers/clk/sifive/sifive-prci.c b/drivers/clk/sifive/sifive-prci.c
index 1701a2c5a0ef..fa0d1dc432bf 100644
--- a/drivers/clk/sifive/sifive-prci.c
+++ b/drivers/clk/sifive/sifive-prci.c
@@ -8,7 +8,7 @@
 #include <linux/list.h>
 #include <linux/clkdev.h>
 #include <linux/overflow.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <clock.h>
 #include <io.h>
 #include <of.h>
diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
index 63f2c097e446..58ffd8778855 100644
--- a/drivers/gpio/gpio-sifive.c
+++ b/drivers/gpio/gpio-sifive.c
@@ -4,7 +4,7 @@
  */
 
 #include <linux/basic_mmio_gpio.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <driver.h>
 #include <errno.h>
 
diff --git a/drivers/gpio/gpio-starfive-vic.c b/drivers/gpio/gpio-starfive-vic.c
index baa4f584d5e8..4f8c0c6cd779 100644
--- a/drivers/gpio/gpio-starfive-vic.c
+++ b/drivers/gpio/gpio-starfive-vic.c
@@ -6,7 +6,7 @@
 #include <linux/basic_mmio_gpio.h>
 #include <linux/reset.h>
 #include <linux/clk.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <driver.h>
 #include <errno.h>
 #include <pinctrl.h>
diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
index 7fa394934a76..1c6214594c9d 100644
--- a/drivers/pwm/pwm-atmel.c
+++ b/drivers/pwm/pwm-atmel.c
@@ -12,7 +12,7 @@
 #include <common.h>
 #include <driver.h>
 #include <module.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <stdio.h>
 #include <init.h>
 #include <pwm.h>
diff --git a/drivers/soc/sifive/sifive_l2_cache.c b/drivers/soc/sifive/sifive_l2_cache.c
index a1e9a1062204..c1b7fda9c868 100644
--- a/drivers/soc/sifive/sifive_l2_cache.c
+++ b/drivers/soc/sifive/sifive_l2_cache.c
@@ -9,7 +9,7 @@
 #define pr_fmt(fmt) "sifive-l2: " fmt
 
 #include <io.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <stdio.h>
 #include <driver.h>
 #include <init.h>
diff --git a/drivers/watchdog/f71808e_wdt.c b/drivers/watchdog/f71808e_wdt.c
index 925c2f809df7..b2cf0f8ddd22 100644
--- a/drivers/watchdog/f71808e_wdt.c
+++ b/drivers/watchdog/f71808e_wdt.c
@@ -13,7 +13,7 @@
 #include <asm/io.h>
 #include <driver.h>
 #include <watchdog.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <reset_source.h>
 #include <superio.h>
 #include <common.h>
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index f4b77226d906..50a1bffdd053 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -27,7 +27,7 @@
 #include <linux/mutex.h>
 #include <console.h>
 #include <malloc.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <module.h>
 
 #include "internal.h"
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 958f46b0ead0..0d8bb8f418f4 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -31,7 +31,7 @@
 #include <linux/log2.h>
 #include <linux/spinlock.h>
 #include <malloc.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <stdio.h>
 #include <globalvar.h>
 #include <init.h>
diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h
index 825df2aeddbd..9ddcfbf1c25c 100644
--- a/fs/squashfs/squashfs.h
+++ b/fs/squashfs/squashfs.h
@@ -17,7 +17,7 @@
  * squashfs.h
  */
 
-#include <printk.h>
+#include <linux/printk.h>
 #include <fs.h>
 #include <linux/fs.h>
 #include <linux/kernel.h>
diff --git a/include/common.h b/include/common.h
index 693f5bf97029..083b76cfedc9 100644
--- a/include/common.h
+++ b/include/common.h
@@ -18,7 +18,7 @@
 #include <linux/stddef.h>
 #include <asm/common.h>
 #include <asm/io.h>
-#include <printk.h>
+#include <linux/printk.h>
 
 /*
  * sanity check. The Linux Kernel defines only one of __LITTLE_ENDIAN and
diff --git a/include/linux/barebox-wrapper.h b/include/linux/barebox-wrapper.h
index 82c52dd93309..83fa9223decc 100644
--- a/include/linux/barebox-wrapper.h
+++ b/include/linux/barebox-wrapper.h
@@ -4,6 +4,7 @@
 #include <malloc.h>
 #include <xfuncs.h>
 #include <linux/slab.h>
+#include <printk.h>
 
 #define vmalloc(len)		malloc(len)
 #define __vmalloc(len, mode, pgsz)	malloc(len)
@@ -13,20 +14,6 @@ static inline void vfree(const void *addr)
 	free((void *)addr);
 }
 
-#define KERN_EMERG      ""   /* system is unusable                   */
-#define KERN_ALERT      ""   /* action must be taken immediately     */
-#define KERN_CRIT       ""   /* critical conditions                  */
-#define KERN_ERR        ""   /* error conditions                     */
-#define KERN_WARNING    ""   /* warning conditions                   */
-#define KERN_NOTICE     ""   /* normal but significant condition     */
-#define KERN_INFO       ""   /* informational                        */
-#define KERN_DEBUG      ""   /* debug-level messages                 */
-#define KERN_CONT       ""
-
-#define printk			printf
-
-#define pr_warn			pr_warning
-
 #define __init
 
 #define MODULE_AUTHOR(x)
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index b17e590f5e91..f9c464518021 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -11,7 +11,7 @@
 
 #include <driver.h>
 #include <errno.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/mtd/mtd-abi.h>
diff --git a/include/linux/printk.h b/include/linux/printk.h
new file mode 100644
index 000000000000..3f370adb90ec
--- /dev/null
+++ b/include/linux/printk.h
@@ -0,0 +1,173 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __LINUX_PRINTK_H
+#define __LINUX_PRINTK_H
+
+#include <linux/list.h>
+#include <printk.h>
+
+#define MSG_EMERG      0    /* system is unusable */
+#define MSG_ALERT      1    /* action must be taken immediately */
+#define MSG_CRIT       2    /* critical conditions */
+#define MSG_ERR        3    /* error conditions */
+#define MSG_WARNING    4    /* warning conditions */
+#define MSG_NOTICE     5    /* normal but significant condition */
+#define MSG_INFO       6    /* informational */
+#define MSG_DEBUG      7    /* debug-level messages */
+#define MSG_VDEBUG     8    /* verbose debug messages */
+
+#ifdef VERBOSE_DEBUG
+#define LOGLEVEL	MSG_VDEBUG
+#elif defined DEBUG
+#define LOGLEVEL	MSG_DEBUG
+#else
+#define LOGLEVEL	CONFIG_COMPILE_LOGLEVEL
+#endif
+
+/* debugging and troubleshooting/diagnostic helpers. */
+struct device_d;
+
+#ifndef CONFIG_CONSOLE_NONE
+int dev_printf(int level, const struct device_d *dev, const char *format, ...)
+	__attribute__ ((format(__printf__, 3, 4)));
+#else
+static inline int dev_printf(int level, const struct device_d *dev, const char *format, ...)
+{
+	return 0;
+}
+#endif
+
+#if (!defined(__PBL__) && !defined(CONFIG_CONSOLE_NONE)) || \
+	(defined(__PBL__) && defined(CONFIG_PBL_CONSOLE))
+int pr_print(int level, const char *format, ...)
+	__attribute__ ((format(__printf__, 2, 3)));
+#else
+static int pr_print(int level, const char *format, ...)
+	__attribute__ ((format(__printf__, 2, 3)));
+static inline int pr_print(int level, const char *format, ...)
+{
+	return 0;
+}
+#endif
+
+#define __dev_printf(level, dev, format, args...) \
+	({	\
+		(level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
+	 })
+
+
+#define dev_emerg(dev, format, arg...)		\
+	__dev_printf(0, (dev) , format , ## arg)
+#define dev_alert(dev, format, arg...)		\
+	__dev_printf(1, (dev) , format , ## arg)
+#define dev_crit(dev, format, arg...)		\
+	__dev_printf(2, (dev) , format , ## arg)
+#define dev_err(dev, format, arg...)		\
+	__dev_printf(3, (dev) , format , ## arg)
+#define dev_warn(dev, format, arg...)		\
+	__dev_printf(4, (dev) , format , ## arg)
+#define dev_notice(dev, format, arg...)		\
+	__dev_printf(5, (dev) , format , ## arg)
+#define dev_info(dev, format, arg...)		\
+	__dev_printf(6, (dev) , format , ## arg)
+#define dev_dbg(dev, format, arg...)		\
+	__dev_printf(7, (dev) , format , ## arg)
+#define dev_vdbg(dev, format, arg...)		\
+	__dev_printf(8, (dev) , format , ## arg)
+
+#define __pr_printk(level, format, args...) \
+	({	\
+		(level) <= LOGLEVEL ? pr_print((level), (format), ##args) : 0; \
+	 })
+
+#ifndef pr_fmt
+#define pr_fmt(fmt) fmt
+#endif
+
+#define pr_emerg(fmt, arg...)	__pr_printk(0, pr_fmt(fmt), ##arg)
+#define pr_alert(fmt, arg...)	__pr_printk(1, pr_fmt(fmt), ##arg)
+#define pr_crit(fmt, arg...)	__pr_printk(2, pr_fmt(fmt), ##arg)
+#define pr_err(fmt, arg...)	__pr_printk(3, pr_fmt(fmt), ##arg)
+#define pr_warning(fmt, arg...)	__pr_printk(4, pr_fmt(fmt), ##arg)
+#define pr_notice(fmt, arg...)	__pr_printk(5, pr_fmt(fmt), ##arg)
+#define pr_info(fmt, arg...)	__pr_printk(6, pr_fmt(fmt), ##arg)
+#define pr_debug(fmt, arg...)	__pr_printk(7, pr_fmt(fmt), ##arg)
+#define debug(fmt, arg...)	__pr_printk(7, pr_fmt(fmt), ##arg)
+#define pr_vdebug(fmt, arg...)	__pr_printk(8, pr_fmt(fmt), ##arg)
+#define pr_cont(fmt, arg...)	__pr_printk(-1, fmt, ##arg)
+
+#define pr_warn			pr_warning
+
+int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size,
+		   int swab);
+int __pr_memory_display(int level, const void *addr, loff_t offs, unsigned nbytes,
+			int size, int swab, const char *format, ...);
+
+#define pr_memory_display(level, addr, offs, nbytes, size, swab) \
+	({	\
+		(level) <= LOGLEVEL ? __pr_memory_display((level), (addr), \
+				(offs), (nbytes), (size), (swab), pr_fmt("")) : 0; \
+	 })
+
+struct log_entry {
+	struct list_head list;
+	char *msg;
+	void *dummy;
+	uint64_t timestamp;
+	int level;
+};
+
+extern struct list_head barebox_logbuf;
+
+extern void log_clean(unsigned int limit);
+
+#define BAREBOX_LOG_PRINT_RAW		BIT(2)
+#define BAREBOX_LOG_DIFF_TIME		BIT(1)
+#define BAREBOX_LOG_PRINT_TIME		BIT(0)
+
+#define BAREBOX_LOG_PRINT_VDEBUG	BIT(8)
+#define BAREBOX_LOG_PRINT_DEBUG		BIT(7)
+#define BAREBOX_LOG_PRINT_INFO		BIT(6)
+#define BAREBOX_LOG_PRINT_NOTICE	BIT(5)
+#define BAREBOX_LOG_PRINT_WARNING	BIT(4)
+#define BAREBOX_LOG_PRINT_ERR		BIT(3)
+#define BAREBOX_LOG_PRINT_CRIT		BIT(2)
+#define BAREBOX_LOG_PRINT_ALERT		BIT(1)
+#define BAREBOX_LOG_PRINT_EMERG		BIT(0)
+
+int log_writefile(const char *filepath);
+void log_print(unsigned flags, unsigned levels);
+
+struct va_format {
+	const char *fmt;
+	va_list *va;
+};
+
+#if LOGLEVEL >= MSG_DEBUG
+#define print_hex_dump_debug(prefix_str, prefix_type, rowsize,		\
+			     groupsize, buf, len, ascii)		\
+	print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize,	\
+		       groupsize, buf, len, ascii)
+#else
+static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type,
+                                        int rowsize, int groupsize,
+                                        const void *buf, size_t len, bool ascii)
+{
+}
+#endif
+
+/**
+ * print_hex_dump_bytes - shorthand form of print_hex_dump() with default params
+ * @prefix_str: string to prefix each line with;
+ *  caller supplies trailing spaces for alignment if desired
+ * @prefix_type: controls whether prefix of an offset, address, or none
+ *  is printed (%DUMP_PREFIX_OFFSET, %DUMP_PREFIX_ADDRESS, %DUMP_PREFIX_NONE)
+ * @buf: data blob to dump
+ * @len: number of bytes in the @buf
+ *
+ * Calls print_hex_dump(), with log level of KERN_DEBUG,
+ * rowsize of 16, groupsize of 1, and ASCII output included.
+ */
+#define print_hex_dump_bytes(prefix_str, prefix_type, buf, len)	\
+	print_hex_dump_debug(prefix_str, prefix_type, 16, 1, buf, len, true)
+
+#endif
diff --git a/include/printk.h b/include/printk.h
index f83ad3bf07f0..0915efbadd51 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -2,97 +2,28 @@
 #ifndef __PRINTK_H
 #define __PRINTK_H
 
-#include <linux/list.h>
-
-#define MSG_EMERG      0    /* system is unusable */
-#define MSG_ALERT      1    /* action must be taken immediately */
-#define MSG_CRIT       2    /* critical conditions */
-#define MSG_ERR        3    /* error conditions */
-#define MSG_WARNING    4    /* warning conditions */
-#define MSG_NOTICE     5    /* normal but significant condition */
-#define MSG_INFO       6    /* informational */
-#define MSG_DEBUG      7    /* debug-level messages */
-#define MSG_VDEBUG     8    /* verbose debug messages */
-
-#ifdef VERBOSE_DEBUG
-#define LOGLEVEL	MSG_VDEBUG
-#elif defined DEBUG
-#define LOGLEVEL	MSG_DEBUG
-#else
-#define LOGLEVEL	CONFIG_COMPILE_LOGLEVEL
-#endif
-
-/* debugging and troubleshooting/diagnostic helpers. */
-struct device_d;
-
-#ifndef CONFIG_CONSOLE_NONE
-int dev_printf(int level, const struct device_d *dev, const char *format, ...)
-	__attribute__ ((format(__printf__, 3, 4)));
-#else
-static inline int dev_printf(int level, const struct device_d *dev, const char *format, ...)
-{
-	return 0;
-}
-#endif
+#define KERN_EMERG      ""   /* system is unusable                   */
+#define KERN_ALERT      ""   /* action must be taken immediately     */
+#define KERN_CRIT       ""   /* critical conditions                  */
+#define KERN_ERR        ""   /* error conditions                     */
+#define KERN_WARNING    ""   /* warning conditions                   */
+#define KERN_NOTICE     ""   /* normal but significant condition     */
+#define KERN_INFO       ""   /* informational                        */
+#define KERN_DEBUG      ""   /* debug-level messages                 */
+#define KERN_CONT       ""
 
 #if (!defined(__PBL__) && !defined(CONFIG_CONSOLE_NONE)) || \
 	(defined(__PBL__) && defined(CONFIG_PBL_CONSOLE))
-int pr_print(int level, const char *format, ...)
-	__attribute__ ((format(__printf__, 2, 3)));
+int printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
 #else
-static int pr_print(int level, const char *format, ...)
-	__attribute__ ((format(__printf__, 2, 3)));
-static inline int pr_print(int level, const char *format, ...)
+static int printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
+static inline int printf(const char *fmt, ...)
 {
 	return 0;
 }
 #endif
 
-#define __dev_printf(level, dev, format, args...) \
-	({	\
-		(level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
-	 })
-
-
-#define dev_emerg(dev, format, arg...)		\
-	__dev_printf(0, (dev) , format , ## arg)
-#define dev_alert(dev, format, arg...)		\
-	__dev_printf(1, (dev) , format , ## arg)
-#define dev_crit(dev, format, arg...)		\
-	__dev_printf(2, (dev) , format , ## arg)
-#define dev_err(dev, format, arg...)		\
-	__dev_printf(3, (dev) , format , ## arg)
-#define dev_warn(dev, format, arg...)		\
-	__dev_printf(4, (dev) , format , ## arg)
-#define dev_notice(dev, format, arg...)		\
-	__dev_printf(5, (dev) , format , ## arg)
-#define dev_info(dev, format, arg...)		\
-	__dev_printf(6, (dev) , format , ## arg)
-#define dev_dbg(dev, format, arg...)		\
-	__dev_printf(7, (dev) , format , ## arg)
-#define dev_vdbg(dev, format, arg...)		\
-	__dev_printf(8, (dev) , format , ## arg)
-
-#define __pr_printk(level, format, args...) \
-	({	\
-		(level) <= LOGLEVEL ? pr_print((level), (format), ##args) : 0; \
-	 })
-
-#ifndef pr_fmt
-#define pr_fmt(fmt) fmt
-#endif
-
-#define pr_emerg(fmt, arg...)	__pr_printk(0, pr_fmt(fmt), ##arg)
-#define pr_alert(fmt, arg...)	__pr_printk(1, pr_fmt(fmt), ##arg)
-#define pr_crit(fmt, arg...)	__pr_printk(2, pr_fmt(fmt), ##arg)
-#define pr_err(fmt, arg...)	__pr_printk(3, pr_fmt(fmt), ##arg)
-#define pr_warning(fmt, arg...)	__pr_printk(4, pr_fmt(fmt), ##arg)
-#define pr_notice(fmt, arg...)	__pr_printk(5, pr_fmt(fmt), ##arg)
-#define pr_info(fmt, arg...)	__pr_printk(6, pr_fmt(fmt), ##arg)
-#define pr_debug(fmt, arg...)	__pr_printk(7, pr_fmt(fmt), ##arg)
-#define debug(fmt, arg...)	__pr_printk(7, pr_fmt(fmt), ##arg)
-#define pr_vdebug(fmt, arg...)	__pr_printk(8, pr_fmt(fmt), ##arg)
-#define pr_cont(fmt, arg...)	__pr_printk(-1, fmt, ##arg)
+#define printk			printf
 
 #define printk_once(fmt, ...)					\
 ({								\
@@ -104,51 +35,6 @@ static inline int pr_print(int level, const char *format, ...)
 	}							\
 })
 
-int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size,
-		   int swab);
-int __pr_memory_display(int level, const void *addr, loff_t offs, unsigned nbytes,
-			int size, int swab, const char *format, ...);
-
-#define pr_memory_display(level, addr, offs, nbytes, size, swab) \
-	({	\
-		(level) <= LOGLEVEL ? __pr_memory_display((level), (addr), \
-				(offs), (nbytes), (size), (swab), pr_fmt("")) : 0; \
-	 })
-
-struct log_entry {
-	struct list_head list;
-	char *msg;
-	void *dummy;
-	uint64_t timestamp;
-	int level;
-};
-
-extern struct list_head barebox_logbuf;
-
-extern void log_clean(unsigned int limit);
-
-#define BAREBOX_LOG_PRINT_RAW		BIT(2)
-#define BAREBOX_LOG_DIFF_TIME		BIT(1)
-#define BAREBOX_LOG_PRINT_TIME		BIT(0)
-
-#define BAREBOX_LOG_PRINT_VDEBUG	BIT(8)
-#define BAREBOX_LOG_PRINT_DEBUG		BIT(7)
-#define BAREBOX_LOG_PRINT_INFO		BIT(6)
-#define BAREBOX_LOG_PRINT_NOTICE	BIT(5)
-#define BAREBOX_LOG_PRINT_WARNING	BIT(4)
-#define BAREBOX_LOG_PRINT_ERR		BIT(3)
-#define BAREBOX_LOG_PRINT_CRIT		BIT(2)
-#define BAREBOX_LOG_PRINT_ALERT		BIT(1)
-#define BAREBOX_LOG_PRINT_EMERG		BIT(0)
-
-int log_writefile(const char *filepath);
-void log_print(unsigned flags, unsigned levels);
-
-struct va_format {
-	const char *fmt;
-	va_list *va;
-};
-
 enum {
 	DUMP_PREFIX_NONE,
 	DUMP_PREFIX_ADDRESS,
@@ -161,32 +47,4 @@ extern void print_hex_dump(const char *level, const char *prefix_str,
 			   int prefix_type, int rowsize, int groupsize,
 			   const void *buf, size_t len, bool ascii);
 
-#if LOGLEVEL >= MSG_DEBUG
-#define print_hex_dump_debug(prefix_str, prefix_type, rowsize,		\
-			     groupsize, buf, len, ascii)		\
-	print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize,	\
-		       groupsize, buf, len, ascii)
-#else
-static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type,
-                                        int rowsize, int groupsize,
-                                        const void *buf, size_t len, bool ascii)
-{
-}
-#endif
-
-/**
- * print_hex_dump_bytes - shorthand form of print_hex_dump() with default params
- * @prefix_str: string to prefix each line with;
- *  caller supplies trailing spaces for alignment if desired
- * @prefix_type: controls whether prefix of an offset, address, or none
- *  is printed (%DUMP_PREFIX_OFFSET, %DUMP_PREFIX_ADDRESS, %DUMP_PREFIX_NONE)
- * @buf: data blob to dump
- * @len: number of bytes in the @buf
- *
- * Calls print_hex_dump(), with log level of KERN_DEBUG,
- * rowsize of 16, groupsize of 1, and ASCII output included.
- */
-#define print_hex_dump_bytes(prefix_str, prefix_type, buf, len)	\
-	print_hex_dump_debug(prefix_str, prefix_type, 16, 1, buf, len, true)
-
 #endif
diff --git a/include/stdio.h b/include/stdio.h
index 1cb11e88deea..49f3d0cf77b3 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -4,6 +4,7 @@
 
 #include <stdarg.h>
 #include <console.h>
+#include <printk.h>
 
 /*
  * STDIO based functions (can always be used)
@@ -71,8 +72,6 @@ static inline int ctrlc (void)
 
 #if (!defined(__PBL__) && !defined(CONFIG_CONSOLE_NONE)) || \
 	(defined(__PBL__) && defined(CONFIG_PBL_CONSOLE))
-int printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
-
 static inline int puts(const char *s)
 {
 	return console_puts(CONSOLE_STDOUT, s);
@@ -83,11 +82,6 @@ static inline void putchar(char c)
 	console_putc(CONSOLE_STDOUT, c);
 }
 #else
-static int printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
-static inline int printf(const char *fmt, ...)
-{
-	return 0;
-}
 static inline int puts(const char *s)
 {
 	return 0;
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 93f345e8817c..fb80ef9724d8 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -7,7 +7,7 @@
 #include <linux/types.h>
 #include <linux/ctype.h>
 #include <linux/log2.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <asm/unaligned.h>
 
 const char hex_asc[] = "0123456789abcdef";
diff --git a/lib/kasan/report.c b/lib/kasan/report.c
index b7b2d032eee0..79442c00f4cb 100644
--- a/lib/kasan/report.c
+++ b/lib/kasan/report.c
@@ -17,7 +17,7 @@
 #include <common.h>
 #include <linux/bitops.h>
 #include <linux/kernel.h>
-#include <printk.h>
+#include <linux/printk.h>
 #include <asm-generic/sections.h>
 
 #include "kasan.h"
diff --git a/pbl/fdt.c b/pbl/fdt.c
index 18ddb9f48a6e..7a913c546af6 100644
--- a/pbl/fdt.c
+++ b/pbl/fdt.c
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/libfdt.h>
 #include <pbl.h>
-#include <printk.h>
+#include <linux/printk.h>
 
 void fdt_find_mem(const void *fdt, unsigned long *membase, unsigned long *memsize)
 {
-- 
2.30.2


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


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

* [PATCH 4/5] include: <asm-generic/bug.h>: make self-contained
  2021-10-30 14:17 [PATCH 1/5] include: <linux/bitops.h>: discard left-over hweight code Ahmad Fatoum
  2021-10-30 14:17 ` [PATCH 2/5] scripts: <linux/bitops.h>: fix references to undefined __BITS_PER_LONG Ahmad Fatoum
  2021-10-30 14:17 ` [PATCH 3/5] include: add dedicated header for printf/printk Ahmad Fatoum
@ 2021-10-30 14:17 ` 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
  4 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2021-10-30 14:17 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

<asm-generic/bug.h> so far depended on a preceding <common.h> to get the
dump_stack() definition. Move dump_stack() to the new printk.h and drop
the remaining puts() use to make header self-contained.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/asm-generic/bug.h |  5 +++--
 include/common.h          |  9 ---------
 include/printk.h          | 10 ++++++++++
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 82b78261fc5d..6aa3eada0ec5 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -2,6 +2,8 @@
 #define _ASM_GENERIC_BUG_H
 
 #include <linux/compiler.h>
+#include <linux/kernel.h>
+#include <printk.h>
 
 #define BUG() do { \
 	printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
@@ -28,8 +30,7 @@
 	int __ret_warn_on = !!(condition);				\
 	if (unlikely(__ret_warn_on)) {					\
 		__WARN();						\
-		puts("WARNING: ");					\
-		printf(format);						\
+		printf("WARNING: " format);				\
 	}								\
 	unlikely(__ret_warn_on);					\
 })
diff --git a/include/common.h b/include/common.h
index 083b76cfedc9..e37630243e73 100644
--- a/include/common.h
+++ b/include/common.h
@@ -62,15 +62,6 @@ void ctrlc_handled(void);
 static inline void ctrlc_handled(void) { }
 #endif
 
-#ifdef CONFIG_ARCH_HAS_STACK_DUMP
-void dump_stack(void);
-#else
-static inline void dump_stack(void)
-{
-	printf("no stack data available\n");
-}
-#endif
-
 int parse_area_spec(const char *str, loff_t *start, loff_t *size);
 
 /* Just like simple_strtoul(), but this one honors a K/M/G suffix */
diff --git a/include/printk.h b/include/printk.h
index 0915efbadd51..baf2cca20213 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -47,4 +47,14 @@ extern void print_hex_dump(const char *level, const char *prefix_str,
 			   int prefix_type, int rowsize, int groupsize,
 			   const void *buf, size_t len, bool ascii);
 
+#ifdef CONFIG_ARCH_HAS_STACK_DUMP
+void dump_stack(void);
+#else
+static inline void dump_stack(void)
+{
+	printf("no stack data available\n");
+}
+#endif
+
+
 #endif
-- 
2.30.2


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


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

* [PATCH 5/5] include: move ARRAY_AND_SIZE to <linux/kernel.h>
  2021-10-30 14:17 [PATCH 1/5] include: <linux/bitops.h>: discard left-over hweight code Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2021-10-30 14:17 ` [PATCH 4/5] include: <asm-generic/bug.h>: make self-contained Ahmad Fatoum
@ 2021-10-30 14:17 ` Ahmad Fatoum
  2021-11-01  9:08 ` [PATCH 1/5] include: <linux/bitops.h>: discard left-over hweight code Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2021-10-30 14:17 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Linux defines this macro at multiple places. We define it once, but in
<common.h>, which is a bit heavy weight. Move it next to the
ARRAY_SIZE() definition.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/common.h               | 2 --
 include/linux/kernel.h         | 1 +
 scripts/include/linux/kernel.h | 1 +
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/common.h b/include/common.h
index e37630243e73..4167d4676e50 100644
--- a/include/common.h
+++ b/include/common.h
@@ -88,8 +88,6 @@ enum autoboot_state do_autoboot_countdown(void);
 void __noreturn start_barebox(void);
 void shutdown_barebox(void);
 
-#define ARRAY_AND_SIZE(x)	(x), ARRAY_SIZE(x)
-
 /*
  * The STACK_ALIGN_ARRAY macro is used to allocate a buffer on the stack that
  * meets a minimum alignment requirement.
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 9ccdd60224dd..4483d33e65bb 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -15,6 +15,7 @@
 #define IS_ALIGNED(x, a)		(((x) & ((typeof(x))(a) - 1)) == 0)
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
+#define ARRAY_AND_SIZE(x)	(x), ARRAY_SIZE(x)
 
 /*
  * This looks more complex than it should be. But we need to
diff --git a/scripts/include/linux/kernel.h b/scripts/include/linux/kernel.h
index dc2e64e16413..f3083ff3545d 100644
--- a/scripts/include/linux/kernel.h
+++ b/scripts/include/linux/kernel.h
@@ -9,6 +9,7 @@
 #define __ALIGN_MASK(x, mask)	(((x) + (mask)) & ~(mask))
 #define ALIGN(x, a)		__ALIGN_MASK(x, (typeof(x))(a) - 1)
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#define ARRAY_AND_SIZE(x)	(x), ARRAY_SIZE(x)
 
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
 
-- 
2.30.2


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


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

* Re: [PATCH 1/5] include: <linux/bitops.h>: discard left-over hweight code
  2021-10-30 14:17 [PATCH 1/5] include: <linux/bitops.h>: discard left-over hweight code Ahmad Fatoum
                   ` (3 preceding siblings ...)
  2021-10-30 14:17 ` [PATCH 5/5] include: move ARRAY_AND_SIZE to <linux/kernel.h> Ahmad Fatoum
@ 2021-11-01  9:08 ` Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2021-11-01  9:08 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Sat, Oct 30, 2021 at 04:17:35PM +0200, Ahmad Fatoum wrote:
> There are no definitions for __sw_hweight*, so no point in keeping the
> prototypes around. The scripts version of the header also ultimately
> tries to access non-existing normal headers, so fix that up as well.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  include/linux/bitops.h                             | 5 -----
>  scripts/include/asm-generic/bitops/arch_hweight.h  | 1 -
>  scripts/include/asm-generic/bitops/const_hweight.h | 1 -
>  scripts/include/asm-generic/bitops/hweight.h       | 3 +--
>  scripts/include/linux/bitops.h                     | 4 ----
>  5 files changed, 1 insertion(+), 13 deletions(-)
>  delete mode 100644 scripts/include/asm-generic/bitops/arch_hweight.h
>  delete mode 100644 scripts/include/asm-generic/bitops/const_hweight.h

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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


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

end of thread, other threads:[~2021-11-01  9:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-30 14:17 [PATCH 1/5] include: <linux/bitops.h>: discard left-over hweight code Ahmad Fatoum
2021-10-30 14:17 ` [PATCH 2/5] scripts: <linux/bitops.h>: fix references to undefined __BITS_PER_LONG Ahmad Fatoum
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

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git