[PATCH v2 1/2] treewide: Fix wrong CONFIG_IS_ENABLED() handling

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH v2 1/2] treewide: Fix wrong CONFIG_IS_ENABLED() handling

Alper Nebi Yasak
CONFIG_IS_ENABLED() takes the kconfig name without the CONFIG_ prefix,
e.g. CONFIG_IS_ENABLED(CLK) for CONFIG_CLK. Some of these were being
fixed every now and then, see:

    commit 71ba2cb0d678 ("board: stm32mp1: correct CONFIG_IS_ENABLED usage for LED")
    commit a5ada25e4213 ("rockchip: clk: fix wrong CONFIG_IS_ENABLED handling")
    commit 5daf6e56d36c ("common: console: Fix duplicated CONFIG in silent env callback")
    commit 48bfc31b6484 ("MIPS: bootm: Fix broken boot_env_legacy codepath")

Fix all files found by `git grep "CONFIG_IS_ENABLED(CONFIG"` by running
':%s/CONFIG_IS_ENABLED(CONFIG_\(\w+\))/CONFIG_IS_ENABLED(\1)/g' in vim.

Signed-off-by: Alper Nebi Yasak <[hidden email]>
Reviewed-by: Simon Glass <[hidden email]>
---

Changes in v2:
- Add tag: "Reviewed-by: Simon Glass <[hidden email]>"

v1: https://patchwork.ozlabs.org/project/uboot/patch/20200930114612.22319-1-alpernebiyasak@.../

 drivers/clk/rockchip/clk_rk3399.c   |  2 +-
 drivers/spi/nxp_fspi.c              | 10 +++++-----
 drivers/sysreset/sysreset_mpc83xx.c |  8 ++++----
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c
index 22c373a623..1ea41f3c5b 100644
--- a/drivers/clk/rockchip/clk_rk3399.c
+++ b/drivers/clk/rockchip/clk_rk3399.c
@@ -1592,7 +1592,7 @@ static int rk3399_pmuclk_ofdata_to_platdata(struct udevice *dev)
 
 static int rk3399_pmuclk_bind(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(CONFIG_RESET_ROCKCHIP)
+#if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
  int ret;
 
  ret = offsetof(struct rk3399_pmucru, pmucru_softrst_con[0]);
diff --git a/drivers/spi/nxp_fspi.c b/drivers/spi/nxp_fspi.c
index c507437f2e..ebd94925e9 100644
--- a/drivers/spi/nxp_fspi.c
+++ b/drivers/spi/nxp_fspi.c
@@ -520,7 +520,7 @@ static void nxp_fspi_prepare_lut(struct nxp_fspi *f,
  fspi_writel(f, FSPI_LCKER_LOCK, f->iobase + FSPI_LCKCR);
 }
 
-#if CONFIG_IS_ENABLED(CONFIG_CLK)
+#if CONFIG_IS_ENABLED(CLK)
 static int nxp_fspi_clk_prep_enable(struct nxp_fspi *f)
 {
  int ret;
@@ -808,7 +808,7 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)
  int ret, i;
  u32 reg;
 
-#if CONFIG_IS_ENABLED(CONFIG_CLK)
+#if CONFIG_IS_ENABLED(CLK)
  /* disable and unprepare clock to avoid glitch pass to controller */
  nxp_fspi_clk_disable_unprep(f);
 
@@ -898,7 +898,7 @@ static int nxp_fspi_claim_bus(struct udevice *dev)
 
 static int nxp_fspi_set_speed(struct udevice *bus, uint speed)
 {
-#if CONFIG_IS_ENABLED(CONFIG_CLK)
+#if CONFIG_IS_ENABLED(CLK)
  struct nxp_fspi *f = dev_get_priv(bus);
  int ret;
 
@@ -924,7 +924,7 @@ static int nxp_fspi_set_mode(struct udevice *bus, uint mode)
 static int nxp_fspi_ofdata_to_platdata(struct udevice *bus)
 {
  struct nxp_fspi *f = dev_get_priv(bus);
-#if CONFIG_IS_ENABLED(CONFIG_CLK)
+#if CONFIG_IS_ENABLED(CLK)
  int ret;
 #endif
 
@@ -950,7 +950,7 @@ static int nxp_fspi_ofdata_to_platdata(struct udevice *bus)
  f->ahb_addr = map_physmem(ahb_addr, ahb_size, MAP_NOCACHE);
  f->memmap_phy_size = ahb_size;
 
-#if CONFIG_IS_ENABLED(CONFIG_CLK)
+#if CONFIG_IS_ENABLED(CLK)
  ret = clk_get_by_name(bus, "fspi_en", &f->clk_en);
  if (ret) {
  dev_err(bus, "failed to get fspi_en clock\n");
diff --git a/drivers/sysreset/sysreset_mpc83xx.c b/drivers/sysreset/sysreset_mpc83xx.c
index 456f006bc1..4e89971840 100644
--- a/drivers/sysreset/sysreset_mpc83xx.c
+++ b/drivers/sysreset/sysreset_mpc83xx.c
@@ -106,7 +106,7 @@ static int print_83xx_arb_event(bool force, char *buf, int size)
  if (!force && !gd->arch.arbiter_event_address)
  return 0;
 
- if (CONFIG_IS_ENABLED(CONFIG_DISPLAY_AER_FULL)) {
+ if (CONFIG_IS_ENABLED(DISPLAY_AER_FULL)) {
  res = snprintf(buf, size,
        "Arbiter Event Status:\n"
        "    %s: 0x%08lX\n"
@@ -119,7 +119,7 @@ static int print_83xx_arb_event(bool force, char *buf, int size)
        "Master ID", mstr_id, master[mstr_id],
        "Transfer Size", tsize_val, tsize_bytes,
        "Transfer Type", ttype, transfer[ttype]);
- } else if (CONFIG_IS_ENABLED(CONFIG_DISPLAY_AER_BRIEF)) {
+ } else if (CONFIG_IS_ENABLED(DISPLAY_AER_BRIEF)) {
  res = snprintf(buf, size,
        "Arbiter Event Status: AEATR=0x%08lX, AEADR=0x%08lX\n",
        gd->arch.arbiter_event_attributes,
@@ -183,8 +183,8 @@ static int mpc83xx_sysreset_get_status(struct udevice *dev, char *buf, int size)
  * TODO([hidden email]): Move this into a dedicated
  *     arbiter driver
  */
- if (CONFIG_IS_ENABLED(CONFIG_DISPLAY_AER_FULL) ||
-    CONFIG_IS_ENABLED(CONFIG_DISPLAY_AER_BRIEF)) {
+ if (CONFIG_IS_ENABLED(DISPLAY_AER_FULL) ||
+    CONFIG_IS_ENABLED(DISPLAY_AER_BRIEF)) {
  /*
  * If there was a bus monitor reset event, we force the arbiter
  * event to be printed
--
2.28.0

Reply | Threaded
Open this post in threaded view
|

[PATCH v2 2/2] checkpatch.pl: Make CONFIG_IS_ENABLED(CONFIG_*) an error

Alper Nebi Yasak
CONFIG_IS_ENABLED() takes the kconfig name without the CONFIG_ prefix,
e.g. CONFIG_IS_ENABLED(CLK) for CONFIG_CLK. Make including the prefix
an error in checkpatch.pl so calls in the wrong format aren't
accidentally reintroduced.

Signed-off-by: Alper Nebi Yasak <[hidden email]>
---

Changes in v2:
- Add patman test

v1: https://patchwork.ozlabs.org/project/uboot/patch/20200930114612.22319-2-alpernebiyasak@.../

 scripts/checkpatch.pl           | 6 ++++++
 tools/patman/test_checkpatch.py | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4bed2b0cdc..4ed7e124c9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2365,6 +2365,12 @@ sub u_boot_line {
  ERROR("DISABLE_FDT_OR_INITRD_RELOC",
      "fdt or initrd relocation disabled at boot time\n" . $herecurr);
  }
+
+ # Do not use CONFIG_ prefix in CONFIG_IS_ENABLED() calls
+ if ($line =~ /^\+.*CONFIG_IS_ENABLED\(CONFIG_\w*\).*/) {
+ ERROR("CONFIG_IS_ENABLED_CONFIG",
+      "CONFIG_IS_ENABLED() takes values without the CONFIG_ prefix\n" . $herecurr);
+ }
 }
 
 sub process {
diff --git a/tools/patman/test_checkpatch.py b/tools/patman/test_checkpatch.py
index 792196e689..f71c70fb13 100644
--- a/tools/patman/test_checkpatch.py
+++ b/tools/patman/test_checkpatch.py
@@ -405,6 +405,12 @@ index 0000000..2234c87
         pm.add_line('include/myfile.h', '#include <dm.h>')
         self.checkSingleMessage(pm, 'BARRED_INCLUDE_IN_HDR', 'error')
 
+    def testConfigIsEnabledConfig(self):
+        """Test for accidental CONFIG_IS_ENABLED(CONFIG_*) calls"""
+        pm = PatchMaker()
+        pm.add_line('common/main.c', 'if (CONFIG_IS_ENABLED(CONFIG_CLK))')
+        self.checkSingleMessage(pm, 'CONFIG_IS_ENABLED_CONFIG', 'error')
+
 
 if __name__ == "__main__":
     unittest.main()
--
2.28.0

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2 2/2] checkpatch.pl: Make CONFIG_IS_ENABLED(CONFIG_*) an error

Simon Glass-3
On Mon, 5 Oct 2020 at 00:57, Alper Nebi Yasak <[hidden email]> wrote:

>
> CONFIG_IS_ENABLED() takes the kconfig name without the CONFIG_ prefix,
> e.g. CONFIG_IS_ENABLED(CLK) for CONFIG_CLK. Make including the prefix
> an error in checkpatch.pl so calls in the wrong format aren't
> accidentally reintroduced.
>
> Signed-off-by: Alper Nebi Yasak <[hidden email]>
> ---
>
> Changes in v2:
> - Add patman test
>
> v1: https://patchwork.ozlabs.org/project/uboot/patch/20200930114612.22319-2-alpernebiyasak@.../
>
>  scripts/checkpatch.pl           | 6 ++++++
>  tools/patman/test_checkpatch.py | 6 ++++++
>  2 files changed, 12 insertions(+)
>

Reviewed-by: Simon Glass <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2 1/2] treewide: Fix wrong CONFIG_IS_ENABLED() handling

Tom Rini-4
In reply to this post by Alper Nebi Yasak
On Mon, Oct 05, 2020 at 09:57:29AM +0300, Alper Nebi Yasak wrote:

> CONFIG_IS_ENABLED() takes the kconfig name without the CONFIG_ prefix,
> e.g. CONFIG_IS_ENABLED(CLK) for CONFIG_CLK. Some of these were being
> fixed every now and then, see:
>
>     commit 71ba2cb0d678 ("board: stm32mp1: correct CONFIG_IS_ENABLED usage for LED")
>     commit a5ada25e4213 ("rockchip: clk: fix wrong CONFIG_IS_ENABLED handling")
>     commit 5daf6e56d36c ("common: console: Fix duplicated CONFIG in silent env callback")
>     commit 48bfc31b6484 ("MIPS: bootm: Fix broken boot_env_legacy codepath")
>
> Fix all files found by `git grep "CONFIG_IS_ENABLED(CONFIG"` by running
> ':%s/CONFIG_IS_ENABLED(CONFIG_\(\w+\))/CONFIG_IS_ENABLED(\1)/g' in vim.
>
> Signed-off-by: Alper Nebi Yasak <[hidden email]>
> Reviewed-by: Simon Glass <[hidden email]>
Applied to u-boot/master, thanks!

--
Tom

signature.asc (673 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2 2/2] checkpatch.pl: Make CONFIG_IS_ENABLED(CONFIG_*) an error

Tom Rini-4
In reply to this post by Alper Nebi Yasak
On Mon, Oct 05, 2020 at 09:57:30AM +0300, Alper Nebi Yasak wrote:

> CONFIG_IS_ENABLED() takes the kconfig name without the CONFIG_ prefix,
> e.g. CONFIG_IS_ENABLED(CLK) for CONFIG_CLK. Make including the prefix
> an error in checkpatch.pl so calls in the wrong format aren't
> accidentally reintroduced.
>
> Signed-off-by: Alper Nebi Yasak <[hidden email]>
> Reviewed-by: Simon Glass <[hidden email]>

Applied to u-boot/master, thanks!

--
Tom

signature.asc (673 bytes) Download Attachment