zap: Do not use macros that are equivalent to IS_ENABLED(CONFIG_...)
Subsystems (2)
cover zap: Do not use macros that are equivalent to IS_ENABLED(CONFIG_...)
Please stop such coding habit as follows:
#ifdef CONFIG_FOO # define ENABLE_FOO 1 #else # define ENABLE_FOO 0 #endif
Use IS_ENABLED(CONFIG_FOO), instead.
Masahiro Yamada (11):
image: zap IMAGE_ENABLE_RAMDISK_HIGH
image: zap IMAGE_ENABLE_OF_LIBFDT
image: zap IMAGE_BOOT_GET_CMDLINE
image: zap IMAGE_OF_BOARD_SETUP
image: zap IMAGE_OF_SYSTEM_SETUP
ARM: bootm: BOOTM_ENABLE_SERIAL_TAG
ARM: bootm: BOOTM_ENABLE_CMDLINE_TAG
ARM: bootm: BOOTM_ENABLE_REVISION_TAG
ARM: bootm: BOOTM_ENABLE_MEMORY_TAG
ARM: bootm: BOOTM_ENABLE_INITRD_TAG
ARM: bootm: drop redundant #ifdef conditional
arch/arc/lib/bootm.c | 2 +- arch/arm/include/asm/bootm.h | 22 ---------------------- arch/arm/lib/bootm.c | 16 +++++++--------- common/image-fdt.c | 6 +++--- common/image.c | 10 +++++----- include/image.h | 30 ------------------------------ 6 files changed, 16 insertions(+), 70 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/11 image: zap IMAGE_ENABLE_RAMDISK_HIGH
Do not use a macro that just ends up in unreadable code.
---
common/image.c | 2 +- include/image.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)
common/image.c +1 -1
@@ -1354,7 +1354,7 @@ int image_setup_linux(bootm_headers_t *images)return ret; } } -if (IMAGE_ENABLE_RAMDISK_HIGH ) { +if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) { rd_len = images->rd_end - images->rd_start; ret =boot_ramdisk_high (lmb, images->rd_start, rd_len, initrd_start, initrd_end);
include/image.h +0 -6
@@ -96,12 +96,6 @@ struct lmb;#endif /* CONFIG_FIT */ -#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH -# define IMAGE_ENABLE_RAMDISK_HIGH 1 -#else -# define IMAGE_ENABLE_RAMDISK_HIGH 0 -#endif -#ifdef CONFIG_OF_LIBFDT # define IMAGE_ENABLE_OF_LIBFDT 1#else
Signature · 1 line
1.9.1
PATCH 2/11 image: zap IMAGE_ENABLE_OF_LIBFDT
In reply to Masahiro YamadaDo not use a macro that just ends up in unreadable code.
---
arch/arc/lib/bootm.c | 2 +- arch/arm/lib/bootm.c | 4 ++-- common/image.c | 6 +++--- include/image.h | 6 ------ 4 files changed, 6 insertions(+), 12 deletions(-)
arch/arc/lib/bootm.c +1 -1
@@ -75,7 +75,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)cleanup_before_linux (); -if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) { +if (IS_ENABLED (CONFIG_OF_LIBFDT ) && images->ft_len) { r0 =2 ; r2 = (unsigned int )images->ft_addr; }else {
arch/arm/lib/bootm.c +2 -2
@@ -205,7 +205,7 @@ static void boot_prep_linux(bootm_headers_t *images) {char *commandline =getenv ("bootargs" ); -if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) { +if (IS_ENABLED (CONFIG_OF_LIBFDT ) && images->ft_len) {#ifdef CONFIG_OF_LIBFDT debug ("using: FDT\n" );if (image_setup_linux (images)) {
@@ -302,7 +302,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)bootstage_mark (BOOTSTAGE_ID_RUN_OS );announce_and_cleanup (fake); -if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) +if (IS_ENABLED (CONFIG_OF_LIBFDT ) && images->ft_len) r2 = (unsigned long )images->ft_addr;else r2 = gd->bd->bi_boot_params;
common/image.c +3 -3
@@ -1343,7 +1343,7 @@ int image_setup_linux(bootm_headers_t *images)ulong rd_len;int ret; -if (IMAGE_ENABLE_OF_LIBFDT ) +if (IS_ENABLED (CONFIG_OF_LIBFDT ))boot_fdt_add_mem_rsv_regions (lmb, *of_flat_tree);if (IMAGE_BOOT_GET_CMDLINE ) {
@@ -1362,13 +1362,13 @@ int image_setup_linux(bootm_headers_t *images)return ret; } -if (IMAGE_ENABLE_OF_LIBFDT ) { +if (IS_ENABLED (CONFIG_OF_LIBFDT )) { ret =boot_relocate_fdt (lmb, of_flat_tree, &of_size);if (ret)return ret; } -if (IMAGE_ENABLE_OF_LIBFDT && of_size) { +if (IS_ENABLED (CONFIG_OF_LIBFDT ) && of_size) { ret =image_setup_libfdt (images, *of_flat_tree, of_size, lmb);if (ret)return ret;
include/image.h +0 -6
@@ -96,12 +96,6 @@ struct lmb;#endif /* CONFIG_FIT */ -#ifdef CONFIG_OF_LIBFDT -# define IMAGE_ENABLE_OF_LIBFDT 1 -#else -# define IMAGE_ENABLE_OF_LIBFDT 0 -#endif -#ifdef CONFIG_SYS_BOOT_GET_CMDLINE # define IMAGE_BOOT_GET_CMDLINE 1#else
Signature · 1 line
1.9.1
PATCH 3/11 image: zap IMAGE_BOOT_GET_CMDLINE
In reply to Masahiro YamadaDo not use a macro that just ends up in unreadable code.
---
common/image.c | 2 +- include/image.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)
common/image.c +1 -1
@@ -1346,7 +1346,7 @@ int image_setup_linux(bootm_headers_t *images)if (IS_ENABLED (CONFIG_OF_LIBFDT ))boot_fdt_add_mem_rsv_regions (lmb, *of_flat_tree); -if (IMAGE_BOOT_GET_CMDLINE ) { +if (IS_ENABLED (CONFIG_SYS_BOOT_GET_CMDLINE )) { ret =boot_get_cmdline (lmb, &images->cmdline_start, &images->cmdline_end);if (ret) {
include/image.h +0 -6
@@ -96,12 +96,6 @@ struct lmb;#endif /* CONFIG_FIT */ -#ifdef CONFIG_SYS_BOOT_GET_CMDLINE -# define IMAGE_BOOT_GET_CMDLINE 1 -#else -# define IMAGE_BOOT_GET_CMDLINE 0 -#endif -#ifdef CONFIG_OF_BOARD_SETUP # define IMAGE_OF_BOARD_SETUP 1#else
Signature · 1 line
1.9.1
PATCH 4/11 image: zap IMAGE_OF_BOARD_SETUP
In reply to Masahiro YamadaDo not use a macro that just ends up in unreadable code.
---
common/image-fdt.c | 4 ++-- include/image.h | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-)
common/image-fdt.c +2 -2
@@ -483,7 +483,7 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,printf ("ERROR: arch-specific fdt fixup failed\n" ); goto err; } -if (IMAGE_OF_BOARD_SETUP ) { +if (IS_ENABLED (CONFIG_OF_BOARD_SETUP )) { fdt_ret =ft_board_setup (blob, gd->bd);if (fdt_ret) { printf("ERROR: board-specific fdt fixup failed: %s\n",
@@ -522,7 +522,7 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob, goto err;#if defined(CONFIG_SOC_KEYSTONE ) -if (IMAGE_OF_BOARD_SETUP ) +if (IS_ENABLED (CONFIG_OF_BOARD_SETUP ))ft_board_setup_ex (blob, gd->bd);#endif
include/image.h +0 -6
@@ -96,12 +96,6 @@ struct lmb;#endif /* CONFIG_FIT */ -#ifdef CONFIG_OF_BOARD_SETUP -# define IMAGE_OF_BOARD_SETUP 1 -#else -# define IMAGE_OF_BOARD_SETUP 0 -#endif -#ifdef CONFIG_OF_SYSTEM_SETUP # define IMAGE_OF_SYSTEM_SETUP 1#else
Signature · 1 line
1.9.1
PATCH 5/11 image: zap IMAGE_OF_SYSTEM_SETUP
In reply to Masahiro YamadaDo not use a macro that just ends up in unreadable code.
---
common/image-fdt.c | 2 +- include/image.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)
common/image-fdt.c +1 -1
@@ -491,7 +491,7 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob, goto err; } } -if (IMAGE_OF_SYSTEM_SETUP ) { +if (IS_ENABLED (CONFIG_OF_SYSTEM_SETUP )) { fdt_ret =ft_system_setup (blob, gd->bd);if (fdt_ret) { printf("ERROR: system-specific fdt fixup failed: %s\n",
include/image.h +0 -6
@@ -96,12 +96,6 @@ struct lmb;#endif /* CONFIG_FIT */ -#ifdef CONFIG_OF_SYSTEM_SETUP -# define IMAGE_OF_SYSTEM_SETUP 1 -#else -# define IMAGE_OF_SYSTEM_SETUP 0 -#endif -/* * Operating System Codes */
Signature · 1 line
1.9.1
PATCH 6/11 ARM: bootm: BOOTM_ENABLE_SERIAL_TAG
In reply to Masahiro YamadaDo not use a macro that just ends up in unreadable code.
---
arch/arm/include/asm/bootm.h | 2 -- arch/arm/lib/bootm.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-)
arch/arm/include/asm/bootm.h +0 -2
@@ -42,10 +42,8 @@ extern void udc_disconnect(void);#endif #ifdef CONFIG_SERIAL_TAG -#define BOOTM_ENABLE_SERIAL_TAG 1void get_board_serial (struct tag_serialnr *serialnr);#else -#define BOOTM_ENABLE_SERIAL_TAG 0static inline void get_board_serial (struct tag_serialnr *serialnr) { }
arch/arm/lib/bootm.c +1 -1
@@ -216,7 +216,7 @@ static void boot_prep_linux(bootm_headers_t *images) }else if (BOOTM_ENABLE_TAGS ) {debug ("using: ATAGS\n" );setup_start_tag (gd->bd); -if (BOOTM_ENABLE_SERIAL_TAG ) +if (IS_ENABLED (CONFIG_SERIAL_TAG ))setup_serial_tag (¶ms);if (BOOTM_ENABLE_CMDLINE_TAG )setup_commandline_tag (gd->bd, commandline);
Signature · 1 line
1.9.1
PATCH 7/11 ARM: bootm: BOOTM_ENABLE_CMDLINE_TAG
In reply to Masahiro YamadaDo not use a macro that just ends up in unreadable code.
---
arch/arm/include/asm/bootm.h | 6 ------ arch/arm/lib/bootm.c | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-)
arch/arm/include/asm/bootm.h +0 -6
@@ -29,12 +29,6 @@ extern void udc_disconnect(void);# define BOOTM_ENABLE_MEMORY_TAGS 0#endif -#ifdef CONFIG_CMDLINE_TAG -#define BOOTM_ENABLE_CMDLINE_TAG 1 -#else -#define BOOTM_ENABLE_CMDLINE_TAG 0 -#endif -#ifdef CONFIG_INITRD_TAG #define BOOTM_ENABLE_INITRD_TAG 1#else
arch/arm/lib/bootm.c +1 -1
@@ -218,7 +218,7 @@ static void boot_prep_linux(bootm_headers_t *images)setup_start_tag (gd->bd);if (IS_ENABLED (CONFIG_SERIAL_TAG ))setup_serial_tag (¶ms); -if (BOOTM_ENABLE_CMDLINE_TAG ) +if (IS_ENABLED (CONFIG_CMDLINE_TAG ))setup_commandline_tag (gd->bd, commandline);if (BOOTM_ENABLE_REVISION_TAG )setup_revision_tag (¶ms);
Signature · 1 line
1.9.1
PATCH 8/11 ARM: bootm: BOOTM_ENABLE_REVISION_TAG
In reply to Masahiro YamadaDo not use a macro that just ends up in unreadable code.
---
arch/arm/include/asm/bootm.h | 2 -- arch/arm/lib/bootm.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-)
arch/arm/include/asm/bootm.h +0 -2
@@ -44,10 +44,8 @@ static inline void get_board_serial(struct tag_serialnr *serialnr)#endif #ifdef CONFIG_REVISION_TAG -#define BOOTM_ENABLE_REVISION_TAG 1u32 get_board_rev (void );#else -#define BOOTM_ENABLE_REVISION_TAG 0static inline u32 get_board_rev (void ) {return 0 ;
arch/arm/lib/bootm.c +1 -1
@@ -220,7 +220,7 @@ static void boot_prep_linux(bootm_headers_t *images)setup_serial_tag (¶ms);if (IS_ENABLED (CONFIG_CMDLINE_TAG ))setup_commandline_tag (gd->bd, commandline); -if (BOOTM_ENABLE_REVISION_TAG ) +if (IS_ENABLED (CONFIG_REVISION_TAG ))setup_revision_tag (¶ms);if (BOOTM_ENABLE_MEMORY_TAGS )setup_memory_tags (gd->bd);
Signature · 1 line
1.9.1
PATCH 9/11 ARM: bootm: BOOTM_ENABLE_MEMORY_TAG
In reply to Masahiro YamadaDo not use a macro that just ends up in unreadable code.
---
arch/arm/include/asm/bootm.h | 6 ------ arch/arm/lib/bootm.c | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-)
arch/arm/include/asm/bootm.h +0 -6
@@ -23,12 +23,6 @@ extern void udc_disconnect(void);# define BOOTM_ENABLE_TAGS 0#endif -#ifdef CONFIG_SETUP_MEMORY_TAGS -# define BOOTM_ENABLE_MEMORY_TAGS 1 -#else -# define BOOTM_ENABLE_MEMORY_TAGS 0 -#endif -#ifdef CONFIG_INITRD_TAG #define BOOTM_ENABLE_INITRD_TAG 1#else
arch/arm/lib/bootm.c +1 -1
@@ -222,7 +222,7 @@ static void boot_prep_linux(bootm_headers_t *images)setup_commandline_tag (gd->bd, commandline);if (IS_ENABLED (CONFIG_REVISION_TAG ))setup_revision_tag (¶ms); -if (BOOTM_ENABLE_MEMORY_TAGS ) +if (IS_ENABLED (CONFIG_SETUP_MEMORY_TAGS ))setup_memory_tags (gd->bd);if (BOOTM_ENABLE_INITRD_TAG ) {if (images->rd_start && images->rd_end) {
Signature · 1 line
1.9.1
PATCH 10/11 ARM: bootm: BOOTM_ENABLE_INITRD_TAG
In reply to Masahiro YamadaDo not use a macro that just ends up in unreadable code.
---
arch/arm/include/asm/bootm.h | 6 ------ arch/arm/lib/bootm.c | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-)
arch/arm/include/asm/bootm.h +0 -6
@@ -23,12 +23,6 @@ extern void udc_disconnect(void);# define BOOTM_ENABLE_TAGS 0#endif -#ifdef CONFIG_INITRD_TAG -#define BOOTM_ENABLE_INITRD_TAG 1 -#else -#define BOOTM_ENABLE_INITRD_TAG 0 -#endif -#ifdef CONFIG_SERIAL_TAG void get_board_serial (struct tag_serialnr *serialnr);#else
arch/arm/lib/bootm.c +1 -1
@@ -224,7 +224,7 @@ static void boot_prep_linux(bootm_headers_t *images)setup_revision_tag (¶ms);if (IS_ENABLED (CONFIG_SETUP_MEMORY_TAGS ))setup_memory_tags (gd->bd); -if (BOOTM_ENABLE_INITRD_TAG ) { +if (IS_ENABLED (CONFIG_INITRD_TAG )) {if (images->rd_start && images->rd_end) {setup_initrd_tag (gd->bd, images->rd_start, images->rd_end);
Signature · 1 line
1.9.1
PATCH 11/11 ARM: bootm: drop redundant #ifdef conditional
In reply to Masahiro YamadaThis if-block is compiled only when IS_ENABLED(CONFIG_OF_LIBFDT) is true. The #ifdef CONFIG_OF_LIBFDT inside of it is redundant.
---
arch/arm/lib/bootm.c | 2 -- 1 file changed, 2 deletions(-)
arch/arm/lib/bootm.c +0 -2
@@ -206,13 +206,11 @@ static void boot_prep_linux(bootm_headers_t *images)char *commandline =getenv ("bootargs" );if (IS_ENABLED (CONFIG_OF_LIBFDT ) && images->ft_len) { -#ifdef CONFIG_OF_LIBFDT debug ("using: FDT\n" );if (image_setup_linux (images)) {printf ("FDT creation failed! hanging..." );hang (); } -#endif }else if (BOOTM_ENABLE_TAGS ) {debug ("using: ATAGS\n" );setup_start_tag (gd->bd);
Signature · 1 line
1.9.1
cover zap: Do not use macros that are equivalent to IS_ENABLED(CONFIG_...)
In reply to Masahiro YamadaQuoted 7 lines · Masahiro Yamada
Please stop such coding habit as follows:
#ifdef CONFIG_FOO # define ENABLE_FOO 1 #else # define ENABLE_FOO 0 #endif
Oh yes, this is horrible, kill this with fire :)
Quoted 17 lines
Use
IS_ENABLED(CONFIG_FOO), instead.Masahiro Yamada (11):
image: zapIMAGE_ENABLE_RAMDISK_HIGH
image: zapIMAGE_ENABLE_OF_LIBFDT
image: zapIMAGE_BOOT_GET_CMDLINE
image: zapIMAGE_OF_BOARD_SETUP
image: zapIMAGE_OF_SYSTEM_SETUP
ARM: bootm:BOOTM_ENABLE_SERIAL_TAG
ARM: bootm:BOOTM_ENABLE_CMDLINE_TAG
ARM: bootm:BOOTM_ENABLE_REVISION_TAG
ARM: bootm:BOOTM_ENABLE_MEMORY_TAG
ARM: bootm:BOOTM_ENABLE_INITRD_TAG
ARM: bootm: drop redundant #ifdef conditional
Quoted 7 lines
arch/arc/lib/bootm.c | 2 +- arch/arm/include/asm/bootm.h | 22 ---------------------- arch/arm/lib/bootm.c | 16 +++++++--------- common/image-fdt.c | 6 +++--- common/image.c | 10 +++++----- include/image.h | 30 ------------------------------ 6 files changed, 16 insertions(+), 70 deletions(-)
Best regards,
Marek Vasut
cover zap: Do not use macros that are equivalent to IS_ENABLED(CONFIG_...)
Hi Masahiro,
Quoted 35 lines · Marek Vasut
Quoted 7 lines · Masahiro Yamada
Please stop such coding habit as follows:
#ifdef CONFIG_FOO # define ENABLE_FOO 1 #else # define ENABLE_FOO 0 #endifOh yes, this is horrible, kill this with fire :)
Quoted 24 lines
Use
IS_ENABLED(CONFIG_FOO), instead.Masahiro Yamada (11):
image: zapIMAGE_ENABLE_RAMDISK_HIGH
image: zapIMAGE_ENABLE_OF_LIBFDT
image: zapIMAGE_BOOT_GET_CMDLINE
image: zapIMAGE_OF_BOARD_SETUP
image: zapIMAGE_OF_SYSTEM_SETUP
ARM: bootm:BOOTM_ENABLE_SERIAL_TAG
ARM: bootm:BOOTM_ENABLE_CMDLINE_TAG
ARM: bootm:BOOTM_ENABLE_REVISION_TAG
ARM: bootm:BOOTM_ENABLE_MEMORY_TAG
ARM: bootm:BOOTM_ENABLE_INITRD_TAG
ARM: bootm: drop redundant #ifdef conditionalarch/arc/lib/bootm.c | 2 +- arch/arm/include/asm/bootm.h | 22 ---------------------- arch/arm/lib/bootm.c | 16 +++++++--------- common/image-fdt.c | 6 +++--- common/image.c | 10 +++++----- include/image.h | 30 ------------------------------ 6 files changed, 16 insertions(+), 70 deletions(-)
I definitely agree it would be good to drop this. But does it work? I thought IS_ENABLED() only worked for Kconfig options?
Regards,
Simon
cover zap: Do not use macros that are equivalent to IS_ENABLED(CONFIG_...)
Hi Simon,
2015-12-19 3:57 GMT+09:00 Simon Glass <[email protected]>:
Quoted 4 lines
Quoted 1 line
Quoted 1 line
6 files changed, 16 insertions(+), 70 deletions(-)I definitely agree it would be good to drop this. But does it work? I thought
IS_ENABLED()only worked forKconfigoptions?
Ah, I missed that.
IS_ENABLED() only works with macros defined as 1.
Most of include/configs/*.h define macros without values, so this series does not work.
I've marked it as Rejected.
Signature · 2 lines
Best Regards Masahiro Yamada
cover zap: Do not use macros that are equivalent to IS_ENABLED(CONFIG_...)
Hi Masahiro,
Quoted 11 lines · Masahiro Yamada
Hi Simon,
2015-12-19 3:57 GMT+09:00 Simon Glass <[email protected]>:
Quoted 4 lines
Quoted 1 line
Quoted 1 line
6 files changed, 16 insertions(+), 70 deletions(-)I definitely agree it would be good to drop this. But does it work? I thought
IS_ENABLED()only worked forKconfigoptions?
Quoted 8 lines
Ah, I missed that.
IS_ENABLED()only works with macros defined as 1.Most of
include/configs/*.hdefine macros without values, so this series does not work.I've marked it as Rejected.
I suppose we need to convert them all to Kconfig.
Regards,
Simon