include: <linux/bitops.h>: discard left-over hweight code
Subsystems (19)
PATCH 1/5 include: <linux/bitops.h>: discard left-over hweight code
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.
--- 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
include/linux/bitops.h +0 -5
@@ -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
scripts/include/asm-generic/bitops/arch_hweight.h deleted +0 -1
@@ -1 +0,0 @@ -#include "../../../../include/asm-generic/bitops/arch_hweight.h"
scripts/include/asm-generic/bitops/const_hweight.h deleted +0 -1
@@ -1 +0,0 @@ -#include "../../../../include/asm-generic/bitops/const_hweight.h"
scripts/include/asm-generic/bitops/hweight.h +1 -2
@@ -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_ */
scripts/include/linux/bitops.h +0 -4
@@ -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
Signature · 7 lines
2.30.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/5 scripts: <linux/bitops.h>: fix references to undefined __BITS_PER_LONG
No where do we define __BITS_PER_LONG, but we know about BITS_PER_LONG. Fix it.
--- 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
scripts/include/asm-generic/bitops/__ffs.h +2 -1
@@ -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 ;
scripts/include/asm-generic/bitops/atomic.h +5 -4
@@ -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_ */
scripts/include/asm-generic/bitsperlong.h new file +12 -0
@@ -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
scripts/include/linux/bitops.h +1 -6
@@ -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)
Signature · 7 lines
2.30.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/5 include: add dedicated header for printf/printk
In reply to Ahmad FatoumIncluding <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>.
--- 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
arch/arm/boards/netgear-rn2120/board.c +1 -1
@@ -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>
arch/arm/mach-mvebu/kwb_bbu.c +1 -1
@@ -1,6 +1,6 @@#include <bbu.h> #include <libfile.h> -#include <printk.h> +#include <linux/printk.h> #include <mach/bbu.h>
common/bootchooser.c +1 -1
@@ -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>
common/optee.c +1 -1
@@ -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)
common/state/backend_bucket_direct.c +1 -1
@@ -17,7 +17,7 @@#include <libfile.h> #include <linux/kernel.h> #include <malloc.h> -#include <printk.h> +#include <linux/printk.h> #include "state.h"
common/state/backend_storage.c +1 -1
@@ -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"
common/state/state_variables.c +1 -1
@@ -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>
drivers/clk/analogbits/wrpll-cln28hpc.c +1 -1
@@ -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>
drivers/clk/at91/pmc.h +1 -1
@@ -10,7 +10,7 @@#include <io.h> #include <linux/bitops.h> -#include <printk.h> +#include <linux/printk.h> struct pmc_data {unsigned int ncore;
drivers/clk/sifive/sifive-prci.c +1 -1
@@ -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>
drivers/gpio/gpio-sifive.c +1 -1
@@ -4,7 +4,7 @@*/ #include <linux/basic_mmio_gpio.h> -#include <printk.h> +#include <linux/printk.h> #include <driver.h> #include <errno.h>
drivers/gpio/gpio-starfive-vic.c +1 -1
@@ -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>
drivers/pwm/pwm-atmel.c +1 -1
@@ -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>
drivers/soc/sifive/sifive_l2_cache.c +1 -1
@@ -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>
drivers/watchdog/f71808e_wdt.c +1 -1
@@ -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>
fs/pstore/platform.c +1 -1
@@ -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"
fs/pstore/ram.c +1 -1
@@ -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>
fs/squashfs/squashfs.h +1 -1
@@ -17,7 +17,7 @@* squashfs.h */ -#include <printk.h> +#include <linux/printk.h> #include <fs.h> #include <linux/fs.h> #include <linux/kernel.h>
include/common.h +1 -1
@@ -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
include/linux/barebox-wrapper.h +1 -14
@@ -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)
include/linux/mtd/mtd.h +1 -1
@@ -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>
include/linux/printk.h new file +173 -0
173 lines not on this page · raw message
include/printk.h +13 -155
193 lines not on this page · raw message
include/stdio.h +1 -7
@@ -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 ;
lib/hexdump.c +1 -1
@@ -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" ;
lib/kasan/report.c +1 -1
@@ -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"
pbl/fdt.c +1 -1
@@ -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) {
Signature · 7 lines
2.30.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/5 include: <asm-generic/bug.h>: make self-contained
In reply to 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.
--- include/asm-generic/bug.h | 5 +++-- include/common.h | 9 --------- include/printk.h | 10 ++++++++++ 3 files changed, 13 insertions(+), 11 deletions(-)
include/asm-generic/bug.h +3 -2
@@ -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); \ })
include/common.h +0 -9
@@ -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 */
include/printk.h +10 -0
@@ -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
Signature · 7 lines
2.30.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 5/5 include: move ARRAY_AND_SIZE to <linux/kernel.h>
In reply to Ahmad FatoumLinux 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.
--- include/common.h | 2 -- include/linux/kernel.h | 1 + scripts/include/linux/kernel.h | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)
include/common.h +0 -2
@@ -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.
include/linux/kernel.h +1 -0
@@ -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
scripts/include/linux/kernel.h +1 -0
@@ -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))
Signature · 7 lines
2.30.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 5 lines · 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 <[email protected]>
Quoted 9 lines
--- 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
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox