[PATCH v5 0/1] CONFIG_IS_ENABLED vs IS_ENABLED

2023-10-27 Thread Troy Kisky


This patch set gets ready to checks the usage of
CONFIG_IS_ENABLED/IS_ENABLED.

After the set has been applied, you can delete
test/usage_of_is_enabled_todo.txt
and run test/usage_of_is_enabled_commit.sh

The script test/usage_of_is_enabled_check.sh
checks for new questionable uses of
CONFIG_IS_ENABLED/IS_ENABLED and is added
to .azure-pipelines.yml, and
.gitlab-ci.yml

version 5 changes:
rebased on denx/next and updated todo with

rm test/usage_of_is_enabled_todo.txt
test/usage_of_is_enabled_check.sh >test/usage_of_is_enabled_todo.txt

And delete the last 2 lines
sed -i '$d' test/usage_of_is_enabled_todo.txt
sed -i '$d' test/usage_of_is_enabled_todo.txt

version 4 changes:
Down to just one patch, other issue fixed by other means
Added the following new configs to todo
ACPI
DM_CLK
FEC_MXC
FWU_MULTI_BANK_UPDATE
IMX8M_VDD_SOC_850MV
MCFTMR
PANEL
SANDBOX64
SPLASH_SCREEN
SPLASH_SOURCE
SPL_LOAD_FIT
USB_ETH_RNDIS
VIDEO
VIDEO_BPP16
VIDEO_BPP32
VIDEO_BPP8
VIDEO_LOGO
X86_32BIT_INIT

version 3 changes:
Dropped changes to puma-rk3399 and ringneck-px30
in favor of Quentin Schulz's patch
https://patchwork.ozlabs.org/project/uboot/patch/20230301-tsd-env-nowhere-kconfig-v1-1-d5c08e096...@theobroma-systems.com/
https://patchwork.ozlabs.org/project/uboot/patch/20230301-tsd-env-nowhere-kconfig-v1-2-d5c08e096...@theobroma-systems.com/
Please apply them before this series.

Drop gateworks: venice: Always define setup_fec and setup_eqos
Drop arm: cpu: armv7: ls102xa: fdt: remove eth_device support
Simon's patches took care of these

Add to todo list, these new questionable uses that snuck into the code.
PARTITION_TYPE_GUID
PHY_ATHEROS
RTC_SANDBOX

(no changes since v1)

Troy Kisky (1):
  CI: add test/usage_of_is_enabled_check.sh

 .azure-pipelines.yml|  11 ++
 .gitlab-ci.yml  |   5 +
 test/usage_of_is_enabled_check.sh   |  19 +++
 test/usage_of_is_enabled_commit.sh  |  12 ++
 test/usage_of_is_enabled_correct.sh |  50 ++
 test/usage_of_is_enabled_exempt.txt |   9 ++
 test/usage_of_is_enabled_list.sh|  86 +++
 test/usage_of_is_enabled_splcfg.txt |  21 +++
 test/usage_of_is_enabled_todo.txt   | 232 
 9 files changed, 445 insertions(+)
 create mode 100755 test/usage_of_is_enabled_check.sh
 create mode 100755 test/usage_of_is_enabled_commit.sh
 create mode 100755 test/usage_of_is_enabled_correct.sh
 create mode 100644 test/usage_of_is_enabled_exempt.txt
 create mode 100755 test/usage_of_is_enabled_list.sh
 create mode 100644 test/usage_of_is_enabled_splcfg.txt
 create mode 100644 test/usage_of_is_enabled_todo.txt

-- 
2.34.1



[PATCH v5 1/1] CI: add test/usage_of_is_enabled_check.sh

2023-10-27 Thread Troy Kisky
Add script usage_of_is_enabled_check to print any configs that
use CONFIG_IS_ENABLED instead of IS_ENABLED and vice versa.

Add usage_of_is_enabled_commit.sh to generate commits to fix the above
issues.

You can remove entries from test/usage_of_is_enabled_todo.txt
or the entire file and then run
test/usage_of_is_enabled_commit.sh
to convert to suggested usage of CONFIG_IS_ENABLED/IS_ENABLED

or run test/usage_of_is_enabled_check.sh to
see which configs are still todo.

Reviewed-by: Simon Glass 
Signed-off-by: Troy Kisky 
---

(no changes since v1)

 .azure-pipelines.yml|  11 ++
 .gitlab-ci.yml  |   5 +
 test/usage_of_is_enabled_check.sh   |  19 +++
 test/usage_of_is_enabled_commit.sh  |  12 ++
 test/usage_of_is_enabled_correct.sh |  50 ++
 test/usage_of_is_enabled_exempt.txt |   9 ++
 test/usage_of_is_enabled_list.sh|  86 +++
 test/usage_of_is_enabled_splcfg.txt |  21 +++
 test/usage_of_is_enabled_todo.txt   | 232 
 9 files changed, 445 insertions(+)
 create mode 100755 test/usage_of_is_enabled_check.sh
 create mode 100755 test/usage_of_is_enabled_commit.sh
 create mode 100755 test/usage_of_is_enabled_correct.sh
 create mode 100644 test/usage_of_is_enabled_exempt.txt
 create mode 100755 test/usage_of_is_enabled_list.sh
 create mode 100644 test/usage_of_is_enabled_splcfg.txt
 create mode 100644 test/usage_of_is_enabled_todo.txt

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 421c5018b40..f8d46ead97f 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -67,6 +67,17 @@ stages:
   :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
   :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+  - job: check_usage_of_is_enabled
+displayName: 'Check usage of CONFIG_IS_ENABLED vs IS_ENABLED'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  # generate list of SPL configs
+  - script: test/usage_of_is_enabled_check.sh
+
   - job: docs
 displayName: 'Build documentation'
 pool:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 981b95c00d8..6f4a016bf60 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -163,6 +163,11 @@ check for new CONFIG symbols outside Kconfig:
 :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
 :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+check usage of CONFIG_IS_ENABLED vs IS_ENABLED:
+  stage: testsuites
+  script:
+- ./test/usage_of_is_enabled_check.sh
+
 # build documentation
 docs:
   extends: .testsuites
diff --git a/test/usage_of_is_enabled_check.sh 
b/test/usage_of_is_enabled_check.sh
new file mode 100755
index 000..6bd5d9c1ac7
--- /dev/null
+++ b/test/usage_of_is_enabled_check.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+${scriptdir}/usage_of_is_enabled_list.sh | grep -vw FOO;
+if [ $? -eq 0 ] ; then
+   echo "The above may have incorrect usage of IS_ENABLED/"\
+"CONFIG_IS_ENABLED"
+   echo "Run test/usage_of_is_enabled_commit.sh and "\
+"squash with appropriate commit"
+   ret=1;
+else
+   ret=0;
+fi
+
+rm ${scriptdir}/splcfg.tmp ${scriptdir}/exclude.tmp
+exit ${ret}
diff --git a/test/usage_of_is_enabled_commit.sh 
b/test/usage_of_is_enabled_commit.sh
new file mode 100755
index 000..593dbd1428c
--- /dev/null
+++ b/test/usage_of_is_enabled_commit.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+${scriptdir}/usage_of_is_enabled_list.sh | \
+xargs -I {} sh -c "${scriptdir}/usage_of_is_enabled_correct.sh {}; \
+git commit -a -m\"CONFIG_{}: correct usage of CONFIG_IS_ENABLED/IS_ENABLED\";"
+
+
+rm ${scriptdir}/splcfg.tmp ${scriptdir}/exclude.tmp
diff --git a/test/usage_of_is_enabled_correct.sh 
b/test/usage_of_is_enabled_correct.sh
new file mode 100755
index 000..8724747beed
--- /dev/null
+++ b/test/usage_of_is_enabled_correct.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+
+if [ -z "$1" ] ; then
+   echo missing config
+   exit 1;
+fi
+if [ ! -f "${scriptdir}/splcfg.tmp" ] ; then
+   echo missing splcfg.tmp
+   exit 1;
+fi
+
+
+grep -qw $1 ${scriptdir}/splcfg.tmp
+if [ $? -ne 0 ] ; then
+# not splcfg
+# change CONFIG_IS_ENABLED to IS_ENABLED
+git grep -l \
+-e "CONFIG_IS_ENABLED($1)" \
+ | \
+xargs -IFile sh -c \
+" \
+sed -i -E \"\
+s/CONFIG_IS_ENABLED\($1\)/IS_ENABLED\(CONFIG_$1\)/g; \
+\" File";
+else
+# splcfg
+# change IS_ENABLED to CONFIG_IS_ENABLED
+# change ifdef to CONFIG_IS_ENABLED
+# c

Re: [PATCH v4 1/1] CI: add test/usage_of_is_enabled_check.sh

2023-09-27 Thread Troy Kisky
On Wed, Sep 27, 2023 at 11:14 AM Troy Kisky 
wrote:

>
>
> On Mon, Jun 19, 2023 at 4:07 PM Troy Kisky 
> wrote:
>
>> Add script usage_of_is_enabled_check to print any configs that
>> use CONFIG_IS_ENABLED instead of IS_ENABLED and vice versa.
>>
>> Add usage_of_is_enabled_commit.sh to generate commits to fix the above
>> issues.
>>
>> You can remove entries from test/usage_of_is_enabled_todo.txt
>> or the entire file and then run
>> test/usage_of_is_enabled_commit.sh
>> to convert to suggested usage of CONFIG_IS_ENABLED/IS_ENABLED
>>
>> or run test/usage_of_is_enabled_check.sh to
>> see which configs are still todo.
>>
>> Reviewed-by: Simon Glass 
>> Signed-off-by: Troy Kisky 
>> ---
>>
>> (no changes since v1)
>>
>>  .azure-pipelines.yml|  11 ++
>>  .gitlab-ci.yml  |   5 +
>>  test/usage_of_is_enabled_check.sh   |  19 +++
>>  test/usage_of_is_enabled_commit.sh  |  12 ++
>>  test/usage_of_is_enabled_correct.sh |  50 +++
>>  test/usage_of_is_enabled_exempt.txt |   9 ++
>>  test/usage_of_is_enabled_list.sh|  86 +++
>>  test/usage_of_is_enabled_splcfg.txt |  21 +++
>>  test/usage_of_is_enabled_todo.txt   | 213 
>>  9 files changed, 426 insertions(+)
>>  create mode 100755 test/usage_of_is_enabled_check.sh
>>  create mode 100755 test/usage_of_is_enabled_commit.sh
>>  create mode 100755 test/usage_of_is_enabled_correct.sh
>>  create mode 100644 test/usage_of_is_enabled_exempt.txt
>>  create mode 100755 test/usage_of_is_enabled_list.sh
>>  create mode 100644 test/usage_of_is_enabled_splcfg.txt
>>  create mode 100644 test/usage_of_is_enabled_todo.txt
>>
>>
> If this patch is still desirable, it can be updated by
>
> rm test/usage_of_is_enabled_todo.txt
> test/usage_of_is_enabled_check.sh >test/usage_of_is_enabled_todo.txt
>
> And delete the last 2 lines
sed -i '$d' test/usage_of_is_enabled_todo.txt
sed -i '$d' test/usage_of_is_enabled_todo.txt


> BR
> Troy
>
>


Re: [PATCH v4 1/1] CI: add test/usage_of_is_enabled_check.sh

2023-09-27 Thread Troy Kisky
On Mon, Jun 19, 2023 at 4:07 PM Troy Kisky 
wrote:

> Add script usage_of_is_enabled_check to print any configs that
> use CONFIG_IS_ENABLED instead of IS_ENABLED and vice versa.
>
> Add usage_of_is_enabled_commit.sh to generate commits to fix the above
> issues.
>
> You can remove entries from test/usage_of_is_enabled_todo.txt
> or the entire file and then run
> test/usage_of_is_enabled_commit.sh
> to convert to suggested usage of CONFIG_IS_ENABLED/IS_ENABLED
>
> or run test/usage_of_is_enabled_check.sh to
> see which configs are still todo.
>
> Reviewed-by: Simon Glass 
> Signed-off-by: Troy Kisky 
> ---
>
> (no changes since v1)
>
>  .azure-pipelines.yml|  11 ++
>  .gitlab-ci.yml  |   5 +
>  test/usage_of_is_enabled_check.sh   |  19 +++
>  test/usage_of_is_enabled_commit.sh  |  12 ++
>  test/usage_of_is_enabled_correct.sh |  50 +++
>  test/usage_of_is_enabled_exempt.txt |   9 ++
>  test/usage_of_is_enabled_list.sh|  86 +++
>  test/usage_of_is_enabled_splcfg.txt |  21 +++
>  test/usage_of_is_enabled_todo.txt   | 213 
>  9 files changed, 426 insertions(+)
>  create mode 100755 test/usage_of_is_enabled_check.sh
>  create mode 100755 test/usage_of_is_enabled_commit.sh
>  create mode 100755 test/usage_of_is_enabled_correct.sh
>  create mode 100644 test/usage_of_is_enabled_exempt.txt
>  create mode 100755 test/usage_of_is_enabled_list.sh
>  create mode 100644 test/usage_of_is_enabled_splcfg.txt
>  create mode 100644 test/usage_of_is_enabled_todo.txt
>
>
If this patch is still desirable, it can be updated by

rm test/usage_of_is_enabled_todo.txt
test/usage_of_is_enabled_check.sh >test/usage_of_is_enabled_todo.txt

BR
Troy


[PATCH v4 1/1] CI: add test/usage_of_is_enabled_check.sh

2023-06-19 Thread Troy Kisky
Add script usage_of_is_enabled_check to print any configs that
use CONFIG_IS_ENABLED instead of IS_ENABLED and vice versa.

Add usage_of_is_enabled_commit.sh to generate commits to fix the above
issues.

You can remove entries from test/usage_of_is_enabled_todo.txt
or the entire file and then run
test/usage_of_is_enabled_commit.sh
to convert to suggested usage of CONFIG_IS_ENABLED/IS_ENABLED

or run test/usage_of_is_enabled_check.sh to
see which configs are still todo.

Reviewed-by: Simon Glass 
Signed-off-by: Troy Kisky 
---

(no changes since v1)

 .azure-pipelines.yml|  11 ++
 .gitlab-ci.yml  |   5 +
 test/usage_of_is_enabled_check.sh   |  19 +++
 test/usage_of_is_enabled_commit.sh  |  12 ++
 test/usage_of_is_enabled_correct.sh |  50 +++
 test/usage_of_is_enabled_exempt.txt |   9 ++
 test/usage_of_is_enabled_list.sh|  86 +++
 test/usage_of_is_enabled_splcfg.txt |  21 +++
 test/usage_of_is_enabled_todo.txt   | 213 
 9 files changed, 426 insertions(+)
 create mode 100755 test/usage_of_is_enabled_check.sh
 create mode 100755 test/usage_of_is_enabled_commit.sh
 create mode 100755 test/usage_of_is_enabled_correct.sh
 create mode 100644 test/usage_of_is_enabled_exempt.txt
 create mode 100755 test/usage_of_is_enabled_list.sh
 create mode 100644 test/usage_of_is_enabled_splcfg.txt
 create mode 100644 test/usage_of_is_enabled_todo.txt

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 3c1846a5bc3..9b5a0ab6459 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -67,6 +67,17 @@ stages:
   :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
   :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+  - job: check_usage_of_is_enabled
+displayName: 'Check usage of CONFIG_IS_ENABLED vs IS_ENABLED'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  # generate list of SPL configs
+  - script: test/usage_of_is_enabled_check.sh
+
   - job: cppcheck
 displayName: 'Static code analysis with cppcheck'
 pool:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e6c6ab3586e..2591feabfe6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -148,6 +148,11 @@ check for new CONFIG symbols outside Kconfig:
 :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
 :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+check usage of CONFIG_IS_ENABLED vs IS_ENABLED:
+  stage: testsuites
+  script:
+- ./test/usage_of_is_enabled_check.sh
+
 # QA jobs for code analytics
 # static code analysis with cppcheck (we can add --enable=all later)
 cppcheck:
diff --git a/test/usage_of_is_enabled_check.sh 
b/test/usage_of_is_enabled_check.sh
new file mode 100755
index 000..6bd5d9c1ac7
--- /dev/null
+++ b/test/usage_of_is_enabled_check.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+${scriptdir}/usage_of_is_enabled_list.sh | grep -vw FOO;
+if [ $? -eq 0 ] ; then
+   echo "The above may have incorrect usage of IS_ENABLED/"\
+"CONFIG_IS_ENABLED"
+   echo "Run test/usage_of_is_enabled_commit.sh and "\
+"squash with appropriate commit"
+   ret=1;
+else
+   ret=0;
+fi
+
+rm ${scriptdir}/splcfg.tmp ${scriptdir}/exclude.tmp
+exit ${ret}
diff --git a/test/usage_of_is_enabled_commit.sh 
b/test/usage_of_is_enabled_commit.sh
new file mode 100755
index 000..593dbd1428c
--- /dev/null
+++ b/test/usage_of_is_enabled_commit.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+${scriptdir}/usage_of_is_enabled_list.sh | \
+xargs -I {} sh -c "${scriptdir}/usage_of_is_enabled_correct.sh {}; \
+git commit -a -m\"CONFIG_{}: correct usage of CONFIG_IS_ENABLED/IS_ENABLED\";"
+
+
+rm ${scriptdir}/splcfg.tmp ${scriptdir}/exclude.tmp
diff --git a/test/usage_of_is_enabled_correct.sh 
b/test/usage_of_is_enabled_correct.sh
new file mode 100755
index 000..8724747beed
--- /dev/null
+++ b/test/usage_of_is_enabled_correct.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+
+if [ -z "$1" ] ; then
+   echo missing config
+   exit 1;
+fi
+if [ ! -f "${scriptdir}/splcfg.tmp" ] ; then
+   echo missing splcfg.tmp
+   exit 1;
+fi
+
+
+grep -qw $1 ${scriptdir}/splcfg.tmp
+if [ $? -ne 0 ] ; then
+# not splcfg
+# change CONFIG_IS_ENABLED to IS_ENABLED
+git grep -l \
+-e "CONFIG_IS_ENABLED($1)" \
+ | \
+xargs -IFile sh -c \
+" \
+sed -i -E \"\
+s/CONFIG_IS_ENABLED\($1\)/IS_ENABLED\(CONFIG_$1\)/g; \
+\" File";
+else
+# splcfg
+# change IS_ENABLE

[PATCH v4 0/1] CONFIG_IS_ENABLED vs IS_ENABLED

2023-06-19 Thread Troy Kisky


This patch set gets ready to checks the usage of
CONFIG_IS_ENABLED/IS_ENABLED.

After the set has been applied, you can delete
test/usage_of_is_enabled_todo.txt
and run test/usage_of_is_enabled_commit.sh

The script test/usage_of_is_enabled_check.sh
checks for new questionable uses of
CONFIG_IS_ENABLED/IS_ENABLED and is added
to .azure-pipelines.yml, and
.gitlab-ci.yml

version 4 changes:
Down to just one patch, other issue fixed by other means
Added the following new configs to todo
ACPI
DM_CLK
FEC_MXC
FWU_MULTI_BANK_UPDATE
IMX8M_VDD_SOC_850MV
MCFTMR
PANEL
SANDBOX64
SPLASH_SCREEN
SPLASH_SOURCE
SPL_LOAD_FIT
USB_ETH_RNDIS
VIDEO
VIDEO_BPP16
VIDEO_BPP32
VIDEO_BPP8
VIDEO_LOGO
X86_32BIT_INIT

version 3 changes:
Dropped changes to puma-rk3399 and ringneck-px30
in favor of Quentin Schulz's patch
https://patchwork.ozlabs.org/project/uboot/patch/20230301-tsd-env-nowhere-kconfig-v1-1-d5c08e096...@theobroma-systems.com/
https://patchwork.ozlabs.org/project/uboot/patch/20230301-tsd-env-nowhere-kconfig-v1-2-d5c08e096...@theobroma-systems.com/
Please apply them before this series.

Drop gateworks: venice: Always define setup_fec and setup_eqos
Drop arm: cpu: armv7: ls102xa: fdt: remove eth_device support
Simon's patches took care of these

Add to todo list, these new questionable uses that snuck into the code.
PARTITION_TYPE_GUID
PHY_ATHEROS
RTC_SANDBOX

(no changes since v1)

Troy Kisky (1):
  CI: add test/usage_of_is_enabled_check.sh

 .azure-pipelines.yml|  11 ++
 .gitlab-ci.yml  |   5 +
 test/usage_of_is_enabled_check.sh   |  19 +++
 test/usage_of_is_enabled_commit.sh  |  12 ++
 test/usage_of_is_enabled_correct.sh |  50 +++
 test/usage_of_is_enabled_exempt.txt |   9 ++
 test/usage_of_is_enabled_list.sh|  86 +++
 test/usage_of_is_enabled_splcfg.txt |  21 +++
 test/usage_of_is_enabled_todo.txt   | 213 
 9 files changed, 426 insertions(+)
 create mode 100755 test/usage_of_is_enabled_check.sh
 create mode 100755 test/usage_of_is_enabled_commit.sh
 create mode 100755 test/usage_of_is_enabled_correct.sh
 create mode 100644 test/usage_of_is_enabled_exempt.txt
 create mode 100755 test/usage_of_is_enabled_list.sh
 create mode 100644 test/usage_of_is_enabled_splcfg.txt
 create mode 100644 test/usage_of_is_enabled_todo.txt

-- 
2.34.1



Re: [PATCH v3 17/23] ns16550: match when to define bdf with uart code

2023-05-10 Thread Troy Kisky
Hi Tom,

You are looking at an old patch, here's the new.

commit c969bedb9cb6029360e6fe7e25a331680fabe3ee
Author: Troy Kisky 
Date:   Thu Feb 23 08:01:46 2023 -0800

ns16550: match when to define bdf with uart code

When switching defined(CONFIG_PCI) to CONFIG_IS_ENABLED(PCI)
bdf is no longer accessible. So add preprocessor protection
to avoid access.

Series-changes: 2
- changed condition of when to include field bdf
- added protection to another instance of bdf in uart.c
- Thanks to Simon for getting this corrected

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 

diff --git a/arch/x86/cpu/apollolake/uart.c b/arch/x86/cpu/apollolake/uart.c
index a9362436000..878aa48ed76 100644
--- a/arch/x86/cpu/apollolake/uart.c
+++ b/arch/x86/cpu/apollolake/uart.c
@@ -79,10 +79,12 @@ void apl_uart_init(pci_dev_t bdf, ulong base)

 static int apl_ns16550_probe(struct udevice *dev)
 {
+#if IS_ENABLED_NOCHECK(CONFIG_PCI) && defined(CONFIG_SPL_BUILD)
struct apl_ns16550_plat *plat = dev_get_plat(dev);

if (!CONFIG_IS_ENABLED(PCI))
apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
+#endif

return ns16550_serial_probe(dev);
 }
@@ -110,7 +112,9 @@ static int apl_ns16550_of_to_plat(struct udevice *dev)
ns.reg_offset = 0;
ns.clock = dtplat->clock_frequency;
ns.fcr = UART_FCR_DEFVAL;
+#if IS_ENABLED_NOCHECK(CONFIG_PCI) && defined(CONFIG_SPL_BUILD)
ns.bdf = pci_ofplat_get_devfn(dtplat->reg[0]);
+#endif
memcpy(plat, &ns, sizeof(ns));
 #else
int ret;
diff --git a/include/ns16550.h b/include/ns16550.h
index e7e68663d03..41b977b5b26 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -74,7 +74,7 @@ struct ns16550_plat {
int clock;
u32 fcr;
int flags;
-#if defined(CONFIG_PCI) && defined(CONFIG_SPL)
+#if IS_ENABLED_NOCHECK(CONFIG_PCI) && defined(CONFIG_SPL_BUILD)
int bdf;
 #endif
 };
__

It reads as,
If the bdf exists, then if spl var PCI is not enabled, then init uart.


The PCI code will handle it if PCI is enabled.


So, PCI needs to be enabled, and SPL_PCI needs to not be enabled, and
currently building for SPL



On Wed, May 10, 2023 at 1:49 PM Tom Rini  wrote:

> On Wed, May 10, 2023 at 02:46:14PM -0600, Simon Glass wrote:
> > Hi Tom,
> >
> > On Wed, 10 May 2023 at 14:41, Tom Rini  wrote:
> > >
> > > On Mon, Mar 13, 2023 at 02:31:39PM -0700, Troy Kisky wrote:
> > >
> > > > When switching defined(CONFIG_PCI) to CONFIG_IS_ENABLED(PCI)
> > > > bdf is no longer accessible. So add preprocessor protection
> > > > to avoid access.
> > > >
> > > > Signed-off-by: Troy Kisky 
> > > > Reviewed-by: Simon Glass 
> > > > ---
> > > >
> > > > (no changes since v2)
> > > >
> > > > Changes in v2:
> > > > - changed condition of when to include field bdf
> > > > - added protection to another instance of bdf in uart.c
> > > > - Thanks to Simon for getting this corrected
> > > >
> > > >  arch/x86/cpu/apollolake/uart.c | 4 
> > > >  include/ns16550.h  | 2 +-
> > > >  2 files changed, 5 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/arch/x86/cpu/apollolake/uart.c
> b/arch/x86/cpu/apollolake/uart.c
> > > > index a9362436000..878aa48ed76 100644
> > > > --- a/arch/x86/cpu/apollolake/uart.c
> > > > +++ b/arch/x86/cpu/apollolake/uart.c
> > > > @@ -79,10 +79,12 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
> > > >
> > > >  static int apl_ns16550_probe(struct udevice *dev)
> > > >  {
> > > > +#if IS_ENABLED(CONFIG_PCI) && defined(CONFIG_SPL_BUILD)
> > > >   struct apl_ns16550_plat *plat = dev_get_plat(dev);
> > > >
> > > >   if (!CONFIG_IS_ENABLED(PCI))
> > > >   apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
> > > > +#endif
> > > >
> > > >   return ns16550_serial_probe(dev);
> > > >  }
> > >
> > > Looking at this again, this hunk here doesn't make sense.  Reading
> > > outloud, "if we have CONFIG_PCI enabled and CONFIG_SPL_BUILD, declare
> > > plat to be .. and then if we do not have PCI enabled ...".  I really
> > > don't know what the code is supposed to be doing here.
> >
> > This is because the bdf member is only present in SPL when PCI is
> enabled.
> >
> > Perhaps it could be CONFIG_SPL instead of CONFIG_SPL_BUILD ?
> >
> > You can apply whatever makes it build if you like. I can look at it
> > either tonight or when I get back.
>
> Digging at this when you get back is fine since it still makes no sense
> to say "If PCI is enabled, when PCI is not enabled actually do
> something".  There's no side-effects on "dev" from the call to
> dev_get_plat which is the only thing that happens, in this case.
>
> --
> Tom
>


[PATCH v3 00/23] CONFIG_IS_ENABLED vs IS_ENABLED

2023-03-13 Thread Troy Kisky


This patch set gets ready to checks the usage of
CONFIG_IS_ENABLED/IS_ENABLED.

After the set has been applied, you can delete
test/usage_of_is_enabled_todo.txt
and run test/usage_of_is_enabled_commit.sh

The script test/usage_of_is_enabled_check.sh
checks for new questionable uses of
CONFIG_IS_ENABLED/IS_ENABLED and is added
to .azure-pipelines.yml, and
.gitlab-ci.yml

version 3 changes:
Dropped changes to puma-rk3399 and ringneck-px30
in favor of Quentin Schulz's patch
https://patchwork.ozlabs.org/project/uboot/patch/20230301-tsd-env-nowhere-kconfig-v1-1-d5c08e096...@theobroma-systems.com/
https://patchwork.ozlabs.org/project/uboot/patch/20230301-tsd-env-nowhere-kconfig-v1-2-d5c08e096...@theobroma-systems.com/
Please apply them before this series.

Drop gateworks: venice: Always define setup_fec and setup_eqos
Drop arm: cpu: armv7: ls102xa: fdt: remove eth_device support
Simon's patches took care of these

Add to todo list, these new questionable uses that snuck into the code.
PARTITION_TYPE_GUID
PHY_ATHEROS
RTC_SANDBOX

Changes in v3:
remove error entirely and prevent with Kconfig
new patch to address Tom's concerns
- Rebase on Simon's s/CMD_SATA/SATA/ change
- commit message updated

Changes in v2:
- new patch
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon
- include linux/kconfig.h from tools/Makefile
- as suggested by Simon
- changed condition of when to include field bdf
- added protection to another instance of bdf in uart.c
- Thanks to Simon for getting this corrected
- use normal if, not preprocessor
- new in series
- use an accessor function gd_set_pci_ram_top

Troy Kisky (23):
  kconfig: add IS_ENABLED_NOCHECK to bypass usage_of_is_enabled_check
  cmd: nvedit: remove error check, handle with Kconfig
  lib: crc32: prepare for CONFIG_IS_ENABLED changes
  lib: md5: prepare for CONFIG_IS_ENABLED changes
  lib: sha1: prepare for CONFIG_IS_ENABLED changes
  lib: sha256: prepare for CONFIG_IS_ENABLED changes
  lib: sha512: prepare for CONFIG_IS_ENABLED changes
  watchdog: add and use Kconfig HAS_WATCHDOG_RUNNING
  tools: prevent CONFIG_IS_ENABLED errors by including linux/kconfig.h
  tools: Makefile: prepare for CONFIG_IS_ENABLED changes by adding
CONFIG_TOOLS_xxx
  x86: cpu: qemu: qemu: remove SPL use with CONFIG_IS_ENABLED
  config_distro_bootcmd: remove booting environment variables from SPL
environment
  ofnode: fdt_support definitions needed if OF_CONTROL is enabled
  fdt_support: always define fdt_fixup_mtdparts
  m53menlo: define ft_board_setup only if CONFIG_IS_ENABLED(OF_LIBFDT)
  freescale: common: pfuze: define pfuze_mode_init only if
defined(CONFIG_DM_PMIC)
  ns16550: match when to define bdf with uart code
  solidrun: mx6cuboxi: use CONFIG_IS_ENABLED(SATA) instead of ifdef
CONFIG_SATA
  wandboard: use CONFIG_IS_ENABLED(SATA) instead of ifdef CONFIG_SATA
  arm: mach-imx: use CONFIG_$(SPL_)SATA instead of CONFIG_SATA
  x86: cpu: i386: cpu: only set pci_ram_top if CONFIG_IS_ENABLED(PCI)
  power: pmic: add dm style definitions if not
CONFIG_IS_ENABLED(POWER_LEGACY)
  CI: add test/usage_of_is_enabled_check.sh

 .azure-pipelines.yml |  11 ++
 .gitlab-ci.yml   |   5 +
 arch/arm/mach-imx/Makefile   |   2 +-
 arch/arm/mach-omap2/boot-common.c|   5 +-
 arch/m68k/lib/time.c |   7 +-
 arch/powerpc/lib/interrupts.c|   5 +-
 arch/powerpc/lib/ticks.S |   2 +-
 arch/x86/cpu/apollolake/uart.c   |   4 +
 arch/x86/cpu/i386/cpu.c  |   2 +-
 arch/x86/cpu/qemu/qemu.c |   2 +-
 board/astro/mcf5373l/fpga.c  |  10 +-
 board/freescale/common/pfuze.c   |   2 +-
 board/menlo/m53menlo/m53menlo.c  |   2 +
 board/solidrun/mx6cuboxi/mx6cuboxi.c |   5 +-
 board/wandboard/wandboard.c  |   5 +-
 boot/image-board.c   |   2 +-
 cmd/nvedit.c |  32 +---
 cmd/ximg.c   |  10 +-
 common/board_f.c |   4 +-
 common/spl/Kconfig   |   4 +
 drivers/crypto/aspeed/aspeed_hace.c  |   2 +-
 drivers/crypto/hash/hash_sw.c|   2 +-
 drivers/timer/mpc83xx_timer.c|   5 +-
 drivers/watchdog/Kconfig |   3 +
 env/Kconfig  |  17 ++-
 fs/cramfs/uncompress.c   |   9 +-
 include/asm-generic/global_data.h|   6 +
 include/config_distro_bootcmd.h  |  23 +++
 include/fdt_support.h|  26 ++--
 include/linux/kconfig.h  |   5 +
 include/ns16550.h 

[PATCH v3 20/23] arm: mach-imx: use CONFIG_$(SPL_)SATA instead of CONFIG_SATA

2023-03-13 Thread Troy Kisky
This avoid an error with enable_sata_clock when
defined(CONFIG_SATA) is changed to CONFIG_IS_ENABLED(SATA).

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 arch/arm/mach-imx/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 4dfc60eedc4..50f26975eac 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -54,7 +54,7 @@ obj-$(CONFIG_IMX_RDC) += rdc-sema.o
 ifneq ($(CONFIG_SPL_BUILD),y)
 obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
 endif
-obj-$(CONFIG_SATA) += sata.o
+obj-$(CONFIG_$(SPL_)SATA) += sata.o
 obj-$(CONFIG_IMX_HAB)+= hab.o
 obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
 endif
-- 
2.34.1



[PATCH v3 23/23] CI: add test/usage_of_is_enabled_check.sh

2023-03-13 Thread Troy Kisky
Add script usage_of_is_enabled_check to print any configs that
use CONFIG_IS_ENABLED instead of IS_ENABLED and vice versa.

Add usage_of_is_enabled_commit.sh to generate commits to fix the above
issues.

You can remove entries from test/usage_of_is_enabled_todo.txt
or the entire file and then run
test/usage_of_is_enabled_commit.sh
to convert to suggested usage of CONFIG_IS_ENABLED/IS_ENABLED

or run test/usage_of_is_enabled_check.sh to
see which configs are still todo.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 .azure-pipelines.yml|  11 ++
 .gitlab-ci.yml  |   5 +
 test/usage_of_is_enabled_check.sh   |  19 +++
 test/usage_of_is_enabled_commit.sh  |  12 ++
 test/usage_of_is_enabled_correct.sh |  50 +++
 test/usage_of_is_enabled_exempt.txt |   9 ++
 test/usage_of_is_enabled_list.sh|  86 +++
 test/usage_of_is_enabled_splcfg.txt |  21 +++
 test/usage_of_is_enabled_todo.txt   | 213 
 9 files changed, 426 insertions(+)
 create mode 100755 test/usage_of_is_enabled_check.sh
 create mode 100755 test/usage_of_is_enabled_commit.sh
 create mode 100755 test/usage_of_is_enabled_correct.sh
 create mode 100644 test/usage_of_is_enabled_exempt.txt
 create mode 100755 test/usage_of_is_enabled_list.sh
 create mode 100644 test/usage_of_is_enabled_splcfg.txt
 create mode 100644 test/usage_of_is_enabled_todo.txt

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 61ada4d681f..a9764006bc3 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -67,6 +67,17 @@ stages:
   :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
   :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+  - job: check_usage_of_is_enabled
+displayName: 'Check usage of CONFIG_IS_ENABLED vs IS_ENABLED'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  # generate list of SPL configs
+  - script: test/usage_of_is_enabled_check.sh
+
   - job: cppcheck
 displayName: 'Static code analysis with cppcheck'
 pool:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a89138701dc..b56446e6174 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -137,6 +137,11 @@ check for new CONFIG symbols outside Kconfig:
 :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
 :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+check usage of CONFIG_IS_ENABLED vs IS_ENABLED:
+  stage: testsuites
+  script:
+- ./test/usage_of_is_enabled_check.sh
+
 # QA jobs for code analytics
 # static code analysis with cppcheck (we can add --enable=all later)
 cppcheck:
diff --git a/test/usage_of_is_enabled_check.sh 
b/test/usage_of_is_enabled_check.sh
new file mode 100755
index 000..6bd5d9c1ac7
--- /dev/null
+++ b/test/usage_of_is_enabled_check.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+${scriptdir}/usage_of_is_enabled_list.sh | grep -vw FOO;
+if [ $? -eq 0 ] ; then
+   echo "The above may have incorrect usage of IS_ENABLED/"\
+"CONFIG_IS_ENABLED"
+   echo "Run test/usage_of_is_enabled_commit.sh and "\
+"squash with appropriate commit"
+   ret=1;
+else
+   ret=0;
+fi
+
+rm ${scriptdir}/splcfg.tmp ${scriptdir}/exclude.tmp
+exit ${ret}
diff --git a/test/usage_of_is_enabled_commit.sh 
b/test/usage_of_is_enabled_commit.sh
new file mode 100755
index 000..593dbd1428c
--- /dev/null
+++ b/test/usage_of_is_enabled_commit.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+${scriptdir}/usage_of_is_enabled_list.sh | \
+xargs -I {} sh -c "${scriptdir}/usage_of_is_enabled_correct.sh {}; \
+git commit -a -m\"CONFIG_{}: correct usage of CONFIG_IS_ENABLED/IS_ENABLED\";"
+
+
+rm ${scriptdir}/splcfg.tmp ${scriptdir}/exclude.tmp
diff --git a/test/usage_of_is_enabled_correct.sh 
b/test/usage_of_is_enabled_correct.sh
new file mode 100755
index 000..8724747beed
--- /dev/null
+++ b/test/usage_of_is_enabled_correct.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+
+if [ -z "$1" ] ; then
+   echo missing config
+   exit 1;
+fi
+if [ ! -f "${scriptdir}/splcfg.tmp" ] ; then
+   echo missing splcfg.tmp
+   exit 1;
+fi
+
+
+grep -qw $1 ${scriptdir}/splcfg.tmp
+if [ $? -ne 0 ] ; then
+# not splcfg
+# change CONFIG_IS_ENABLED to IS_ENABLED
+git grep -l \
+-e "CONFIG_IS_ENABLED($1)" \
+ | \
+xargs -IFile sh -c \
+" \
+sed -i -E \"\
+s/CONFIG_IS_ENABLED\($1\)/IS_ENABLED\(CONFIG_$1\)/g; \
+\" File";
+else
+# splcfg
+# change IS_ENABLE

[PATCH v3 21/23] x86: cpu: i386: cpu: only set pci_ram_top if CONFIG_IS_ENABLED(PCI)

2023-03-13 Thread Troy Kisky
This avoids an error when ifdef CONFIG_PCI is changed to
if CONFIG_IS_ENABLED(PCI)

Signed-off-by: Troy Kisky 
---

(no changes since v2)

Changes in v2:
- use an accessor function gd_set_pci_ram_top

 arch/x86/cpu/i386/cpu.c   | 2 +-
 include/asm-generic/global_data.h | 6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/cpu/i386/cpu.c b/arch/x86/cpu/i386/cpu.c
index c7f6c5a013e..068670dfc41 100644
--- a/arch/x86/cpu/i386/cpu.c
+++ b/arch/x86/cpu/i386/cpu.c
@@ -415,7 +415,7 @@ int cpu_phys_address_size(void)
 /* Don't allow PCI region 3 to use memory in the 2-4GB memory hole */
 static void setup_pci_ram_top(void)
 {
-   gd->pci_ram_top = 0x8000U;
+   gd_set_pci_ram_top(0x8000U);
 }
 
 static void setup_mtrr(void)
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index 987fb66c17a..952e17b2c13 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -560,6 +560,12 @@ static_assert(sizeof(struct global_data) == GD_SIZE);
 #define gd_event_state()   NULL
 #endif
 
+#if CONFIG_IS_ENABLED(PCI)
+#define gd_set_pci_ram_top(val)gd->pci_ram_top = val
+#else
+#define gd_set_pci_ram_top(val)
+#endif
+
 /**
  * enum gd_flags - global data flags
  *
-- 
2.34.1



[PATCH v3 22/23] power: pmic: add dm style definitions if not CONFIG_IS_ENABLED(POWER_LEGACY)

2023-03-13 Thread Troy Kisky
This avoids an error in converting to CONFIG_IS_ENABLED(DM_PMIC).
Many boards SPL code needs these definitions to compile, even if
the functions are not linked.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 include/power/pmic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/power/pmic.h b/include/power/pmic.h
index 70f2709bd0b..636221692d0 100644
--- a/include/power/pmic.h
+++ b/include/power/pmic.h
@@ -86,7 +86,7 @@ struct pmic {
 #endif /* CONFIG_IS_ENABLED(POWER_LEGACY) */
 
 /* TODO: Change to CONFIG_IS_ENABLED(DM_PMIC) when SPL_DM_PMIC exists */
-#ifdef CONFIG_DM_PMIC
+#if defined(CONFIG_DM_PMIC) || !CONFIG_IS_ENABLED(POWER_LEGACY)
 /**
  * U-Boot PMIC Framework
  * =
-- 
2.34.1



[PATCH v3 19/23] wandboard: use CONFIG_IS_ENABLED(SATA) instead of ifdef CONFIG_SATA

2023-03-13 Thread Troy Kisky
Prepare for linking setup_sata only when CONFIG_SATA/CONFIG_SPL_SATA
is defined.

Signed-off-by: Troy Kisky 
---

(no changes since v2)

Changes in v2:
- new in series

 board/wandboard/wandboard.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/board/wandboard/wandboard.c b/board/wandboard/wandboard.c
index da995dd0f58..48914450a29 100644
--- a/board/wandboard/wandboard.c
+++ b/board/wandboard/wandboard.c
@@ -352,9 +352,8 @@ static void setup_display(void)
 int board_early_init_f(void)
 {
setup_iomux_uart();
-#ifdef CONFIG_SATA
-   setup_sata();
-#endif
+   if (CONFIG_IS_ENABLED(SATA))
+   setup_sata();
 
return 0;
 }
-- 
2.34.1



[PATCH v3 18/23] solidrun: mx6cuboxi: use CONFIG_IS_ENABLED(SATA) instead of ifdef CONFIG_SATA

2023-03-13 Thread Troy Kisky
Prepare for linking setup_sata only when CONFIG_SATA/CONFIG_SPL_SATA
is defined.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

Changes in v3:
- Rebase on Simon's s/CMD_SATA/SATA/ change
- commit message updated

Changes in v2:
- use normal if, not preprocessor

 board/solidrun/mx6cuboxi/mx6cuboxi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c 
b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index cb14c2f30c9..6fa5cf4d27d 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -275,9 +275,8 @@ int board_early_init_f(void)
 {
setup_iomux_uart();
 
-#ifdef CONFIG_SATA
-   setup_sata();
-#endif
+   if (CONFIG_IS_ENABLED(SATA))
+   setup_sata();
setup_fec();
 
return 0;
-- 
2.34.1



[PATCH v3 17/23] ns16550: match when to define bdf with uart code

2023-03-13 Thread Troy Kisky
When switching defined(CONFIG_PCI) to CONFIG_IS_ENABLED(PCI)
bdf is no longer accessible. So add preprocessor protection
to avoid access.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- changed condition of when to include field bdf
- added protection to another instance of bdf in uart.c
- Thanks to Simon for getting this corrected

 arch/x86/cpu/apollolake/uart.c | 4 
 include/ns16550.h  | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/cpu/apollolake/uart.c b/arch/x86/cpu/apollolake/uart.c
index a9362436000..878aa48ed76 100644
--- a/arch/x86/cpu/apollolake/uart.c
+++ b/arch/x86/cpu/apollolake/uart.c
@@ -79,10 +79,12 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
 
 static int apl_ns16550_probe(struct udevice *dev)
 {
+#if IS_ENABLED_NOCHECK(CONFIG_PCI) && defined(CONFIG_SPL_BUILD)
struct apl_ns16550_plat *plat = dev_get_plat(dev);
 
if (!CONFIG_IS_ENABLED(PCI))
apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
+#endif
 
return ns16550_serial_probe(dev);
 }
@@ -110,7 +112,9 @@ static int apl_ns16550_of_to_plat(struct udevice *dev)
ns.reg_offset = 0;
ns.clock = dtplat->clock_frequency;
ns.fcr = UART_FCR_DEFVAL;
+#if IS_ENABLED_NOCHECK(CONFIG_PCI) && defined(CONFIG_SPL_BUILD)
ns.bdf = pci_ofplat_get_devfn(dtplat->reg[0]);
+#endif
memcpy(plat, &ns, sizeof(ns));
 #else
int ret;
diff --git a/include/ns16550.h b/include/ns16550.h
index e7e68663d03..41b977b5b26 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -74,7 +74,7 @@ struct ns16550_plat {
int clock;
u32 fcr;
int flags;
-#if defined(CONFIG_PCI) && defined(CONFIG_SPL)
+#if IS_ENABLED_NOCHECK(CONFIG_PCI) && defined(CONFIG_SPL_BUILD)
int bdf;
 #endif
 };
-- 
2.34.1



[PATCH v3 16/23] freescale: common: pfuze: define pfuze_mode_init only if defined(CONFIG_DM_PMIC)

2023-03-13 Thread Troy Kisky
pfuze_mode_init calls pmic_reg_read which is only available from

obj-$(CONFIG_$(SPL_TPL_)DM_PMIC) += pmic-uclass.o

Prepare for conversion of defined(CONFIG_DM_PMIC) to
CONFIG_IS_ENABLED(DM_PMIC).

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 board/freescale/common/pfuze.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/freescale/common/pfuze.c b/board/freescale/common/pfuze.c
index 6dca22960bf..a9288820b2e 100644
--- a/board/freescale/common/pfuze.c
+++ b/board/freescale/common/pfuze.c
@@ -91,7 +91,7 @@ struct pmic *pfuze_common_init(unsigned char i2cbus)
 
return p;
 }
-#else
+#elif defined(CONFIG_DM_PMIC)
 int pfuze_mode_init(struct udevice *dev, u32 mode)
 {
unsigned char offset, i, switch_num;
-- 
2.34.1



[PATCH v3 14/23] fdt_support: always define fdt_fixup_mtdparts

2023-03-13 Thread Troy Kisky
SPL code wants fdt_fixup_mtdparts defined as a NOP
when the function isn't linked in.

Prepare for ifdef CONFIG_OF_LIBFDT being converted to
 if CONFIG_IS_ENABLED(OF_LIBFDT)

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 include/fdt_support.h | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/include/fdt_support.h b/include/fdt_support.h
index eeb83e6251d..94497d755a3 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -245,16 +245,6 @@ int fdt_increase_size(void *fdt, int add_len);
 int fdt_delete_disabled_nodes(void *blob);
 
 struct node_info;
-#if defined(CONFIG_FDT_FIXUP_PARTITIONS)
-void fdt_fixup_mtdparts(void *fdt, const struct node_info *node_info,
-   int node_info_size);
-#else
-static inline void fdt_fixup_mtdparts(void *fdt,
- const struct node_info *node_info,
- int node_info_size)
-{
-}
-#endif
 
 void fdt_del_node_and_alias(void *blob, const char *alias);
 
@@ -412,6 +402,19 @@ int fdt_get_cells_len(const void *blob, char 
*nr_cells_name);
 
 #endif /* ifdef CONFIG_OF_LIBFDT */
 
+#if CONFIG_IS_ENABLED(OF_LIBFDT) && defined(CONFIG_FDT_FIXUP_PARTITIONS)
+struct node_info;
+void fdt_fixup_mtdparts(void *fdt, const struct node_info *node_info,
+   int node_info_size);
+#else
+struct node_info;
+static inline void fdt_fixup_mtdparts(void *fdt,
+ const struct node_info *node_info,
+ int node_info_size)
+{
+}
+#endif
+
 #ifdef USE_HOSTCC
 int fdtdec_get_int(const void *blob, int node, const char *prop_name,
int default_val);
-- 
2.34.1



[PATCH v3 15/23] m53menlo: define ft_board_setup only if CONFIG_IS_ENABLED(OF_LIBFDT)

2023-03-13 Thread Troy Kisky
The function ft_board_setup calls do_fixup_by_path_string
which is only available on CONFIG_IS_ENABLED(OF_LIBFDT).
This prepares for the conversion.

ft_board_setup is only called from image-fdt which is linked by
obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 board/menlo/m53menlo/m53menlo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/board/menlo/m53menlo/m53menlo.c b/board/menlo/m53menlo/m53menlo.c
index 14324c7087d..ca3b81c57ff 100644
--- a/board/menlo/m53menlo/m53menlo.c
+++ b/board/menlo/m53menlo/m53menlo.c
@@ -264,6 +264,7 @@ void board_preboot_os(void)
gpio_direction_output(IMX_GPIO_NR(6, 0), 0);
 }
 
+#if CONFIG_IS_ENABLED(OF_LIBFDT)
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
if (lvds_compat_string)
@@ -272,6 +273,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 
return 0;
 }
+#endif
 
 struct display_info_t const displays[] = {
{
-- 
2.34.1



[PATCH v3 13/23] ofnode: fdt_support definitions needed if OF_CONTROL is enabled

2023-03-13 Thread Troy Kisky
With the use of CONFIG_IS_ENABLED in code, instead of at the preprocessor
level, these defines are still needed if OF_CONTROL is enabled.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 include/fdt_support.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/fdt_support.h b/include/fdt_support.h
index 5638bd4f165..eeb83e6251d 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -7,7 +7,8 @@
 #ifndef __FDT_SUPPORT_H
 #define __FDT_SUPPORT_H
 
-#if defined(CONFIG_OF_LIBFDT) && !defined(USE_HOSTCC)
+#if (defined(CONFIG_OF_LIBFDT) || defined(CONFIG_OF_CONTROL)) && \
+   !defined(USE_HOSTCC)
 
 #include 
 #include 
-- 
2.34.1



[PATCH v3 12/23] config_distro_bootcmd: remove booting environment variables from SPL environment

2023-03-13 Thread Troy Kisky
SPL environments don't need commands that they can never use.
Avoid errors with CONFIG_IS_ENABLED conversions by skipping them now.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 include/config_distro_bootcmd.h | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 9d2a225e7eb..2a136b96a6d 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -35,11 +35,15 @@
#devtypel "_boot=" \
BOOTENV_SHARED_BLKDEV_BODY(devtypel)
 
+#define BOOTENV_DEV_BLKDEV_NONE(devtypeu, devtypel, instance)
+
 #define BOOTENV_DEV_BLKDEV(devtypeu, devtypel, instance) \
"bootcmd_" #devtypel #instance "=" \
"devnum=" #instance "; " \
"run " #devtypel "_boot\0"
 
+#define BOOTENV_DEV_NAME_BLKDEV_NONE(devtypeu, devtypel, instance)
+
 #define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \
#devtypel #instance " "
 
@@ -59,6 +63,10 @@
 #define BOOTENV_SHARED_MMC BOOTENV_SHARED_BLKDEV(mmc)
 #define BOOTENV_DEV_MMCBOOTENV_DEV_BLKDEV
 #define BOOTENV_DEV_NAME_MMC   BOOTENV_DEV_NAME_BLKDEV
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_SHARED_MMC
+#define BOOTENV_DEV_MMCBOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_MMC   BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_SHARED_MMC
 #define BOOTENV_DEV_MMC \
@@ -190,6 +198,10 @@
 #define BOOTENV_SHARED_SATABOOTENV_SHARED_BLKDEV(sata)
 #define BOOTENV_DEV_SATA   BOOTENV_DEV_BLKDEV
 #define BOOTENV_DEV_NAME_SATA  BOOTENV_DEV_NAME_BLKDEV
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_SHARED_SATA
+#define BOOTENV_DEV_SATA   BOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_SATA  BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_SHARED_SATA
 #define BOOTENV_DEV_SATA \
@@ -293,6 +305,11 @@
BOOTENV_SHARED_BLKDEV_BODY(usb)
 #define BOOTENV_DEV_USBBOOTENV_DEV_BLKDEV
 #define BOOTENV_DEV_NAME_USB   BOOTENV_DEV_NAME_BLKDEV
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_RUN_NET_USB_START
+#define BOOTENV_SHARED_USB
+#define BOOTENV_DEV_USBBOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_USB   BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_RUN_NET_USB_START
 #define BOOTENV_SHARED_USB
@@ -395,6 +412,9 @@
"\0"
 #define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \
"dhcp "
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_DEV_DHCP   BOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_DHCP  BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_DEV_DHCP \
BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP
@@ -413,6 +433,9 @@
"fi\0"
 #define BOOTENV_DEV_NAME_PXE(devtypeu, devtypel, instance) \
"pxe "
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_DEV_PXEBOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_PXE   BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_DEV_PXE \
BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
-- 
2.34.1



[PATCH v3 11/23] x86: cpu: qemu: qemu: remove SPL use with CONFIG_IS_ENABLED

2023-03-13 Thread Troy Kisky
CONFIG_IS_ENABLED(SPL_X86_32BIT_INIT)
would check for CONFIG_SPL_SPL_X86_32BIT_INIT for SPL builds

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 arch/x86/cpu/qemu/qemu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/cpu/qemu/qemu.c b/arch/x86/cpu/qemu/qemu.c
index e54082df7f9..274978c023b 100644
--- a/arch/x86/cpu/qemu/qemu.c
+++ b/arch/x86/cpu/qemu/qemu.c
@@ -97,7 +97,7 @@ static void qemu_chipset_init(void)
}
 }
 
-#if !CONFIG_IS_ENABLED(SPL_X86_32BIT_INIT)
+#if CONFIG_IS_ENABLED(X86_32BIT_INIT)
 int arch_cpu_init(void)
 {
post_code(POST_CPU_INIT);
-- 
2.34.1



[PATCH v3 09/23] tools: prevent CONFIG_IS_ENABLED errors by including linux/kconfig.h

2023-03-13 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
Reviewed-by: Tom Rini 
---

(no changes since v2)

Changes in v2:
- include linux/kconfig.h from tools/Makefile
- as suggested by Simon

 tools/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/Makefile b/tools/Makefile
index e13effbb66a..5d6284e6451 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -298,6 +298,7 @@ endif # !LOGO_BMP
 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
 #
 HOST_EXTRACFLAGS += -include $(srctree)/include/compiler.h \
+   -include $(srctree)/include/linux/kconfig.h \
$(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
-I$(srctree)/scripts/dtc/libfdt \
-I$(srctree)/tools \
-- 
2.34.1



[PATCH v3 10/23] tools: Makefile: prepare for CONFIG_IS_ENABLED changes by adding CONFIG_TOOLS_xxx

2023-03-13 Thread Troy Kisky
CONFIG_IS_ENABLED(FIT_SIGNATURE) will check for
CONFIG_TOOLS_FIT_SIGNATURE. So define it now in preparation.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 tools/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/Makefile b/tools/Makefile
index 5d6284e6451..86f1b6b5049 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -162,8 +162,10 @@ ifdef CONFIG_TOOLS_LIBCRYPTO
 # This affects include/image.h, but including the board config file
 # is tricky, so manually define this options here.
 HOST_EXTRACFLAGS   += -DCONFIG_FIT_SIGNATURE
+HOST_EXTRACFLAGS   += -DCONFIG_TOOLS_FIT_SIGNATURE=1
 HOST_EXTRACFLAGS   += -DCONFIG_FIT_SIGNATURE_MAX_SIZE=0x
 HOST_EXTRACFLAGS   += -DCONFIG_FIT_CIPHER
+HOST_EXTRACFLAGS   += -DCONFIG_TOOLS_FIT_CIPHER=1
 endif
 
 # MXSImage needs LibSSL
-- 
2.34.1



[PATCH v3 08/23] watchdog: add and use Kconfig HAS_WATCHDOG_RUNNING

2023-03-13 Thread Troy Kisky
defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
is a common pattern. Create an new config symbol
HAS_WATCHDOG_RUNNING to express it.

Signed-off-by: Troy Kisky 
---

Changes in v3:
new patch to address Tom's concerns

 arch/arm/mach-omap2/boot-common.c   |  5 ++---
 arch/m68k/lib/time.c|  7 +++
 arch/powerpc/lib/interrupts.c   |  5 ++---
 arch/powerpc/lib/ticks.S|  2 +-
 board/astro/mcf5373l/fpga.c | 10 --
 boot/image-board.c  |  2 +-
 cmd/ximg.c  | 10 --
 common/board_f.c|  4 ++--
 common/spl/Kconfig  |  4 
 drivers/crypto/aspeed/aspeed_hace.c |  2 +-
 drivers/crypto/hash/hash_sw.c   |  2 +-
 drivers/timer/mpc83xx_timer.c   |  5 ++---
 drivers/watchdog/Kconfig|  3 +++
 fs/cramfs/uncompress.c  |  9 -
 include/watchdog.h  |  7 ++-
 lib/bzip2/bzlib.c   |  5 ++---
 lib/bzip2/bzlib_decompress.c| 20 
 lib/crc32.c |  2 +-
 lib/md5.c   |  2 +-
 lib/sha1.c  |  2 +-
 lib/sha256.c|  2 +-
 lib/sha512.c|  2 +-
 22 files changed, 51 insertions(+), 61 deletions(-)

diff --git a/arch/arm/mach-omap2/boot-common.c 
b/arch/arm/mach-omap2/boot-common.c
index 9a342a1bf95..928a4136781 100644
--- a/arch/arm/mach-omap2/boot-common.c
+++ b/arch/arm/mach-omap2/boot-common.c
@@ -302,9 +302,8 @@ void spl_board_init(void)
 #if defined(CONFIG_AM33XX) && defined(CONFIG_SPL_MUSB_NEW)
arch_misc_init();
 #endif
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-   hw_watchdog_init();
-#endif
+   if (CONFIG_IS_ENABLED(HAS_WATCHDOG_RUNNING))
+   hw_watchdog_init();
 #ifdef CONFIG_AM33XX
am33xx_spl_board_init();
 #endif
diff --git a/arch/m68k/lib/time.c b/arch/m68k/lib/time.c
index 2ce69088d94..4a9841667b7 100644
--- a/arch/m68k/lib/time.c
+++ b/arch/m68k/lib/time.c
@@ -70,11 +70,10 @@ void dtimer_interrupt(void *not_used)
timerp->ter = (DTIM_DTER_CAP | DTIM_DTER_REF);
timestamp++;
 
-   #if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG)
-   if (CFG_SYS_WATCHDOG_FREQ && (timestamp % 
(CFG_SYS_WATCHDOG_FREQ)) == 0) {
+   if (CONFIG_IS_ENABLED(HAS_WATCHDOG_RUNNING) &&
+   CFG_SYS_WATCHDOG_FREQ &&
+   !(timestamp % CFG_SYS_WATCHDOG_FREQ))
schedule();
-   }
-   #endif/* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */
return;
}
 }
diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c
index df312dfa28e..f76b2db9025 100644
--- a/arch/powerpc/lib/interrupts.c
+++ b/arch/powerpc/lib/interrupts.c
@@ -79,10 +79,9 @@ void timer_interrupt(struct pt_regs *regs)
 
timestamp++;
 
-#if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG)
-   if (CFG_SYS_WATCHDOG_FREQ && (timestamp % (CFG_SYS_WATCHDOG_FREQ)) == 0)
+   if (CONFIG_IS_ENABLED(HAS_WATCHDOG_RUNNING) &&
+   CFG_SYS_WATCHDOG_FREQ && !(timestamp % CFG_SYS_WATCHDOG_FREQ))
schedule();
-#endif/* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */
 
 #ifdef CONFIG_LED_STATUS
status_led_tick(timestamp);
diff --git a/arch/powerpc/lib/ticks.S b/arch/powerpc/lib/ticks.S
index 8647d77cc9a..dd9afe693df 100644
--- a/arch/powerpc/lib/ticks.S
+++ b/arch/powerpc/lib/ticks.S
@@ -41,7 +41,7 @@ wait_ticks:
addcr14, r4, r14/* Compute end time lower */
addze   r15, r3 /* and end time upper */
 
-#if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
+#if CONFIG_IS_ENABLED(HAS_WATCHDOG_RUNNING)
bl  schedule/* Trigger watchdog, if needed */
 #endif
 1: bl  get_ticks   /* Get current time */
diff --git a/board/astro/mcf5373l/fpga.c b/board/astro/mcf5373l/fpga.c
index f85737432b3..3e1f507cdfe 100644
--- a/board/astro/mcf5373l/fpga.c
+++ b/board/astro/mcf5373l/fpga.c
@@ -122,9 +122,8 @@ int altera_write_fn(const void *buf, size_t len, int flush, 
int cookie)
} while (i > 0);
 
if (bytecount % len_40 == 0) {
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-   schedule();
-#endif
+   if (CONFIG_IS_ENABLED(HAS_WATCHDOG_RUNNING))
+   schedule();
 #ifdef CONFIG_SYS_FPGA_PROG_FEEDBACK
putc('.');  /* let them know we are alive */
 #endif
@@ -342,9 +341,8 @@ int xilinx_fastwr_config_fn(void *buf, size_t len, int 
flush, int cookie)
val <<= 1;
}
if (bytecount % len_40 == 0) {
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONF

[PATCH v3 06/23] lib: sha256: prepare for CONFIG_IS_ENABLED changes

2023-03-13 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
don't pet the watchdog when USE_HOSTCC is defined.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon

 lib/sha256.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/sha256.c b/lib/sha256.c
index 4d26aea1c8c..8e1c3992674 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -8,6 +8,9 @@
 #ifndef USE_HOSTCC
 #include 
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#define PET_WDG
+#endif
 #else
 #include 
 #endif /* USE_HOSTCC */
@@ -276,7 +279,7 @@ void sha256_csum_wd(const unsigned char *input, unsigned 
int ilen,
unsigned char *output, unsigned int chunk_sz)
 {
sha256_context ctx;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end;
unsigned char *curr;
int chunk;
@@ -284,7 +287,7 @@ void sha256_csum_wd(const unsigned char *input, unsigned 
int ilen,
 
sha256_starts(&ctx);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = (unsigned char *)input;
end = input + ilen;
while (curr < end) {
-- 
2.34.1



[PATCH v3 07/23] lib: sha512: prepare for CONFIG_IS_ENABLED changes

2023-03-13 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
don't pet the watchdog when USE_HOSTCC is defined.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon

 lib/sha512.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/sha512.c b/lib/sha512.c
index fbe8d5f5bfe..a504281bf93 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -13,6 +13,9 @@
 #ifndef USE_HOSTCC
 #include 
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#define PET_WDG
+#endif
 #else
 #include 
 #endif /* USE_HOSTCC */
@@ -292,7 +295,7 @@ void sha384_csum_wd(const unsigned char *input, unsigned 
int ilen,
unsigned char *output, unsigned int chunk_sz)
 {
sha512_context ctx;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end;
unsigned char *curr;
int chunk;
@@ -300,7 +303,7 @@ void sha384_csum_wd(const unsigned char *input, unsigned 
int ilen,
 
sha384_starts(&ctx);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = (unsigned char *)input;
end = input + ilen;
while (curr < end) {
@@ -355,7 +358,7 @@ void sha512_csum_wd(const unsigned char *input, unsigned 
int ilen,
unsigned char *output, unsigned int chunk_sz)
 {
sha512_context ctx;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end;
unsigned char *curr;
int chunk;
@@ -363,7 +366,7 @@ void sha512_csum_wd(const unsigned char *input, unsigned 
int ilen,
 
sha512_starts(&ctx);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = (unsigned char *)input;
end = input + ilen;
while (curr < end) {
-- 
2.34.1



[PATCH v3 05/23] lib: sha1: prepare for CONFIG_IS_ENABLED changes

2023-03-13 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
don't pet the watchdog when USE_HOSTCC is defined.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon

 lib/sha1.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/sha1.c b/lib/sha1.c
index 8d074078934..cd5d7aead8d 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -19,6 +19,9 @@
 #ifndef USE_HOSTCC
 #include 
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#define PET_WDG
+#endif
 #else
 #include 
 #endif /* USE_HOSTCC */
@@ -328,14 +331,14 @@ void sha1_csum_wd(const unsigned char *input, unsigned 
int ilen,
  unsigned char *output, unsigned int chunk_sz)
 {
sha1_context ctx;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end, *curr;
int chunk;
 #endif
 
sha1_starts (&ctx);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = input;
end = input + ilen;
while (curr < end) {
-- 
2.34.1



[PATCH v3 04/23] lib: md5: prepare for CONFIG_IS_ENABLED changes

2023-03-13 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
don't pet the watchdog when USE_HOSTCC is defined.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon

 lib/md5.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/md5.c b/lib/md5.c
index 1636ab93661..20d5e87814b 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -29,7 +29,10 @@
 
 #ifndef USE_HOSTCC
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
 #include 
+#define PET_WDG
+#endif
 #endif /* USE_HOSTCC */
 #include 
 
@@ -288,14 +291,14 @@ md5_wd(const unsigned char *input, unsigned int len, 
unsigned char output[16],
unsigned int chunk_sz)
 {
struct MD5Context context;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end, *curr;
int chunk;
 #endif
 
MD5Init(&context);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = input;
end = input + len;
while (curr < end) {
-- 
2.34.1



[PATCH v3 02/23] cmd: nvedit: remove error check, handle with Kconfig

2023-03-13 Thread Troy Kisky
Avoid error messages when SPL,TPL,VPL build don't
have the environment options of the main build.
This is needed when defined(CONFIG_ENV_IS_IN_xxx) is changed
to CONFIG_IS_ENABLED(ENV_IS_IN_xxx).

Signed-off-by: Troy Kisky 
---

Changes in v3:
remove error entirely and prevent with Kconfig

 cmd/nvedit.c | 32 +---
 env/Kconfig  | 17 ++---
 2 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 7cbc3fd573a..96bbf1904b1 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -43,28 +43,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifdefined(CONFIG_ENV_IS_IN_EEPROM)|| \
-   defined(CONFIG_ENV_IS_IN_FLASH) || \
-   defined(CONFIG_ENV_IS_IN_MMC)   || \
-   defined(CONFIG_ENV_IS_IN_FAT)   || \
-   defined(CONFIG_ENV_IS_IN_EXT4)  || \
-   defined(CONFIG_ENV_IS_IN_NAND)  || \
-   defined(CONFIG_ENV_IS_IN_NVRAM) || \
-   defined(CONFIG_ENV_IS_IN_ONENAND)   || \
-   defined(CONFIG_ENV_IS_IN_SPI_FLASH) || \
-   defined(CONFIG_ENV_IS_IN_REMOTE)|| \
-   defined(CONFIG_ENV_IS_IN_UBI)
-
-#define ENV_IS_IN_DEVICE
-
-#endif
-
-#if!defined(ENV_IS_IN_DEVICE)  && \
-   !defined(CONFIG_ENV_IS_NOWHERE)
-# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|\
-NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
-#endif
-
 /*
  * Maximum expected input data size for import command
  */
@@ -596,7 +574,7 @@ static int do_env_edit(struct cmd_tbl *cmdtp, int flag, int 
argc,
 }
 #endif /* CONFIG_CMD_EDITENV */
 
-#if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE)
+#if defined(CONFIG_CMD_SAVEENV) && !IS_ENABLED(CONFIG_ENV_IS_DEFAULT)
 static int do_env_save(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[])
 {
@@ -1108,7 +1086,7 @@ static int do_env_info(struct cmd_tbl *cmdtp, int flag,
int eval_flags = 0;
int eval_results = 0;
bool quiet = false;
-#if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE)
+#if defined(CONFIG_CMD_SAVEENV) && !IS_ENABLED(CONFIG_ENV_IS_DEFAULT)
enum env_location loc;
 #endif
 
@@ -1151,7 +1129,7 @@ static int do_env_info(struct cmd_tbl *cmdtp, int flag,
 
/* evaluate whether environment can be persisted */
if (eval_flags & ENV_INFO_IS_PERSISTED) {
-#if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE)
+#if defined(CONFIG_CMD_SAVEENV) && !IS_ENABLED(CONFIG_ENV_IS_DEFAULT)
loc = env_get_location(ENVOP_SAVE, gd->env_load_prio);
if (ENVL_NOWHERE != loc && ENVL_UNKNOWN != loc) {
if (!quiet)
@@ -1232,7 +1210,7 @@ static struct cmd_tbl cmd_env_sub[] = {
 #if defined(CONFIG_CMD_RUN)
U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""),
 #endif
-#if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE)
+#if defined(CONFIG_CMD_SAVEENV) && !IS_ENABLED(CONFIG_ENV_IS_DEFAULT)
U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""),
 #if defined(CONFIG_CMD_ERASEENV)
U_BOOT_CMD_MKENT(erase, 1, 0, do_env_erase, "", ""),
@@ -1323,7 +1301,7 @@ static char env_help_text[] =
 #if defined(CONFIG_CMD_RUN)
"env run var [...] - run commands in an environment variable\n"
 #endif
-#if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE)
+#if defined(CONFIG_CMD_SAVEENV) && !IS_ENABLED(CONFIG_ENV_IS_DEFAULT)
"env save - save environment\n"
 #if defined(CONFIG_CMD_ERASEENV)
"env erase - erase environment\n"
diff --git a/env/Kconfig b/env/Kconfig
index 2bbe4c466a6..7342397e169 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -55,20 +55,23 @@ config ENV_MAX_ENTRIES
  be generous and should work in most cases. This setting can be used
  to tune behaviour; see lib/hashtable.c for details.
 
-config ENV_IS_NOWHERE
-   bool "Environment is not stored"
-   default y if !ENV_IS_IN_EEPROM && !ENV_IS_IN_EXT4 && \
+config ENV_IS_DEFAULT
+   def_bool y if !ENV_IS_IN_EEPROM && !ENV_IS_IN_EXT4 && \
 !ENV_IS_IN_FAT && !ENV_IS_IN_FLASH && \
 !ENV_IS_IN_MMC && !ENV_IS_IN_NAND && \
 !ENV_IS_IN_NVRAM && !ENV_IS_IN_ONENAND && \
 !ENV_IS_IN_REMOTE && !ENV_IS_IN_SPI_FLASH && \
 !ENV_IS_IN_UBI
+   select ENV_IS_NOWHERE
+
+config ENV_IS_NOWHERE
+   bool "Environment is not stored"
help
- Define this if you don't want to or can't have an environment stored
+ Define this if you don't care whether or not an environment is stored
 

[PATCH v3 03/23] lib: crc32: prepare for CONFIG_IS_ENABLED changes

2023-03-13 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
be more direct with using defined(USE_HOSTCC).

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon

 lib/crc32.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/crc32.c b/lib/crc32.c
index aa94d70ef3e..12c104c62a4 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -14,11 +14,14 @@
 #else
 #include 
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#define PET_WDG
+#endif
 #endif
 #include 
 #include 
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
 #include 
 #endif
 #include "u-boot/zlib.h"
@@ -84,7 +87,7 @@ static void __efi_runtime make_crc_table(void)
   }
   crc_table_empty = 0;
 }
-#elif !defined(CONFIG_ARM64_CRC32)
+#elif !defined(CONFIG_ARM64_CRC32) || defined(USE_HOSTCC)
 /* 
  * Table of CRC-32's of all single-byte values (made by make_crc_table)
  */
@@ -184,7 +187,7 @@ const uint32_t * ZEXPORT get_crc_table()
  */
 uint32_t __efi_runtime crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
 {
-#ifdef CONFIG_ARM64_CRC32
+#if defined(CONFIG_ARM64_CRC32) && !defined(USE_HOSTCC)
 crc = cpu_to_le32(crc);
 while (len--)
 crc = __builtin_aarch64_crc32b(crc, *buf++);
@@ -243,7 +246,7 @@ uint32_t __efi_runtime crc32(uint32_t crc, const Bytef *p, 
uInt len)
 uint32_t crc32_wd(uint32_t crc, const unsigned char *buf, uInt len,
  uInt chunk_sz)
 {
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end, *curr;
int chunk;
 
-- 
2.34.1



[PATCH v3 01/23] kconfig: add IS_ENABLED_NOCHECK to bypass usage_of_is_enabled_check

2023-03-13 Thread Troy Kisky
This is for use when a config with an SPL version needs to always
check the non-spl verion of the config. It avoids error messages
from CI test script usage_of_is_enabled_check.sh

Signed-off-by: Troy Kisky 
---

(no changes since v2)

Changes in v2:
- new patch

 include/linux/kconfig.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 2bc704e1104..19b71723ab3 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -27,6 +27,11 @@
  * 0 otherwise.
  */
 #define IS_ENABLED(option) config_enabled(option, 0)
+/*
+ * Using IS_ENABLED_NOCHECK instead of IS_ENABLED prevents
+ * complaints from test/usage_of_is_enabled_check.sh
+ */
+#define IS_ENABLED_NOCHECK(option) config_enabled(option, 0)
 
 /*
  * U-Boot add-on: Helper macros to reference to different macros (prefixed by
-- 
2.34.1



Re: [PATCH v2 02/26] cmd: nvedit: check for ENV_SUPPORT

2023-03-09 Thread Troy Kisky
On Thu, Mar 9, 2023 at 11:36 AM Tom Rini  wrote:

> On Thu, Mar 09, 2023 at 11:20:33AM -0800, Troy Kisky wrote:
> > On Wed, Mar 1, 2023 at 7:33 AM Tom Rini  wrote:
> >
> > > On Fri, Feb 24, 2023 at 10:10:23AM -0800, Troy Kisky wrote:
> > > > Avoid error messages when SPL,TPL,VPL build don't
> > > > have the environment options of the main build.
> > > > This is needed when defined(CONFIG_ENV_IS_IN_xxx) is changed
> > > > to CONFIG_IS_ENABLED(ENV_IS_IN_xxx).
> > > >
> > > > Signed-off-by: Troy Kisky 
> > > > Reviewed-by: Simon Glass 
> > > > ---
> > > >
> > > > (no changes since v1)
> > > >
> > > >  cmd/nvedit.c | 5 -
> > > >  1 file changed, 4 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> > > > index 7cbc3fd573a..ef0fe55431c 100644
> > > > --- a/cmd/nvedit.c
> > > > +++ b/cmd/nvedit.c
> > > > @@ -43,6 +43,7 @@
> > > >
> > > >  DECLARE_GLOBAL_DATA_PTR;
> > > >
> > > > +#if CONFIG_IS_ENABLED(ENV_SUPPORT)
> > > >  #if  defined(CONFIG_ENV_IS_IN_EEPROM)|| \
> > > >   defined(CONFIG_ENV_IS_IN_FLASH) || \
> > > >   defined(CONFIG_ENV_IS_IN_MMC)   || \
> > > > @@ -60,10 +61,12 @@ DECLARE_GLOBAL_DATA_PTR;
> > > >  #endif
> > > >
> > > >  #if  !defined(ENV_IS_IN_DEVICE)  && \
> > > > - !defined(CONFIG_ENV_IS_NOWHERE)
> > > > + !defined(CONFIG_ENV_IS_NOWHERE) && \
> > > > + !defined(CONFIG_VPL_BUILD)
> > > >  # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|\
> > > >  NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or
> CONFIG_ENV_IS_NOWHERE
> > > >  #endif
> > > > +#endif
> > >
> > > This is one of the #error messes that we no longer need with Kconfig,
> > > where we can ensure things happen. Maybe we can use def_bool y if ..
> > > instead of default y if ..., in the ENV_IS_NOWHERE choice ?
> > >
> > > --
> > > Tom
> > >
> >
> > Hi Tom
> >
> > There is some weirdness here
> > git grep -A1 CONFIG_ENV_IS_NOWHERE *
> [snip]
> > Should I force  CONFIG_ENV_IS_NOWHERE=n in these cases?
>
> No, we support more than one env location being enabled at a time, with
> nowhere being the location of last resort (at run time).
>
>
>
Okay, this help text is misleading then.

config ENV_IS_NOWHERE
bool "Environment is not stored"
default y if !ENV_IS_IN_EEPROM && !ENV_IS_IN_EXT4 && \
!ENV_IS_IN_FAT && !ENV_IS_IN_FLASH && \
!ENV_IS_IN_MMC && !ENV_IS_IN_NAND && \
!ENV_IS_IN_NVRAM && !ENV_IS_IN_ONENAND && \
!ENV_IS_IN_REMOTE && !ENV_IS_IN_SPI_FLASH && \
!ENV_IS_IN_UBI
help
 Define this if you don't want to or can't have an environment stored
 on a storage medium. In this case the environment will still exist
 while U-Boot is running, but once U-Boot exits it will not be
 stored. U-Boot will therefore always start up with a default
 environment.
__

Perhaps this is better ?

config ENV_IS_NOT_IN_DEVICE
def_bool y if !ENV_IS_IN_EEPROM && !ENV_IS_IN_EXT4 && \
!ENV_IS_IN_FAT && !ENV_IS_IN_FLASH && \
!ENV_IS_IN_MMC && !ENV_IS_IN_NAND && \
!ENV_IS_IN_NVRAM && !ENV_IS_IN_ONENAND && \
!ENV_IS_IN_REMOTE && !ENV_IS_IN_SPI_FLASH && \
!ENV_IS_IN_UBI
select ENV_IS_NOWHERE

config ENV_IS_NOWHERE
bool "Environment is not stored"
help
 Define this if you don't care whether or not an environment is stored
 on a storage medium. In this case the environment will still exist
 while U-Boot is running, but once U-Boot exits it may not be
 stored. If no other ENV_IS_IN_ is defined, U-Boot will always start up
 with a default  environment.

BR
Troy


Re: [PATCH 2/2] rockchip: ringneck-px30: enforce ENV_IS_NOWHERE with Kconfig select

2023-03-09 Thread Troy Kisky
On Wed, Mar 1, 2023 at 9:39 AM Quentin Schulz  wrote:

> From: Quentin Schulz 
>
> Instead of letting the compiler error out if CONFIG_ENV_IS_NOWHERE is
> not selected by the user, let's just enforce it when the user builds for
> Ringneck PX30 so that no check needs to be performed by the compiler and
> the configuration is always valid.
>
> Suggested-by: Tom Rini 
> Cc: Quentin Schulz 
> Signed-off-by: Quentin Schulz 
> ---
>  board/theobroma-systems/ringneck_px30/Kconfig | 1 +
>  board/theobroma-systems/ringneck_px30/ringneck-px30.c | 4 
>  configs/ringneck-px30_defconfig   | 1 -
>  3 files changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/board/theobroma-systems/ringneck_px30/Kconfig
> b/board/theobroma-systems/ringneck_px30/Kconfig
> index 24d94807db8..c33253bdad8 100644
> --- a/board/theobroma-systems/ringneck_px30/Kconfig
> +++ b/board/theobroma-systems/ringneck_px30/Kconfig
> @@ -11,6 +11,7 @@ config SYS_CONFIG_NAME
>
>  config BOARD_SPECIFIC_OPTIONS # dummy
> def_bool y
> +   select ENV_IS_NOWHERE
>
>  config ENV_SIZE
> default 0x3000
> diff --git a/board/theobroma-systems/ringneck_px30/ringneck-px30.c
> b/board/theobroma-systems/ringneck_px30/ringneck-px30.c
> index 47d1a40ef7c..bb1bb4acf5c 100644
> --- a/board/theobroma-systems/ringneck_px30/ringneck-px30.c
> +++ b/board/theobroma-systems/ringneck_px30/ringneck-px30.c
> @@ -118,10 +118,6 @@ int mmc_get_env_dev(void)
> return CONFIG_SYS_MMC_ENV_DEV;
>  }
>
> -#if !IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
> -#error Please enable CONFIG_ENV_IS_NOWHERE
> -#endif
> -
>  enum env_location arch_env_get_location(enum env_operation op, int prio)
>  {
> const char *boot_device =
> diff --git a/configs/ringneck-px30_defconfig
> b/configs/ringneck-px30_defconfig
> index 91706d8def2..e9234efc2a0 100644
> --- a/configs/ringneck-px30_defconfig
> +++ b/configs/ringneck-px30_defconfig
> @@ -68,7 +68,6 @@ CONFIG_SPL_OF_CONTROL=y
>  CONFIG_OF_LIVE=y
>  CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent assigned-clocks
> assigned-clock-rates assigned-clock-parents"
>  CONFIG_ENV_OVERWRITE=y
> -CONFIG_ENV_IS_NOWHERE=y
>  CONFIG_ENV_IS_IN_MMC=y
>


Hi Quentin,

Should you delete the line
 CONFIG_ENV_IS_IN_MMC=y

as well ?

BR
Troy


Re: [PATCH v2 02/26] cmd: nvedit: check for ENV_SUPPORT

2023-03-09 Thread Troy Kisky
On Wed, Mar 1, 2023 at 7:33 AM Tom Rini  wrote:

> On Fri, Feb 24, 2023 at 10:10:23AM -0800, Troy Kisky wrote:
> > Avoid error messages when SPL,TPL,VPL build don't
> > have the environment options of the main build.
> > This is needed when defined(CONFIG_ENV_IS_IN_xxx) is changed
> > to CONFIG_IS_ENABLED(ENV_IS_IN_xxx).
> >
> > Signed-off-by: Troy Kisky 
> > Reviewed-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >  cmd/nvedit.c | 5 -
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> > index 7cbc3fd573a..ef0fe55431c 100644
> > --- a/cmd/nvedit.c
> > +++ b/cmd/nvedit.c
> > @@ -43,6 +43,7 @@
> >
> >  DECLARE_GLOBAL_DATA_PTR;
> >
> > +#if CONFIG_IS_ENABLED(ENV_SUPPORT)
> >  #if  defined(CONFIG_ENV_IS_IN_EEPROM)|| \
> >   defined(CONFIG_ENV_IS_IN_FLASH) || \
> >   defined(CONFIG_ENV_IS_IN_MMC)   || \
> > @@ -60,10 +61,12 @@ DECLARE_GLOBAL_DATA_PTR;
> >  #endif
> >
> >  #if  !defined(ENV_IS_IN_DEVICE)  && \
> > - !defined(CONFIG_ENV_IS_NOWHERE)
> > + !defined(CONFIG_ENV_IS_NOWHERE) && \
> > + !defined(CONFIG_VPL_BUILD)
> >  # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|\
> >  NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
> >  #endif
> > +#endif
>
> This is one of the #error messes that we no longer need with Kconfig,
> where we can ensure things happen. Maybe we can use def_bool y if ..
> instead of default y if ..., in the ENV_IS_NOWHERE choice ?
>
> --
> Tom
>

Hi Tom

There is some weirdness here
git grep -A1 CONFIG_ENV_IS_NOWHERE *

am62ax_evm_r5_defconfig:CONFIG_ENV_IS_NOWHERE=y
am62ax_evm_r5_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
aristainetos2c_defconfig:CONFIG_ENV_IS_NOWHERE=y
aristainetos2c_defconfig-CONFIG_ENV_IS_IN_SPI_FLASH=y
--
aristainetos2ccslb_defconfig:CONFIG_ENV_IS_NOWHERE=y
aristainetos2ccslb_defconfig-CONFIG_ENV_IS_IN_SPI_FLASH=y
--
imx6q_bosch_acc_defconfig:CONFIG_ENV_IS_NOWHERE=y
imx6q_bosch_acc_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
imx8mn_beacon_2g_defconfig:CONFIG_ENV_IS_NOWHERE=y
imx8mn_beacon_2g_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
imx8mn_beacon_defconfig:CONFIG_ENV_IS_NOWHERE=y
imx8mn_beacon_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
imx8mn_beacon_fspi_defconfig:CONFIG_ENV_IS_NOWHERE=y
imx8mn_beacon_fspi_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
imx8mp_dhcom_pdk2_defconfig:CONFIG_ENV_IS_NOWHERE=y
imx8mp_dhcom_pdk2_defconfig-CONFIG_ENV_IS_IN_SPI_FLASH=y
--
imx93_11x11_evk_defconfig:CONFIG_ENV_IS_NOWHERE=y
imx93_11x11_evk_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
imxrt1020-evk_defconfig:CONFIG_ENV_IS_NOWHERE=y
imxrt1020-evk_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
imxrt1050-evk_defconfig:CONFIG_ENV_IS_NOWHERE=y
imxrt1050-evk_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
imxrt1170-evk_defconfig:CONFIG_ENV_IS_NOWHERE=y
imxrt1170-evk_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
j721e_evm_a72_defconfig:CONFIG_ENV_IS_NOWHERE=y
j721e_evm_a72_defconfig-CONFIG_ENV_IS_IN_FAT=y
--
j721e_hs_evm_a72_defconfig:CONFIG_ENV_IS_NOWHERE=y
j721e_hs_evm_a72_defconfig-CONFIG_ENV_IS_IN_FAT=y
--
puma-rk3399_defconfig:CONFIG_ENV_IS_NOWHERE=y
puma-rk3399_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
ringneck-px30_defconfig:CONFIG_ENV_IS_NOWHERE=y
ringneck-px30_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
sandbox64_defconfig:CONFIG_ENV_IS_NOWHERE=y
sandbox64_defconfig-CONFIG_ENV_IS_IN_EXT4=y
--
sandbox_defconfig:CONFIG_ENV_IS_NOWHERE=y
sandbox_defconfig-CONFIG_ENV_IS_IN_EXT4=y
--
sandbox_flattree_defconfig:CONFIG_ENV_IS_NOWHERE=y
sandbox_flattree_defconfig-CONFIG_ENV_IS_IN_EXT4=y
--
sandbox_noinst_defconfig:CONFIG_ENV_IS_NOWHERE=y
sandbox_noinst_defconfig-CONFIG_ENV_IS_IN_EXT4=y
--
sandbox_spl_defconfig:CONFIG_ENV_IS_NOWHERE=y
sandbox_spl_defconfig-CONFIG_ENV_IS_IN_EXT4=y
--
sandbox_vpl_defconfig:CONFIG_ENV_IS_NOWHERE=y
sandbox_vpl_defconfig-CONFIG_ENV_IS_IN_EXT4=y
--
socrates_defconfig:CONFIG_ENV_IS_NOWHERE=y
socrates_defconfig-CONFIG_ENV_IS_IN_FLASH=y
--
stm32mp13_defconfig:CONFIG_ENV_IS_NOWHERE=y
stm32mp13_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
stm32mp15-icore-stm32mp1-ctouch2_defconfig:CONFIG_ENV_IS_NOWHERE=y
stm32mp15-icore-stm32mp1-ctouch2_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
stm32mp15-icore-stm32mp1-edimm2.2_defconfig:CONFIG_ENV_IS_NOWHERE=y
stm32mp15-icore-stm32mp1-edimm2.2_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
stm32mp15-microgea-stm32mp1-microdev2-of7_defconfig:CONFIG_ENV_IS_NOWHERE=y
stm32mp15-microgea-stm32mp1-microdev2-of7_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
stm32mp15-microgea-stm32mp1-microdev2_defconfig:CONFIG_ENV_IS_NOWHERE=y
stm32mp15-microgea-stm32mp1-microdev2_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
stm32mp15_basic_defconfig:CONFIG_ENV_IS_NOWHERE=y
stm32mp15_basic_defconfig-CONFIG_ENV_IS_IN_MMC=y
--
stm32mp15_defconfig:CONFIG_E

Re: [PATCH v2 09/26] tools: Makefile: prepare for CONFIG_IS_ENABLED changes by adding CONFIG_TOOLS_xxx

2023-03-02 Thread Troy Kisky
On Wed, Mar 1, 2023 at 7:33 AM Tom Rini  wrote:

> On Fri, Feb 24, 2023 at 10:10:30AM -0800, Troy Kisky wrote:
> > CONFIG_IS_ENABLED(FIT_SIGNATURE) will check for
> > CONFIG_TOOLS_FIT_SIGNATURE. So define it now in preparation.
> >
> > Signed-off-by: Troy Kisky 
> > Reviewed-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >  tools/Makefile | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/tools/Makefile b/tools/Makefile
> > index 5d6284e6451..86f1b6b5049 100644
> > --- a/tools/Makefile
> > +++ b/tools/Makefile
> > @@ -162,8 +162,10 @@ ifdef CONFIG_TOOLS_LIBCRYPTO
> >  # This affects include/image.h, but including the board config file
> >  # is tricky, so manually define this options here.
> >  HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE
> > +HOST_EXTRACFLAGS += -DCONFIG_TOOLS_FIT_SIGNATURE=1
> >  HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE_MAX_SIZE=0x
> >  HOST_EXTRACFLAGS += -DCONFIG_FIT_CIPHER
> > +HOST_EXTRACFLAGS += -DCONFIG_TOOLS_FIT_CIPHER=1
> >  endif
>
> Is the "=1" required here, as in we check the value of the define, not
> just that it is defined?
>
> --
> Tom
>

When it is converted to  CONFIG_IS_ENABLED it will require the =1
The CONFIG_IS_ENABLED logic counts the number of parameters and "empty
string" doesn't count.
I think it also compares to 1 somewhere in there.

BR
Troy


[PATCH v2 00/26] CONFIG_IS_ENABLED vs IS_ENABLED

2023-02-24 Thread Troy Kisky


This patch set gets ready to check the usage of
CONFIG_IS_ENABLED/IS_ENABLED.

After the set has been applied, you can delete
test/usage_of_is_enabled_todo.txt
and run test/usage_of_is_enabled_commit.sh

The script test/usage_of_is_enabled_check.sh
checks for new questionable uses of
CONFIG_IS_ENABLED/IS_ENABLED and is added
to .azure-pipelines.yml, and
.gitlab-ci.yml

Changes in v2:
- new patch
- delay include of linux/kconfig.h to do from Makefile
- include linux/kconfig.h from tools/Makefile
- as suggested by Simon
- keep #error, but change condition to use IS_ENABLED_NOCHECK
- keep #error, but change condition to use IS_ENABLED_NOCHECK
- changed condition of when to include field bdf
- added protection to another instance of bdf in uart.c
- Thanks to Simon for getting this corrected
- use normal if, not preprocessor
- new in series
- use an accessor function gd_set_pci_ram_top
- Always define function instead of using same protection

Troy Kisky (26):
  kconfig: add IS_ENABLED_NOCHECK to bypass usage_of_is_enabled_check
  cmd: nvedit: check for ENV_SUPPORT
  lib: crc32: prepare for CONFIG_IS_ENABLED changes
  lib: md5: prepare for CONFIG_IS_ENABLED changes
  lib: sha1: prepare for CONFIG_IS_ENABLED changes
  lib: sha256: prepare for CONFIG_IS_ENABLED changes
  lib: sha512: prepare for CONFIG_IS_ENABLED changes
  tools: prevent CONFIG_IS_ENABLED errors by including linux/kconfig.h
  tools: Makefile: prepare for CONFIG_IS_ENABLED changes by adding
CONFIG_TOOLS_xxx
  x86: cpu: qemu: qemu: remove SPL use with CONFIG_IS_ENABLED
  config_distro_bootcmd: remove booting environment variables from SPL
environment
  ofnode: fdt_support definitions needed if OF_CONTROL is enabled
  ringneck-px30: use IS_ENABLED_NOCHECK to avoid CI test failure for
ENV_IS_NOWHERE
  puma-rk3399: use IS_ENABLED_NOCHECK to avoid CI test failure for
ENV_IS_NOWHERE
  fdt_support: always define fdt_fixup_mtdparts
  m53menlo: define ft_board_setup only if CONFIG_IS_ENABLED(OF_LIBFDT)
  freescale: common: pfuze: define pfuze_mode_init only if
defined(CONFIG_DM_PMIC)
  ns16550: match when to define bdf with uart code
  solidrun: mx6cuboxi: use CONFIG_IS_ENABLED(SATA) instead of
CONFIG_CMD_SATA
  wandboard: use CONFIG_IS_ENABLED(SATA) instead of ifdef CONFIG_SATA
  arm: mach-imx: use CONFIG_$(SPL_)SATA instead of CONFIG_SATA
  x86: cpu: i386: cpu: only set pci_ram_top if CONFIG_IS_ENABLED(PCI)
  gateworks: venice: Always define setup_fec and setup_eqos
  power: pmic: add dm style definitions if not
CONFIG_IS_ENABLED(POWER_LEGACY)
  arm: cpu: armv7: ls102xa: fdt: remove eth_device support
  CI: add test/usage_of_is_enabled_check.sh

 .azure-pipelines.yml  |  11 +
 .gitlab-ci.yml|   5 +
 arch/arm/cpu/armv7/ls102xa/fdt.c  |  12 -
 arch/arm/mach-imx/Makefile|   2 +-
 arch/x86/cpu/apollolake/uart.c|   4 +
 arch/x86/cpu/i386/cpu.c   |   2 +-
 arch/x86/cpu/qemu/qemu.c  |   2 +-
 board/freescale/common/pfuze.c|   2 +-
 board/gateworks/venice/venice.c   |   2 +-
 board/menlo/m53menlo/m53menlo.c   |   2 +
 board/solidrun/mx6cuboxi/mx6cuboxi.c  |   5 +-
 .../puma_rk3399/puma-rk3399.c |   2 +-
 .../ringneck_px30/ringneck-px30.c |   2 +-
 board/wandboard/wandboard.c   |   5 +-
 cmd/nvedit.c  |   5 +-
 include/asm-generic/global_data.h |   6 +
 include/config_distro_bootcmd.h   |  23 ++
 include/fdt_support.h |  26 ++-
 include/linux/kconfig.h   |   5 +
 include/ns16550.h |   2 +-
 include/power/pmic.h  |   2 +-
 lib/crc32.c   |  11 +-
 lib/md5.c |   7 +-
 lib/sha1.c|   7 +-
 lib/sha256.c  |   7 +-
 lib/sha512.c  |  11 +-
 test/usage_of_is_enabled_check.sh |  19 ++
 test/usage_of_is_enabled_commit.sh|  12 +
 test/usage_of_is_enabled_correct.sh   |  50 +
 test/usage_of_is_enabled_exempt.txt   |   9 +
 test/usage_of_is_enabled_list.sh  |  86 +++
 test/usage_of_is_enabled_splcfg.txt   |  21 ++
 test/usage_of_is_enabled_todo.txt | 210 ++
 tools/Makefile|   3 +
 34 files changed, 527 insertions(+), 53 deletions(-)
 create mode 100755 test/usage_of_is_enabled_check.sh
 create mode 100755 test/usage_of_is_enabled_commit.sh
 create mode 100755 test/usage_of_is_enabled_correct.sh
 create mode 100644 test/usage_of_is_enabled_exempt.txt
 create mode 100755 test/usage_of_is_enabled_list.sh
 create mode 100644 test/usage_of_is_enabled_splcfg.txt
 create mode 100644

[PATCH v2 23/26] gateworks: venice: Always define setup_fec and setup_eqos

2023-02-24 Thread Troy Kisky
The compiler will optimize away base on IS_ENABLED(CONFIG_FEC_MXC).
It avoids an error in converting to CONFIG_IS_ENABLED(NET).

Signed-off-by: Troy Kisky 
---

Changes in v2:
- Always define function instead of using same protection

 board/gateworks/venice/venice.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/gateworks/venice/venice.c b/board/gateworks/venice/venice.c
index c4d86c26a9b..7a819e76a1c 100644
--- a/board/gateworks/venice/venice.c
+++ b/board/gateworks/venice/venice.c
@@ -41,7 +41,6 @@ int board_fit_config_name_match(const char *name)
return -1;
 }
 
-#if (IS_ENABLED(CONFIG_NET))
 static int setup_fec(void)
 {
struct iomuxc_gpr_base_regs *gpr =
@@ -71,6 +70,7 @@ static int setup_eqos(void)
return set_clk_eqos(ENET_125MHZ);
 }
 
+#if IS_ENABLED(CONFIG_NET)
 int board_phy_config(struct phy_device *phydev)
 {
unsigned short val;
-- 
2.34.1



[PATCH v2 19/26] solidrun: mx6cuboxi: use CONFIG_IS_ENABLED(SATA) instead of CONFIG_CMD_SATA

2023-02-24 Thread Troy Kisky
setup_sata is linked with
obj-$(CONFIG_SATA) += sata.o

So use SATA instead of CMD_SATA.

Signed-off-by: Troy Kisky 
---

Changes in v2:
- use normal if, not preprocessor

 board/solidrun/mx6cuboxi/mx6cuboxi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c 
b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 7c44379ec4a..6fa5cf4d27d 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -275,9 +275,8 @@ int board_early_init_f(void)
 {
setup_iomux_uart();
 
-#ifdef CONFIG_CMD_SATA
-   setup_sata();
-#endif
+   if (CONFIG_IS_ENABLED(SATA))
+   setup_sata();
setup_fec();
 
return 0;
-- 
2.34.1



[PATCH v2 24/26] power: pmic: add dm style definitions if not CONFIG_IS_ENABLED(POWER_LEGACY)

2023-02-24 Thread Troy Kisky
This avoids an error in converting to CONFIG_IS_ENABLED(DM_PMIC).
Many boards SPL code needs these definitions to compile, even if
the functions are not linked.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 include/power/pmic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/power/pmic.h b/include/power/pmic.h
index 70f2709bd0b..636221692d0 100644
--- a/include/power/pmic.h
+++ b/include/power/pmic.h
@@ -86,7 +86,7 @@ struct pmic {
 #endif /* CONFIG_IS_ENABLED(POWER_LEGACY) */
 
 /* TODO: Change to CONFIG_IS_ENABLED(DM_PMIC) when SPL_DM_PMIC exists */
-#ifdef CONFIG_DM_PMIC
+#if defined(CONFIG_DM_PMIC) || !CONFIG_IS_ENABLED(POWER_LEGACY)
 /**
  * U-Boot PMIC Framework
  * =
-- 
2.34.1



[PATCH v2 14/26] puma-rk3399: use IS_ENABLED_NOCHECK to avoid CI test failure for ENV_IS_NOWHERE

2023-02-24 Thread Troy Kisky
When usage_of_is_enabled_check.sh is added, this will show a false
positive for IS_ENABLED(CONFIG_ENV_IS_NOWHERE).
Use IS_ENABLED_NOCHECK to avoid check and error on SPL builds.

Signed-off-by: Troy Kisky 
---

Changes in v2:
- keep #error, but change condition to use IS_ENABLED_NOCHECK

 board/theobroma-systems/puma_rk3399/puma-rk3399.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c 
b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
index 97f398bd754..d1e3a544974 100644
--- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c
+++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
@@ -136,7 +136,7 @@ int mmc_get_env_dev(void)
return CONFIG_SYS_MMC_ENV_DEV;
 }
 
-#if !IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
+#if !IS_ENABLED_NOCHECK(CONFIG_ENV_IS_NOWHERE)
 #error Please enable CONFIG_ENV_IS_NOWHERE
 #endif
 
-- 
2.34.1



[PATCH v2 12/26] ofnode: fdt_support definitions needed if OF_CONTROL is enabled

2023-02-24 Thread Troy Kisky
With the use of CONFIG_IS_ENABLED in code, instead of at the preprocessor
level, these defines are still needed if OF_CONTROL is enabled.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 include/fdt_support.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/fdt_support.h b/include/fdt_support.h
index 5638bd4f165..eeb83e6251d 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -7,7 +7,8 @@
 #ifndef __FDT_SUPPORT_H
 #define __FDT_SUPPORT_H
 
-#if defined(CONFIG_OF_LIBFDT) && !defined(USE_HOSTCC)
+#if (defined(CONFIG_OF_LIBFDT) || defined(CONFIG_OF_CONTROL)) && \
+   !defined(USE_HOSTCC)
 
 #include 
 #include 
-- 
2.34.1



[PATCH v2 21/26] arm: mach-imx: use CONFIG_$(SPL_)SATA instead of CONFIG_SATA

2023-02-24 Thread Troy Kisky
This avoid an error with enable_sata_clock when
defined(CONFIG_SATA) is changed to CONFIG_IS_ENABLED(SATA).

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 arch/arm/mach-imx/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 4dfc60eedc4..50f26975eac 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -54,7 +54,7 @@ obj-$(CONFIG_IMX_RDC) += rdc-sema.o
 ifneq ($(CONFIG_SPL_BUILD),y)
 obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
 endif
-obj-$(CONFIG_SATA) += sata.o
+obj-$(CONFIG_$(SPL_)SATA) += sata.o
 obj-$(CONFIG_IMX_HAB)+= hab.o
 obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
 endif
-- 
2.34.1



[PATCH v2 15/26] fdt_support: always define fdt_fixup_mtdparts

2023-02-24 Thread Troy Kisky
SPL code wants fdt_fixup_mtdparts defined as a NOP
when the function isn't linked in.

Prepare for ifdef CONFIG_OF_LIBFDT being converted to
 if CONFIG_IS_ENABLED(OF_LIBFDT)

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 include/fdt_support.h | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/include/fdt_support.h b/include/fdt_support.h
index eeb83e6251d..94497d755a3 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -245,16 +245,6 @@ int fdt_increase_size(void *fdt, int add_len);
 int fdt_delete_disabled_nodes(void *blob);
 
 struct node_info;
-#if defined(CONFIG_FDT_FIXUP_PARTITIONS)
-void fdt_fixup_mtdparts(void *fdt, const struct node_info *node_info,
-   int node_info_size);
-#else
-static inline void fdt_fixup_mtdparts(void *fdt,
- const struct node_info *node_info,
- int node_info_size)
-{
-}
-#endif
 
 void fdt_del_node_and_alias(void *blob, const char *alias);
 
@@ -412,6 +402,19 @@ int fdt_get_cells_len(const void *blob, char 
*nr_cells_name);
 
 #endif /* ifdef CONFIG_OF_LIBFDT */
 
+#if CONFIG_IS_ENABLED(OF_LIBFDT) && defined(CONFIG_FDT_FIXUP_PARTITIONS)
+struct node_info;
+void fdt_fixup_mtdparts(void *fdt, const struct node_info *node_info,
+   int node_info_size);
+#else
+struct node_info;
+static inline void fdt_fixup_mtdparts(void *fdt,
+ const struct node_info *node_info,
+ int node_info_size)
+{
+}
+#endif
+
 #ifdef USE_HOSTCC
 int fdtdec_get_int(const void *blob, int node, const char *prop_name,
int default_val);
-- 
2.34.1



[PATCH v2 10/26] x86: cpu: qemu: qemu: remove SPL use with CONFIG_IS_ENABLED

2023-02-24 Thread Troy Kisky
CONFIG_IS_ENABLED(SPL_X86_32BIT_INIT)
would check for CONFIG_SPL_SPL_X86_32BIT_INIT for SPL builds

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 arch/x86/cpu/qemu/qemu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/cpu/qemu/qemu.c b/arch/x86/cpu/qemu/qemu.c
index e54082df7f9..274978c023b 100644
--- a/arch/x86/cpu/qemu/qemu.c
+++ b/arch/x86/cpu/qemu/qemu.c
@@ -97,7 +97,7 @@ static void qemu_chipset_init(void)
}
 }
 
-#if !CONFIG_IS_ENABLED(SPL_X86_32BIT_INIT)
+#if CONFIG_IS_ENABLED(X86_32BIT_INIT)
 int arch_cpu_init(void)
 {
post_code(POST_CPU_INIT);
-- 
2.34.1



[PATCH v2 18/26] ns16550: match when to define bdf with uart code

2023-02-24 Thread Troy Kisky
When switching defined(CONFIG_PCI) to CONFIG_IS_ENABLED(PCI)
bdf is no longer accessible. So add preprocessor protection
to avoid access.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

Changes in v2:
- changed condition of when to include field bdf
- added protection to another instance of bdf in uart.c
- Thanks to Simon for getting this corrected

 arch/x86/cpu/apollolake/uart.c | 4 
 include/ns16550.h  | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/cpu/apollolake/uart.c b/arch/x86/cpu/apollolake/uart.c
index a9362436000..878aa48ed76 100644
--- a/arch/x86/cpu/apollolake/uart.c
+++ b/arch/x86/cpu/apollolake/uart.c
@@ -79,10 +79,12 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
 
 static int apl_ns16550_probe(struct udevice *dev)
 {
+#if IS_ENABLED_NOCHECK(CONFIG_PCI) && defined(CONFIG_SPL_BUILD)
struct apl_ns16550_plat *plat = dev_get_plat(dev);
 
if (!CONFIG_IS_ENABLED(PCI))
apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
+#endif
 
return ns16550_serial_probe(dev);
 }
@@ -110,7 +112,9 @@ static int apl_ns16550_of_to_plat(struct udevice *dev)
ns.reg_offset = 0;
ns.clock = dtplat->clock_frequency;
ns.fcr = UART_FCR_DEFVAL;
+#if IS_ENABLED_NOCHECK(CONFIG_PCI) && defined(CONFIG_SPL_BUILD)
ns.bdf = pci_ofplat_get_devfn(dtplat->reg[0]);
+#endif
memcpy(plat, &ns, sizeof(ns));
 #else
int ret;
diff --git a/include/ns16550.h b/include/ns16550.h
index e7e68663d03..41b977b5b26 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -74,7 +74,7 @@ struct ns16550_plat {
int clock;
u32 fcr;
int flags;
-#if defined(CONFIG_PCI) && defined(CONFIG_SPL)
+#if IS_ENABLED_NOCHECK(CONFIG_PCI) && defined(CONFIG_SPL_BUILD)
int bdf;
 #endif
 };
-- 
2.34.1



[PATCH v2 26/26] CI: add test/usage_of_is_enabled_check.sh

2023-02-24 Thread Troy Kisky
Add script usage_of_is_enabled_check to print any configs that
use CONFIG_IS_ENABLED instead of IS_ENABLED and vice versa.

Add usage_of_is_enabled_commit.sh to generate commits to fix the above
issues.

You can remove entries from test/usage_of_is_enabled_todo.txt
or the entire file and then run
test/usage_of_is_enabled_commit.sh
to convert to suggested usage of CONFIG_IS_ENABLED/IS_ENABLED

or run test/usage_of_is_enabled_check.sh to
see which configs are still todo.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 .azure-pipelines.yml|  11 ++
 .gitlab-ci.yml  |   5 +
 test/usage_of_is_enabled_check.sh   |  19 +++
 test/usage_of_is_enabled_commit.sh  |  12 ++
 test/usage_of_is_enabled_correct.sh |  50 +++
 test/usage_of_is_enabled_exempt.txt |   9 ++
 test/usage_of_is_enabled_list.sh|  86 
 test/usage_of_is_enabled_splcfg.txt |  21 +++
 test/usage_of_is_enabled_todo.txt   | 210 
 9 files changed, 423 insertions(+)
 create mode 100755 test/usage_of_is_enabled_check.sh
 create mode 100755 test/usage_of_is_enabled_commit.sh
 create mode 100755 test/usage_of_is_enabled_correct.sh
 create mode 100644 test/usage_of_is_enabled_exempt.txt
 create mode 100755 test/usage_of_is_enabled_list.sh
 create mode 100644 test/usage_of_is_enabled_splcfg.txt
 create mode 100644 test/usage_of_is_enabled_todo.txt

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 8327edf87aa..3f216d82a7e 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -67,6 +67,17 @@ stages:
   :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
   :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+  - job: check_usage_of_is_enabled
+displayName: 'Check usage of CONFIG_IS_ENABLED vs IS_ENABLED'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  # generate list of SPL configs
+  - script: test/usage_of_is_enabled_check.sh
+
   - job: cppcheck
 displayName: 'Static code analysis with cppcheck'
 pool:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c3ceca2974d..57330060b82 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -137,6 +137,11 @@ check for new CONFIG symbols outside Kconfig:
 :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
 :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+check usage of CONFIG_IS_ENABLED vs IS_ENABLED:
+  stage: testsuites
+  script:
+- ./test/usage_of_is_enabled_check.sh
+
 # QA jobs for code analytics
 # static code analysis with cppcheck (we can add --enable=all later)
 cppcheck:
diff --git a/test/usage_of_is_enabled_check.sh 
b/test/usage_of_is_enabled_check.sh
new file mode 100755
index 000..6bd5d9c1ac7
--- /dev/null
+++ b/test/usage_of_is_enabled_check.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+${scriptdir}/usage_of_is_enabled_list.sh | grep -vw FOO;
+if [ $? -eq 0 ] ; then
+   echo "The above may have incorrect usage of IS_ENABLED/"\
+"CONFIG_IS_ENABLED"
+   echo "Run test/usage_of_is_enabled_commit.sh and "\
+"squash with appropriate commit"
+   ret=1;
+else
+   ret=0;
+fi
+
+rm ${scriptdir}/splcfg.tmp ${scriptdir}/exclude.tmp
+exit ${ret}
diff --git a/test/usage_of_is_enabled_commit.sh 
b/test/usage_of_is_enabled_commit.sh
new file mode 100755
index 000..593dbd1428c
--- /dev/null
+++ b/test/usage_of_is_enabled_commit.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+${scriptdir}/usage_of_is_enabled_list.sh | \
+xargs -I {} sh -c "${scriptdir}/usage_of_is_enabled_correct.sh {}; \
+git commit -a -m\"CONFIG_{}: correct usage of CONFIG_IS_ENABLED/IS_ENABLED\";"
+
+
+rm ${scriptdir}/splcfg.tmp ${scriptdir}/exclude.tmp
diff --git a/test/usage_of_is_enabled_correct.sh 
b/test/usage_of_is_enabled_correct.sh
new file mode 100755
index 000..8724747beed
--- /dev/null
+++ b/test/usage_of_is_enabled_correct.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+
+if [ -z "$1" ] ; then
+   echo missing config
+   exit 1;
+fi
+if [ ! -f "${scriptdir}/splcfg.tmp" ] ; then
+   echo missing splcfg.tmp
+   exit 1;
+fi
+
+
+grep -qw $1 ${scriptdir}/splcfg.tmp
+if [ $? -ne 0 ] ; then
+# not splcfg
+# change CONFIG_IS_ENABLED to IS_ENABLED
+git grep -l \
+-e "CONFIG_IS_ENABLED($1)" \
+ | \
+xargs -IFile sh -c \
+" \
+sed -i -E \"\
+s/CONFIG_IS_ENABLED\($1\)/IS_ENABLED\(CONFIG_$1\)/g; \
+\" File";
+else
+# splcfg
+# change

[PATCH v2 25/26] arm: cpu: armv7: ls102xa: fdt: remove eth_device support

2023-02-24 Thread Troy Kisky
commit e524f3a449f5 ("net: Remove eth_legacy.c")

removed struct eth_device
This prevents errors in the conversion to CONFIG_IS_ENABLED(DM_ETH).

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 arch/arm/cpu/armv7/ls102xa/fdt.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/arch/arm/cpu/armv7/ls102xa/fdt.c b/arch/arm/cpu/armv7/ls102xa/fdt.c
index 599b7e18ef3..a5c5c780ae8 100644
--- a/arch/arm/cpu/armv7/ls102xa/fdt.c
+++ b/arch/arm/cpu/armv7/ls102xa/fdt.c
@@ -25,11 +25,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void ft_fixup_enet_phy_connect_type(void *fdt)
 {
-#ifdef CONFIG_DM_ETH
struct udevice *dev;
-#else
-   struct eth_device *dev;
-#endif
struct tsec_private *priv;
const char *enet_path, *phy_path;
char enet[16];
@@ -37,12 +33,8 @@ void ft_fixup_enet_phy_connect_type(void *fdt)
int phy_node;
int i = 0;
uint32_t ph;
-#ifdef CONFIG_DM_ETH
char *name[3] = { "ethernet@2d1", "ethernet@2d5",
  "ethernet@2d9" };
-#else
-   char *name[3] = { "eTSEC1", "eTSEC2", "eTSEC3" };
-#endif
 
for (; i < ARRAY_SIZE(name); i++) {
dev = eth_get_dev_by_name(name[i]);
@@ -53,11 +45,7 @@ void ft_fixup_enet_phy_connect_type(void *fdt)
continue;
}
 
-#ifdef CONFIG_DM_ETH
priv = dev_get_priv(dev);
-#else
-   priv = dev->priv;
-#endif
if (priv->flags & TSEC_SGMII)
continue;
 
-- 
2.34.1



[PATCH v2 22/26] x86: cpu: i386: cpu: only set pci_ram_top if CONFIG_IS_ENABLED(PCI)

2023-02-24 Thread Troy Kisky
This avoids an error when ifdef CONFIG_PCI is changed to
if CONFIG_IS_ENABLED(PCI)

Signed-off-by: Troy Kisky 
---

Changes in v2:
- use an accessor function gd_set_pci_ram_top

 arch/x86/cpu/i386/cpu.c   | 2 +-
 include/asm-generic/global_data.h | 6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/cpu/i386/cpu.c b/arch/x86/cpu/i386/cpu.c
index c7f6c5a013e..068670dfc41 100644
--- a/arch/x86/cpu/i386/cpu.c
+++ b/arch/x86/cpu/i386/cpu.c
@@ -415,7 +415,7 @@ int cpu_phys_address_size(void)
 /* Don't allow PCI region 3 to use memory in the 2-4GB memory hole */
 static void setup_pci_ram_top(void)
 {
-   gd->pci_ram_top = 0x8000U;
+   gd_set_pci_ram_top(0x8000U);
 }
 
 static void setup_mtrr(void)
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index 987fb66c17a..952e17b2c13 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -560,6 +560,12 @@ static_assert(sizeof(struct global_data) == GD_SIZE);
 #define gd_event_state()   NULL
 #endif
 
+#if CONFIG_IS_ENABLED(PCI)
+#define gd_set_pci_ram_top(val)gd->pci_ram_top = val
+#else
+#define gd_set_pci_ram_top(val)
+#endif
+
 /**
  * enum gd_flags - global data flags
  *
-- 
2.34.1



[PATCH v2 17/26] freescale: common: pfuze: define pfuze_mode_init only if defined(CONFIG_DM_PMIC)

2023-02-24 Thread Troy Kisky
pfuze_mode_init calls pmic_reg_read which is only available from

obj-$(CONFIG_$(SPL_TPL_)DM_PMIC) += pmic-uclass.o

Prepare for conversion of defined(CONFIG_DM_PMIC) to
CONFIG_IS_ENABLED(DM_PMIC).

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 board/freescale/common/pfuze.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/freescale/common/pfuze.c b/board/freescale/common/pfuze.c
index 6dca22960bf..a9288820b2e 100644
--- a/board/freescale/common/pfuze.c
+++ b/board/freescale/common/pfuze.c
@@ -91,7 +91,7 @@ struct pmic *pfuze_common_init(unsigned char i2cbus)
 
return p;
 }
-#else
+#elif defined(CONFIG_DM_PMIC)
 int pfuze_mode_init(struct udevice *dev, u32 mode)
 {
unsigned char offset, i, switch_num;
-- 
2.34.1



[PATCH v2 16/26] m53menlo: define ft_board_setup only if CONFIG_IS_ENABLED(OF_LIBFDT)

2023-02-24 Thread Troy Kisky
The function ft_board_setup calls do_fixup_by_path_string
which is only available on CONFIG_IS_ENABLED(OF_LIBFDT).
This prepares for the conversion.

ft_board_setup is only called from image-fdt which is linked by
obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 board/menlo/m53menlo/m53menlo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/board/menlo/m53menlo/m53menlo.c b/board/menlo/m53menlo/m53menlo.c
index 14324c7087d..ca3b81c57ff 100644
--- a/board/menlo/m53menlo/m53menlo.c
+++ b/board/menlo/m53menlo/m53menlo.c
@@ -264,6 +264,7 @@ void board_preboot_os(void)
gpio_direction_output(IMX_GPIO_NR(6, 0), 0);
 }
 
+#if CONFIG_IS_ENABLED(OF_LIBFDT)
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
if (lvds_compat_string)
@@ -272,6 +273,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 
return 0;
 }
+#endif
 
 struct display_info_t const displays[] = {
{
-- 
2.34.1



[PATCH v2 13/26] ringneck-px30: use IS_ENABLED_NOCHECK to avoid CI test failure for ENV_IS_NOWHERE

2023-02-24 Thread Troy Kisky
When usage_of_is_enabled_check.sh is added, this will show a false
positive for IS_ENABLED(CONFIG_ENV_IS_NOWHERE).
Use IS_ENABLED_NOCHECK to avoid check and error on SPL builds.

Signed-off-by: Troy Kisky 
---

Changes in v2:
- keep #error, but change condition to use IS_ENABLED_NOCHECK

 board/theobroma-systems/ringneck_px30/ringneck-px30.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/theobroma-systems/ringneck_px30/ringneck-px30.c 
b/board/theobroma-systems/ringneck_px30/ringneck-px30.c
index 47d1a40ef7c..5b2e0c7d40f 100644
--- a/board/theobroma-systems/ringneck_px30/ringneck-px30.c
+++ b/board/theobroma-systems/ringneck_px30/ringneck-px30.c
@@ -118,7 +118,7 @@ int mmc_get_env_dev(void)
return CONFIG_SYS_MMC_ENV_DEV;
 }
 
-#if !IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
+#if !IS_ENABLED_NOCHECK(CONFIG_ENV_IS_NOWHERE)
 #error Please enable CONFIG_ENV_IS_NOWHERE
 #endif
 
-- 
2.34.1



[PATCH v2 20/26] wandboard: use CONFIG_IS_ENABLED(SATA) instead of ifdef CONFIG_SATA

2023-02-24 Thread Troy Kisky
Prepare for linking setup_sata only when CONFIG_SATA/CONFIG_SPL_SATA
is defined.

Signed-off-by: Troy Kisky 
---

Changes in v2:
- new in series

 board/wandboard/wandboard.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/board/wandboard/wandboard.c b/board/wandboard/wandboard.c
index da995dd0f58..48914450a29 100644
--- a/board/wandboard/wandboard.c
+++ b/board/wandboard/wandboard.c
@@ -352,9 +352,8 @@ static void setup_display(void)
 int board_early_init_f(void)
 {
setup_iomux_uart();
-#ifdef CONFIG_SATA
-   setup_sata();
-#endif
+   if (CONFIG_IS_ENABLED(SATA))
+   setup_sata();
 
return 0;
 }
-- 
2.34.1



[PATCH v2 11/26] config_distro_bootcmd: remove booting environment variables from SPL environment

2023-02-24 Thread Troy Kisky
SPL environments don't need commands that they can never use.
Avoid errors with CONFIG_IS_ENABLED conversions by skipping them now.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 include/config_distro_bootcmd.h | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 9d2a225e7eb..2a136b96a6d 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -35,11 +35,15 @@
#devtypel "_boot=" \
BOOTENV_SHARED_BLKDEV_BODY(devtypel)
 
+#define BOOTENV_DEV_BLKDEV_NONE(devtypeu, devtypel, instance)
+
 #define BOOTENV_DEV_BLKDEV(devtypeu, devtypel, instance) \
"bootcmd_" #devtypel #instance "=" \
"devnum=" #instance "; " \
"run " #devtypel "_boot\0"
 
+#define BOOTENV_DEV_NAME_BLKDEV_NONE(devtypeu, devtypel, instance)
+
 #define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \
#devtypel #instance " "
 
@@ -59,6 +63,10 @@
 #define BOOTENV_SHARED_MMC BOOTENV_SHARED_BLKDEV(mmc)
 #define BOOTENV_DEV_MMCBOOTENV_DEV_BLKDEV
 #define BOOTENV_DEV_NAME_MMC   BOOTENV_DEV_NAME_BLKDEV
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_SHARED_MMC
+#define BOOTENV_DEV_MMCBOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_MMC   BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_SHARED_MMC
 #define BOOTENV_DEV_MMC \
@@ -190,6 +198,10 @@
 #define BOOTENV_SHARED_SATABOOTENV_SHARED_BLKDEV(sata)
 #define BOOTENV_DEV_SATA   BOOTENV_DEV_BLKDEV
 #define BOOTENV_DEV_NAME_SATA  BOOTENV_DEV_NAME_BLKDEV
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_SHARED_SATA
+#define BOOTENV_DEV_SATA   BOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_SATA  BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_SHARED_SATA
 #define BOOTENV_DEV_SATA \
@@ -293,6 +305,11 @@
BOOTENV_SHARED_BLKDEV_BODY(usb)
 #define BOOTENV_DEV_USBBOOTENV_DEV_BLKDEV
 #define BOOTENV_DEV_NAME_USB   BOOTENV_DEV_NAME_BLKDEV
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_RUN_NET_USB_START
+#define BOOTENV_SHARED_USB
+#define BOOTENV_DEV_USBBOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_USB   BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_RUN_NET_USB_START
 #define BOOTENV_SHARED_USB
@@ -395,6 +412,9 @@
"\0"
 #define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \
"dhcp "
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_DEV_DHCP   BOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_DHCP  BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_DEV_DHCP \
BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP
@@ -413,6 +433,9 @@
"fi\0"
 #define BOOTENV_DEV_NAME_PXE(devtypeu, devtypel, instance) \
"pxe "
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_DEV_PXEBOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_PXE   BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_DEV_PXE \
BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
-- 
2.34.1



[PATCH v2 09/26] tools: Makefile: prepare for CONFIG_IS_ENABLED changes by adding CONFIG_TOOLS_xxx

2023-02-24 Thread Troy Kisky
CONFIG_IS_ENABLED(FIT_SIGNATURE) will check for
CONFIG_TOOLS_FIT_SIGNATURE. So define it now in preparation.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 tools/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/Makefile b/tools/Makefile
index 5d6284e6451..86f1b6b5049 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -162,8 +162,10 @@ ifdef CONFIG_TOOLS_LIBCRYPTO
 # This affects include/image.h, but including the board config file
 # is tricky, so manually define this options here.
 HOST_EXTRACFLAGS   += -DCONFIG_FIT_SIGNATURE
+HOST_EXTRACFLAGS   += -DCONFIG_TOOLS_FIT_SIGNATURE=1
 HOST_EXTRACFLAGS   += -DCONFIG_FIT_SIGNATURE_MAX_SIZE=0x
 HOST_EXTRACFLAGS   += -DCONFIG_FIT_CIPHER
+HOST_EXTRACFLAGS   += -DCONFIG_TOOLS_FIT_CIPHER=1
 endif
 
 # MXSImage needs LibSSL
-- 
2.34.1



[PATCH v2 08/26] tools: prevent CONFIG_IS_ENABLED errors by including linux/kconfig.h

2023-02-24 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

Changes in v2:
- include linux/kconfig.h from tools/Makefile
- as suggested by Simon

 tools/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/Makefile b/tools/Makefile
index e13effbb66a..5d6284e6451 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -298,6 +298,7 @@ endif # !LOGO_BMP
 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
 #
 HOST_EXTRACFLAGS += -include $(srctree)/include/compiler.h \
+   -include $(srctree)/include/linux/kconfig.h \
$(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
-I$(srctree)/scripts/dtc/libfdt \
-I$(srctree)/tools \
-- 
2.34.1



[PATCH v2 07/26] lib: sha512: prepare for CONFIG_IS_ENABLED changes

2023-02-24 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
don't pet the watchdog when USE_HOSTCC is defined.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

Changes in v2:
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon

 lib/sha512.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/sha512.c b/lib/sha512.c
index fbe8d5f5bfe..a504281bf93 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -13,6 +13,9 @@
 #ifndef USE_HOSTCC
 #include 
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#define PET_WDG
+#endif
 #else
 #include 
 #endif /* USE_HOSTCC */
@@ -292,7 +295,7 @@ void sha384_csum_wd(const unsigned char *input, unsigned 
int ilen,
unsigned char *output, unsigned int chunk_sz)
 {
sha512_context ctx;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end;
unsigned char *curr;
int chunk;
@@ -300,7 +303,7 @@ void sha384_csum_wd(const unsigned char *input, unsigned 
int ilen,
 
sha384_starts(&ctx);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = (unsigned char *)input;
end = input + ilen;
while (curr < end) {
@@ -355,7 +358,7 @@ void sha512_csum_wd(const unsigned char *input, unsigned 
int ilen,
unsigned char *output, unsigned int chunk_sz)
 {
sha512_context ctx;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end;
unsigned char *curr;
int chunk;
@@ -363,7 +366,7 @@ void sha512_csum_wd(const unsigned char *input, unsigned 
int ilen,
 
sha512_starts(&ctx);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = (unsigned char *)input;
end = input + ilen;
while (curr < end) {
-- 
2.34.1



[PATCH v2 04/26] lib: md5: prepare for CONFIG_IS_ENABLED changes

2023-02-24 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
don't pet the watchdog when USE_HOSTCC is defined.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

Changes in v2:
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon

 lib/md5.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/md5.c b/lib/md5.c
index 1636ab93661..20d5e87814b 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -29,7 +29,10 @@
 
 #ifndef USE_HOSTCC
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
 #include 
+#define PET_WDG
+#endif
 #endif /* USE_HOSTCC */
 #include 
 
@@ -288,14 +291,14 @@ md5_wd(const unsigned char *input, unsigned int len, 
unsigned char output[16],
unsigned int chunk_sz)
 {
struct MD5Context context;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end, *curr;
int chunk;
 #endif
 
MD5Init(&context);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = input;
end = input + len;
while (curr < end) {
-- 
2.34.1



[PATCH v2 05/26] lib: sha1: prepare for CONFIG_IS_ENABLED changes

2023-02-24 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
don't pet the watchdog when USE_HOSTCC is defined.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

Changes in v2:
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon

 lib/sha1.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/sha1.c b/lib/sha1.c
index 8d074078934..cd5d7aead8d 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -19,6 +19,9 @@
 #ifndef USE_HOSTCC
 #include 
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#define PET_WDG
+#endif
 #else
 #include 
 #endif /* USE_HOSTCC */
@@ -328,14 +331,14 @@ void sha1_csum_wd(const unsigned char *input, unsigned 
int ilen,
  unsigned char *output, unsigned int chunk_sz)
 {
sha1_context ctx;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end, *curr;
int chunk;
 #endif
 
sha1_starts (&ctx);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = input;
end = input + ilen;
while (curr < end) {
-- 
2.34.1



[PATCH v2 06/26] lib: sha256: prepare for CONFIG_IS_ENABLED changes

2023-02-24 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
don't pet the watchdog when USE_HOSTCC is defined.

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

Changes in v2:
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon

 lib/sha256.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/sha256.c b/lib/sha256.c
index 4d26aea1c8c..8e1c3992674 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -8,6 +8,9 @@
 #ifndef USE_HOSTCC
 #include 
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#define PET_WDG
+#endif
 #else
 #include 
 #endif /* USE_HOSTCC */
@@ -276,7 +279,7 @@ void sha256_csum_wd(const unsigned char *input, unsigned 
int ilen,
unsigned char *output, unsigned int chunk_sz)
 {
sha256_context ctx;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end;
unsigned char *curr;
int chunk;
@@ -284,7 +287,7 @@ void sha256_csum_wd(const unsigned char *input, unsigned 
int ilen,
 
sha256_starts(&ctx);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = (unsigned char *)input;
end = input + ilen;
while (curr < end) {
-- 
2.34.1



[PATCH v2 03/26] lib: crc32: prepare for CONFIG_IS_ENABLED changes

2023-02-24 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
be more direct with using defined(USE_HOSTCC).

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

Changes in v2:
- delay include of linux/kconfig.h to do from Makefile
- as suggested by Simon

 lib/crc32.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/crc32.c b/lib/crc32.c
index aa94d70ef3e..12c104c62a4 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -14,11 +14,14 @@
 #else
 #include 
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#define PET_WDG
+#endif
 #endif
 #include 
 #include 
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
 #include 
 #endif
 #include "u-boot/zlib.h"
@@ -84,7 +87,7 @@ static void __efi_runtime make_crc_table(void)
   }
   crc_table_empty = 0;
 }
-#elif !defined(CONFIG_ARM64_CRC32)
+#elif !defined(CONFIG_ARM64_CRC32) || defined(USE_HOSTCC)
 /* 
  * Table of CRC-32's of all single-byte values (made by make_crc_table)
  */
@@ -184,7 +187,7 @@ const uint32_t * ZEXPORT get_crc_table()
  */
 uint32_t __efi_runtime crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
 {
-#ifdef CONFIG_ARM64_CRC32
+#if defined(CONFIG_ARM64_CRC32) && !defined(USE_HOSTCC)
 crc = cpu_to_le32(crc);
 while (len--)
 crc = __builtin_aarch64_crc32b(crc, *buf++);
@@ -243,7 +246,7 @@ uint32_t __efi_runtime crc32(uint32_t crc, const Bytef *p, 
uInt len)
 uint32_t crc32_wd(uint32_t crc, const unsigned char *buf, uInt len,
  uInt chunk_sz)
 {
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end, *curr;
int chunk;
 
-- 
2.34.1



[PATCH v2 02/26] cmd: nvedit: check for ENV_SUPPORT

2023-02-24 Thread Troy Kisky
Avoid error messages when SPL,TPL,VPL build don't
have the environment options of the main build.
This is needed when defined(CONFIG_ENV_IS_IN_xxx) is changed
to CONFIG_IS_ENABLED(ENV_IS_IN_xxx).

Signed-off-by: Troy Kisky 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 cmd/nvedit.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 7cbc3fd573a..ef0fe55431c 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -43,6 +43,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if CONFIG_IS_ENABLED(ENV_SUPPORT)
 #ifdefined(CONFIG_ENV_IS_IN_EEPROM)|| \
defined(CONFIG_ENV_IS_IN_FLASH) || \
defined(CONFIG_ENV_IS_IN_MMC)   || \
@@ -60,10 +61,12 @@ DECLARE_GLOBAL_DATA_PTR;
 #endif
 
 #if!defined(ENV_IS_IN_DEVICE)  && \
-   !defined(CONFIG_ENV_IS_NOWHERE)
+   !defined(CONFIG_ENV_IS_NOWHERE) && \
+   !defined(CONFIG_VPL_BUILD)
 # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|\
 NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
 #endif
+#endif
 
 /*
  * Maximum expected input data size for import command
-- 
2.34.1



[PATCH v2 01/26] kconfig: add IS_ENABLED_NOCHECK to bypass usage_of_is_enabled_check

2023-02-24 Thread Troy Kisky
This is for use when a config with an SPL version needs to always
check the non-spl verion of the config. It avoids error messages
from CI test script usage_of_is_enabled_check.sh

Signed-off-by: Troy Kisky 
---

Changes in v2:
- new patch

 include/linux/kconfig.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 2bc704e1104..19b71723ab3 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -27,6 +27,11 @@
  * 0 otherwise.
  */
 #define IS_ENABLED(option) config_enabled(option, 0)
+/*
+ * Using IS_ENABLED_NOCHECK instead of IS_ENABLED prevents
+ * complaints from test/usage_of_is_enabled_check.sh
+ */
+#define IS_ENABLED_NOCHECK(option) config_enabled(option, 0)
 
 /*
  * U-Boot add-on: Helper macros to reference to different macros (prefixed by
-- 
2.34.1



Re: [PATCH v1 18/24] solidrun: mx6cuboxi: use CONFIG_IS_ENABLED(SATA) instead of CONFIG_CMD_SATA

2023-02-23 Thread Troy Kisky
On Wed, Feb 22, 2023 at 10:13 AM Troy Kisky 
wrote:

> On Wed, Feb 22, 2023 at 8:59 AM Tom Rini  wrote:
>
>> On Tue, Feb 21, 2023 at 05:38:15PM -0800, Troy Kisky wrote:
>>
>> > setup_sata is linked with
>> > obj-$(CONFIG_SATA) += sata.o
>> >
>> > So use SATA instead of CMD_SATA.
>> >
>> > Signed-off-by: Troy Kisky 
>> > ---
>> >
>> >  board/solidrun/mx6cuboxi/mx6cuboxi.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> b/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> > index 7c44379ec4a..e31a7e9552f 100644
>> > --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> > +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> > @@ -275,7 +275,7 @@ int board_early_init_f(void)
>> >  {
>> >   setup_iomux_uart();
>> >
>> > -#ifdef CONFIG_CMD_SATA
>> > +#if CONFIG_IS_ENABLED(SATA)
>> >   setup_sata();
>> >  #endif
>> >   setup_fec();
>>
>> Note that wandboard needs a similar fix.
>>
>> --
>> Tom
>>
>
> Hi Tom
>
> The commit script will change
> #ifdef CONFIG_SATA
>
> to
> #if CONFIG_IS_ENABLED(SATA)
>
> This series only changes things that the commit script won't.
>
> BR
> Troy
>

You are right Tom, wandboard is needed too as it uses SPL.
I don't know how it passed CI last time. But it didn't this time.

BR
Troy


Re: [PATCH v1 19/24] arm: mach-imx: use CONFIG_$(SPL_)SATA instead of CONFIG_SATA

2023-02-23 Thread Troy Kisky
On Wed, Feb 22, 2023 at 7:05 AM Tom Rini  wrote:

> On Tue, Feb 21, 2023 at 05:38:16PM -0800, Troy Kisky wrote:
>
> > This avoid an error with enable_sata_clock when
> > defined(CONFIG_SATA) is changed to CONFIG_IS_ENABLED(SATA).
> >
> > Signed-off-by: Troy Kisky 
> > ---
> >
> >  arch/arm/mach-imx/Makefile | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
> > index 4dfc60eedc4..50f26975eac 100644
> > --- a/arch/arm/mach-imx/Makefile
> > +++ b/arch/arm/mach-imx/Makefile
> > @@ -54,7 +54,7 @@ obj-$(CONFIG_IMX_RDC) += rdc-sema.o
> >  ifneq ($(CONFIG_SPL_BUILD),y)
> >  obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
> >  endif
> > -obj-$(CONFIG_SATA) += sata.o
> > +obj-$(CONFIG_$(SPL_)SATA) += sata.o
> >  obj-$(CONFIG_IMX_HAB)+= hab.o
> >  obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
> >  endif
>
> In that Simon thinks the $(SPL_) syntax here is ugly, lets just move
> this line in to the existing guard for non-SPL builds, with
> imx_bootaux.o.
>
> --
> Tom
>

Hi Tom

I don't think that does the same thing for mach-mvebu.

arch/arm/mach-mvebu/Kconfig-config MVEBU_SPL_BOOT_DEVICE_SATA
arch/arm/mach-mvebu/Kconfig-bool "SATA"
arch/arm/mach-mvebu/Kconfig:imply SPL_SATA

Shouldn't it be linked in SPL builds as well for that one?

BR
Troy


Re: [PATCH v1 05/24] lib: sha256: prepare for CONFIG_IS_ENABLED changes

2023-02-22 Thread Troy Kisky
OK, I'll try that.

BR
Troy


On Wed, Feb 22, 2023 at 1:20 PM Simon Glass  wrote:

> On Tue, 21 Feb 2023 at 18:38, Troy Kisky 
> wrote:
> >
> > We need to include  in order to include
> > files that use CONFIG_IS_ENABLED. TO prepare for that
> > don't pet the watchdog when USE_HOSTCC is defined.
> >
> > Signed-off-by: Troy Kisky 
> > ---
> >
> >  lib/sha256.c | 8 ++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
>
> Reviewed-by: Simon Glass 
>
> BTW it might be possible to use '-include linux/kconfig.h' in
> tools/Makefile like we do in Makefile
>


Re: [PATCH v1 17/24] ns16550: match when to define bdf with uart code

2023-02-22 Thread Troy Kisky
On Wed, Feb 22, 2023 at 12:41 PM Troy Kisky 
wrote:

>
>
>
>> How does this look ?
>>
>> diff --git a/arch/x86/cpu/apollolake/uart.c
>> b/arch/x86/cpu/apollolake/uart.c
>> index a9362436000..da184638cb9 100644
>> --- a/arch/x86/cpu/apollolake/uart.c
>> +++ b/arch/x86/cpu/apollolake/uart.c
>> @@ -79,10 +79,11 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
>>
>>  static int apl_ns16550_probe(struct udevice *dev)
>>  {
>> +#if defined(CONFIG_SPL) && IS_ENABLED_NOCHECK(CONFIG_PCI)
>> struct apl_ns16550_plat *plat = dev_get_plat(dev);
>>
>> -   if (!CONFIG_IS_ENABLED(PCI))
>> -   apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
>> +   apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
>> +#endif
>>
>> return ns16550_serial_probe(dev);
>>  }
>> @@ -110,7 +111,9 @@ static int apl_ns16550_of_to_plat(struct udevice *dev)
>> ns.reg_offset = 0;
>> ns.clock = dtplat->clock_frequency;
>> ns.fcr = UART_FCR_DEFVAL;
>> +#if defined(CONFIG_SPL) && IS_ENABLED_NOCHECK(CONFIG_PCI)
>> ns.bdf = pci_ofplat_get_devfn(dtplat->reg[0]);
>> +#endif
>> memcpy(plat, &ns, sizeof(ns));
>>  #else
>> int ret;
>> diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
>> index 2bc704e1104..d18c49686dd 100644
>> --- a/include/linux/kconfig.h
>> +++ b/include/linux/kconfig.h
>> @@ -27,6 +27,7 @@
>>   * 0 otherwise.
>>   */
>>  #define IS_ENABLED(option) config_enabled(option, 0)
>> +#define IS_ENABLED_NOCHECK(option) config_enabled(option, 0)
>>
>>  /*
>>   * U-Boot add-on: Helper macros to reference to different macros
>> (prefixed by
>> diff --git a/include/ns16550.h b/include/ns16550.h
>> index e7e68663d03..f416e67e68f 100644
>> --- a/include/ns16550.h
>> +++ b/include/ns16550.h
>> @@ -74,7 +74,7 @@ struct ns16550_plat {
>> int clock;
>> u32 fcr;
>> int flags;
>> -#if defined(CONFIG_PCI) && defined(CONFIG_SPL)
>> +#if IS_ENABLED_NOCHECK(CONFIG_PCI) && defined(CONFIG_SPL)
>> int bdf;
>>  #endif
>>  };
>>
>>
>
> Or maybe I should s/CONFIG_SPL/CONFIG_SPL_BUILD/  in these places ?
>

Or better
defined(CONFIG_SPL_BUILD) || defined(CONFIG_TPL_BUILD)

since Simon specified TPL use.

Thanks
Troy


Re: [PATCH v1 17/24] ns16550: match when to define bdf with uart code

2023-02-22 Thread Troy Kisky
On Wed, Feb 22, 2023 at 11:39 AM Troy Kisky 
wrote:

>
> On Wed, Feb 22, 2023 at 10:42 AM Troy Kisky 
> wrote:
>
>> On Wed, Feb 22, 2023 at 10:18 AM Tom Rini  wrote:
>>
>>> On Tue, Feb 21, 2023 at 05:38:14PM -0800, Troy Kisky wrote:
>>>
>>> > When switching defined(CONFIG_PCI) to CONFIG_IS_ENABLED(PCI)
>>> > bdf is no longer accessible. So change to preprocessor to avoid access.
>>> >
>>> > Signed-off-by: Troy Kisky 
>>> > ---
>>> >
>>> >  arch/x86/cpu/apollolake/uart.c | 6 +++---
>>> >  include/ns16550.h  | 2 +-
>>> >  2 files changed, 4 insertions(+), 4 deletions(-)
>>> >
>>> > diff --git a/arch/x86/cpu/apollolake/uart.c
>>> b/arch/x86/cpu/apollolake/uart.c
>>> > index a9362436000..143217755ff 100644
>>> > --- a/arch/x86/cpu/apollolake/uart.c
>>> > +++ b/arch/x86/cpu/apollolake/uart.c
>>> > @@ -79,11 +79,11 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
>>> >
>>> >  static int apl_ns16550_probe(struct udevice *dev)
>>> >  {
>>> > +#if !CONFIG_IS_ENABLED(PCI)
>>> >   struct apl_ns16550_plat *plat = dev_get_plat(dev);
>>> >
>>> > - if (!CONFIG_IS_ENABLED(PCI))
>>> > - apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
>>> > -
>>> > + apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
>>> > +#endif
>>> >   return ns16550_serial_probe(dev);
>>> >  }
>>> >
>>> > diff --git a/include/ns16550.h b/include/ns16550.h
>>> > index e7e68663d03..8d7eb7d8f9c 100644
>>> > --- a/include/ns16550.h
>>> > +++ b/include/ns16550.h
>>> > @@ -74,7 +74,7 @@ struct ns16550_plat {
>>> >   int clock;
>>> >   u32 fcr;
>>> >   int flags;
>>> > -#if defined(CONFIG_PCI) && defined(CONFIG_SPL)
>>> > +#if !CONFIG_IS_ENABLED(PCI) || CONFIG_IS_ENABLED(OF_PLATDATA)
>>> >   int bdf;
>>> >  #endif
>>> >  };
>>>
>>> This isn't equivalent.  This means platforms such as am335x_evm which do
>>> not enable PCI nor SPL_PCI now get this field and grow their rodata.
>>>
>>> --
>>> Tom
>>
>>
> How does this look ?
>
> diff --git a/arch/x86/cpu/apollolake/uart.c
> b/arch/x86/cpu/apollolake/uart.c
> index a9362436000..da184638cb9 100644
> --- a/arch/x86/cpu/apollolake/uart.c
> +++ b/arch/x86/cpu/apollolake/uart.c
> @@ -79,10 +79,11 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
>
>  static int apl_ns16550_probe(struct udevice *dev)
>  {
> +#if defined(CONFIG_SPL) && IS_ENABLED_NOCHECK(CONFIG_PCI)
> struct apl_ns16550_plat *plat = dev_get_plat(dev);
>
> -   if (!CONFIG_IS_ENABLED(PCI))
> -   apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
> +   apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
> +#endif
>
> return ns16550_serial_probe(dev);
>  }
> @@ -110,7 +111,9 @@ static int apl_ns16550_of_to_plat(struct udevice *dev)
> ns.reg_offset = 0;
> ns.clock = dtplat->clock_frequency;
> ns.fcr = UART_FCR_DEFVAL;
> +#if defined(CONFIG_SPL) && IS_ENABLED_NOCHECK(CONFIG_PCI)
> ns.bdf = pci_ofplat_get_devfn(dtplat->reg[0]);
> +#endif
> memcpy(plat, &ns, sizeof(ns));
>  #else
> int ret;
> diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
> index 2bc704e1104..d18c49686dd 100644
> --- a/include/linux/kconfig.h
> +++ b/include/linux/kconfig.h
> @@ -27,6 +27,7 @@
>   * 0 otherwise.
>   */
>  #define IS_ENABLED(option) config_enabled(option, 0)
> +#define IS_ENABLED_NOCHECK(option) config_enabled(option, 0)
>
>  /*
>   * U-Boot add-on: Helper macros to reference to different macros
> (prefixed by
> diff --git a/include/ns16550.h b/include/ns16550.h
> index e7e68663d03..f416e67e68f 100644
> --- a/include/ns16550.h
> +++ b/include/ns16550.h
> @@ -74,7 +74,7 @@ struct ns16550_plat {
> int clock;
> u32 fcr;
> int flags;
> -#if defined(CONFIG_PCI) && defined(CONFIG_SPL)
> +#if IS_ENABLED_NOCHECK(CONFIG_PCI) && defined(CONFIG_SPL)
> int bdf;
>  #endif
>  };
>
>

Or maybe I should s/CONFIG_SPL/CONFIG_SPL_BUILD/  in these places ?


Re: [PATCH v1 17/24] ns16550: match when to define bdf with uart code

2023-02-22 Thread Troy Kisky
On Wed, Feb 22, 2023 at 10:42 AM Troy Kisky 
wrote:

> On Wed, Feb 22, 2023 at 10:18 AM Tom Rini  wrote:
>
>> On Tue, Feb 21, 2023 at 05:38:14PM -0800, Troy Kisky wrote:
>>
>> > When switching defined(CONFIG_PCI) to CONFIG_IS_ENABLED(PCI)
>> > bdf is no longer accessible. So change to preprocessor to avoid access.
>> >
>> > Signed-off-by: Troy Kisky 
>> > ---
>> >
>> >  arch/x86/cpu/apollolake/uart.c | 6 +++---
>> >  include/ns16550.h  | 2 +-
>> >  2 files changed, 4 insertions(+), 4 deletions(-)
>> >
>> > diff --git a/arch/x86/cpu/apollolake/uart.c
>> b/arch/x86/cpu/apollolake/uart.c
>> > index a9362436000..143217755ff 100644
>> > --- a/arch/x86/cpu/apollolake/uart.c
>> > +++ b/arch/x86/cpu/apollolake/uart.c
>> > @@ -79,11 +79,11 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
>> >
>> >  static int apl_ns16550_probe(struct udevice *dev)
>> >  {
>> > +#if !CONFIG_IS_ENABLED(PCI)
>> >   struct apl_ns16550_plat *plat = dev_get_plat(dev);
>> >
>> > - if (!CONFIG_IS_ENABLED(PCI))
>> > - apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
>> > -
>> > + apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
>> > +#endif
>> >   return ns16550_serial_probe(dev);
>> >  }
>> >
>> > diff --git a/include/ns16550.h b/include/ns16550.h
>> > index e7e68663d03..8d7eb7d8f9c 100644
>> > --- a/include/ns16550.h
>> > +++ b/include/ns16550.h
>> > @@ -74,7 +74,7 @@ struct ns16550_plat {
>> >   int clock;
>> >   u32 fcr;
>> >   int flags;
>> > -#if defined(CONFIG_PCI) && defined(CONFIG_SPL)
>> > +#if !CONFIG_IS_ENABLED(PCI) || CONFIG_IS_ENABLED(OF_PLATDATA)
>> >   int bdf;
>> >  #endif
>> >  };
>>
>> This isn't equivalent.  This means platforms such as am335x_evm which do
>> not enable PCI nor SPL_PCI now get this field and grow their rodata.
>>
>> --
>> Tom
>
>
How does this look ?

diff --git a/arch/x86/cpu/apollolake/uart.c b/arch/x86/cpu/apollolake/uart.c
index a9362436000..da184638cb9 100644
--- a/arch/x86/cpu/apollolake/uart.c
+++ b/arch/x86/cpu/apollolake/uart.c
@@ -79,10 +79,11 @@ void apl_uart_init(pci_dev_t bdf, ulong base)

 static int apl_ns16550_probe(struct udevice *dev)
 {
+#if defined(CONFIG_SPL) && IS_ENABLED_NOCHECK(CONFIG_PCI)
struct apl_ns16550_plat *plat = dev_get_plat(dev);

-   if (!CONFIG_IS_ENABLED(PCI))
-   apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
+   apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
+#endif

return ns16550_serial_probe(dev);
 }
@@ -110,7 +111,9 @@ static int apl_ns16550_of_to_plat(struct udevice *dev)
ns.reg_offset = 0;
ns.clock = dtplat->clock_frequency;
ns.fcr = UART_FCR_DEFVAL;
+#if defined(CONFIG_SPL) && IS_ENABLED_NOCHECK(CONFIG_PCI)
ns.bdf = pci_ofplat_get_devfn(dtplat->reg[0]);
+#endif
memcpy(plat, &ns, sizeof(ns));
 #else
int ret;
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 2bc704e1104..d18c49686dd 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -27,6 +27,7 @@
  * 0 otherwise.
  */
 #define IS_ENABLED(option) config_enabled(option, 0)
+#define IS_ENABLED_NOCHECK(option) config_enabled(option, 0)

 /*
  * U-Boot add-on: Helper macros to reference to different macros (prefixed
by
diff --git a/include/ns16550.h b/include/ns16550.h
index e7e68663d03..f416e67e68f 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -74,7 +74,7 @@ struct ns16550_plat {
int clock;
u32 fcr;
int flags;
-#if defined(CONFIG_PCI) && defined(CONFIG_SPL)
+#if IS_ENABLED_NOCHECK(CONFIG_PCI) && defined(CONFIG_SPL)
int bdf;
 #endif
 };


Re: [PATCH v1 17/24] ns16550: match when to define bdf with uart code

2023-02-22 Thread Troy Kisky
On Wed, Feb 22, 2023 at 10:18 AM Tom Rini  wrote:

> On Tue, Feb 21, 2023 at 05:38:14PM -0800, Troy Kisky wrote:
>
> > When switching defined(CONFIG_PCI) to CONFIG_IS_ENABLED(PCI)
> > bdf is no longer accessible. So change to preprocessor to avoid access.
> >
> > Signed-off-by: Troy Kisky 
> > ---
> >
> >  arch/x86/cpu/apollolake/uart.c | 6 +++---
> >  include/ns16550.h  | 2 +-
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/x86/cpu/apollolake/uart.c
> b/arch/x86/cpu/apollolake/uart.c
> > index a9362436000..143217755ff 100644
> > --- a/arch/x86/cpu/apollolake/uart.c
> > +++ b/arch/x86/cpu/apollolake/uart.c
> > @@ -79,11 +79,11 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
> >
> >  static int apl_ns16550_probe(struct udevice *dev)
> >  {
> > +#if !CONFIG_IS_ENABLED(PCI)
> >   struct apl_ns16550_plat *plat = dev_get_plat(dev);
> >
> > - if (!CONFIG_IS_ENABLED(PCI))
> > - apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
> > -
> > + apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
> > +#endif
> >   return ns16550_serial_probe(dev);
> >  }
> >
> > diff --git a/include/ns16550.h b/include/ns16550.h
> > index e7e68663d03..8d7eb7d8f9c 100644
> > --- a/include/ns16550.h
> > +++ b/include/ns16550.h
> > @@ -74,7 +74,7 @@ struct ns16550_plat {
> >   int clock;
> >   u32 fcr;
> >   int flags;
> > -#if defined(CONFIG_PCI) && defined(CONFIG_SPL)
> > +#if !CONFIG_IS_ENABLED(PCI) || CONFIG_IS_ENABLED(OF_PLATDATA)
> >   int bdf;
> >  #endif
> >  };
>
> This isn't equivalent.  This means platforms such as am335x_evm which do
> not enable PCI nor SPL_PCI now get this field and grow their rodata.
>
> --
> Tom
>

tkisky@OS2:~/u-boot-tkisky$ make am335x_evm_defconfig
#
# configuration written to .config
#
tkisky@OS2:~/u-boot-tkisky$ grep -w CONFIG_INTEL_APOLLOLAKE .config
tkisky@OS2:~/u-boot-tkisky$

Would this be better ?
#if defined(CONFIG_INTEL_APOLLOLAKE) && ( !CONFIG_IS_ENABLED(PCI) ||
CONFIG_IS_ENABLED(OF_PLATDATA))

I don't understand what bdf is, but
#if defined(CONFIG_PCI) && defined(CONFIG_SPL)
   int bdf;
 #endif

in the include/ns16550.h, doesn't make sense with the usage in uart.c
 if (!CONFIG_IS_ENABLED(PCI))
 apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
_
I think I might be trying to paper over a bug.

Thanks
Troy


Re: [PATCH v1 18/24] solidrun: mx6cuboxi: use CONFIG_IS_ENABLED(SATA) instead of CONFIG_CMD_SATA

2023-02-22 Thread Troy Kisky
On Wed, Feb 22, 2023 at 8:59 AM Tom Rini  wrote:

> On Tue, Feb 21, 2023 at 05:38:15PM -0800, Troy Kisky wrote:
>
> > setup_sata is linked with
> > obj-$(CONFIG_SATA) += sata.o
> >
> > So use SATA instead of CMD_SATA.
> >
> > Signed-off-by: Troy Kisky 
> > ---
> >
> >  board/solidrun/mx6cuboxi/mx6cuboxi.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> > index 7c44379ec4a..e31a7e9552f 100644
> > --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> > +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> > @@ -275,7 +275,7 @@ int board_early_init_f(void)
> >  {
> >   setup_iomux_uart();
> >
> > -#ifdef CONFIG_CMD_SATA
> > +#if CONFIG_IS_ENABLED(SATA)
> >   setup_sata();
> >  #endif
> >   setup_fec();
>
> Note that wandboard needs a similar fix.
>
> --
> Tom
>

Hi Tom

The commit script will change
#ifdef CONFIG_SATA

to
#if CONFIG_IS_ENABLED(SATA)

This series only changes things that the commit script won't.

BR
Troy


[PATCH v1 23/24] arm: cpu: armv7: ls102xa: fdt: remove eth_device support

2023-02-21 Thread Troy Kisky
commit e524f3a449f5 ("net: Remove eth_legacy.c")

removed struct eth_device
This prevents errors in the conversion to CONFIG_IS_ENABLED(DM_ETH).

Signed-off-by: Troy Kisky 
---

 arch/arm/cpu/armv7/ls102xa/fdt.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/arch/arm/cpu/armv7/ls102xa/fdt.c b/arch/arm/cpu/armv7/ls102xa/fdt.c
index 599b7e18ef3..a5c5c780ae8 100644
--- a/arch/arm/cpu/armv7/ls102xa/fdt.c
+++ b/arch/arm/cpu/armv7/ls102xa/fdt.c
@@ -25,11 +25,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void ft_fixup_enet_phy_connect_type(void *fdt)
 {
-#ifdef CONFIG_DM_ETH
struct udevice *dev;
-#else
-   struct eth_device *dev;
-#endif
struct tsec_private *priv;
const char *enet_path, *phy_path;
char enet[16];
@@ -37,12 +33,8 @@ void ft_fixup_enet_phy_connect_type(void *fdt)
int phy_node;
int i = 0;
uint32_t ph;
-#ifdef CONFIG_DM_ETH
char *name[3] = { "ethernet@2d1", "ethernet@2d5",
  "ethernet@2d9" };
-#else
-   char *name[3] = { "eTSEC1", "eTSEC2", "eTSEC3" };
-#endif
 
for (; i < ARRAY_SIZE(name); i++) {
dev = eth_get_dev_by_name(name[i]);
@@ -53,11 +45,7 @@ void ft_fixup_enet_phy_connect_type(void *fdt)
continue;
}
 
-#ifdef CONFIG_DM_ETH
priv = dev_get_priv(dev);
-#else
-   priv = dev->priv;
-#endif
if (priv->flags & TSEC_SGMII)
continue;
 
-- 
2.34.1



[PATCH v1 00/24] CONFIG_IS_ENABLED vs IS_ENABLED

2023-02-21 Thread Troy Kisky


This patch set gets ready to checks the usage of
CONFIG_IS_ENABLED/IS_ENABLED.

After the set has been applied, you can delete
test/usage_of_is_enabled_todo.txt
and run test/usage_of_is_enabled_commit.sh

The script test/usage_of_is_enabled_check.sh
checks for new questionable uses of
CONFIG_IS_ENABLED/IS_ENABLED and is added
to .azure-pipelines.yml, and
.gitlab-ci.yml


Troy Kisky (24):
  cmd: nvedit: check for ENV_SUPPORT
  lib: crc32: prepare for CONFIG_IS_ENABLED changes
  lib: md5: prepare for CONFIG_IS_ENABLED changes
  lib: sha1: prepare for CONFIG_IS_ENABLED changes
  lib: sha256: prepare for CONFIG_IS_ENABLED changes
  lib: sha512: prepare for CONFIG_IS_ENABLED changes
  tools: prevent CONFIG_IS_ENABLED errors by including linux/kconfig.h
  tools: Makefile: prepare for CONFIG_IS_ENABLED changes by adding
CONFIG_TOOLS_xxx
  x86: cpu: qemu: qemu: remove SPL use with CONFIG_IS_ENABLED
  config_distro_bootcmd: remove booting environment variables from SPL
environment
  ofnode: fdt_support definitions needed if OF_CONTROL is enabled
  ringneck-px30: remove check for ENV_IS_NOWHERE, it is an SPL config
  puma-rk3399: remove check for ENV_IS_NOWHERE, it is an SPL config
  fdt_support: always define fdt_fixup_mtdparts
  m53menlo: define ft_board_setup only if CONFIG_IS_ENABLED(OF_LIBFDT)
  freescale: common: pfuze: define pfuze_mode_init only if
defined(CONFIG_DM_PMIC)
  ns16550: match when to define bdf with uart code
  solidrun: mx6cuboxi: use CONFIG_IS_ENABLED(SATA) instead of
CONFIG_CMD_SATA
  arm: mach-imx: use CONFIG_$(SPL_)SATA instead of CONFIG_SATA
  x86: cpu: i386: cpu: only set pci_ram_top if CONFIG_IS_ENABLED(PCI)
  gateworks: venice: surround call of setup_fec with if
IS_ENABLED(CONFIG_NET)
  power: pmic: add dm style definitions if not
CONFIG_IS_ENABLED(POWER_LEGACY)
  arm: cpu: armv7: ls102xa: fdt: remove eth_device support
  CI: add test/usage_of_is_enabled_check.sh

 .azure-pipelines.yml  |  11 +
 .gitlab-ci.yml|   5 +
 arch/arm/cpu/armv7/ls102xa/fdt.c  |  12 -
 arch/arm/mach-imx/Makefile|   2 +-
 arch/x86/cpu/apollolake/uart.c|   6 +-
 arch/x86/cpu/i386/cpu.c   |   2 +
 arch/x86/cpu/qemu/qemu.c  |   2 +-
 board/freescale/common/pfuze.c|   2 +-
 board/gateworks/venice/venice.c   |   4 +-
 board/menlo/m53menlo/m53menlo.c   |   2 +
 board/solidrun/mx6cuboxi/mx6cuboxi.c  |   2 +-
 .../puma_rk3399/puma-rk3399.c |   4 -
 .../ringneck_px30/ringneck-px30.c |   4 -
 boot/fdt_region.c |   1 +
 cmd/nvedit.c  |   5 +-
 include/config_distro_bootcmd.h   |  23 ++
 include/fdt_support.h |  26 ++-
 include/ns16550.h |   2 +-
 include/power/pmic.h  |   2 +-
 lib/crc32.c   |  12 +-
 lib/fdtdec_common.c   |   1 +
 lib/hash-checksum.c   |   1 +
 lib/md5.c |   9 +-
 lib/sha1.c|   8 +-
 lib/sha256.c  |   8 +-
 lib/sha512.c  |  12 +-
 test/usage_of_is_enabled_check.sh |  19 ++
 test/usage_of_is_enabled_commit.sh|  12 +
 test/usage_of_is_enabled_correct.sh   |  50 +
 test/usage_of_is_enabled_exempt.txt   |   9 +
 test/usage_of_is_enabled_list.sh  |  86 +++
 test/usage_of_is_enabled_splcfg.txt   |  21 ++
 test/usage_of_is_enabled_todo.txt | 210 ++
 tools/Makefile|   2 +
 tools/env/fw_env.c|   1 +
 tools/fdt_host.h  |   1 +
 tools/mkimage.h   |   1 +
 37 files changed, 524 insertions(+), 56 deletions(-)
 create mode 100755 test/usage_of_is_enabled_check.sh
 create mode 100755 test/usage_of_is_enabled_commit.sh
 create mode 100755 test/usage_of_is_enabled_correct.sh
 create mode 100644 test/usage_of_is_enabled_exempt.txt
 create mode 100755 test/usage_of_is_enabled_list.sh
 create mode 100644 test/usage_of_is_enabled_splcfg.txt
 create mode 100644 test/usage_of_is_enabled_todo.txt

-- 
2.34.1



[PATCH v1 24/24] CI: add test/usage_of_is_enabled_check.sh

2023-02-21 Thread Troy Kisky
Add script usage_of_is_enabled_check to print any configs that
use CONFIG_IS_ENABLED instead of IS_ENABLED and vice versa.

Add usage_of_is_enabled_commit.sh to generate commits to fix the above
issues.

You can remove entries from test/usage_of_is_enabled_todo.txt
or the entire file and then run
test/usage_of_is_enabled_commit.sh
to convert to suggested usage of CONFIG_IS_ENABLED/IS_ENABLED

or run test/usage_of_is_enabled_check.sh to
see which configs are still todo.

Signed-off-by: Troy Kisky 
---

 .azure-pipelines.yml|  11 ++
 .gitlab-ci.yml  |   5 +
 test/usage_of_is_enabled_check.sh   |  19 +++
 test/usage_of_is_enabled_commit.sh  |  12 ++
 test/usage_of_is_enabled_correct.sh |  50 +++
 test/usage_of_is_enabled_exempt.txt |   9 ++
 test/usage_of_is_enabled_list.sh|  86 
 test/usage_of_is_enabled_splcfg.txt |  21 +++
 test/usage_of_is_enabled_todo.txt   | 210 
 9 files changed, 423 insertions(+)
 create mode 100755 test/usage_of_is_enabled_check.sh
 create mode 100755 test/usage_of_is_enabled_commit.sh
 create mode 100755 test/usage_of_is_enabled_correct.sh
 create mode 100644 test/usage_of_is_enabled_exempt.txt
 create mode 100755 test/usage_of_is_enabled_list.sh
 create mode 100644 test/usage_of_is_enabled_splcfg.txt
 create mode 100644 test/usage_of_is_enabled_todo.txt

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 947c400f8d3..fcf8885fd33 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -67,6 +67,17 @@ stages:
   :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
   :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+  - job: check_usage_of_is_enabled
+displayName: 'Check usage of CONFIG_IS_ENABLED vs IS_ENABLED'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  # generate list of SPL configs
+  - script: test/usage_of_is_enabled_check.sh
+
   - job: cppcheck
 displayName: 'Static code analysis with cppcheck'
 pool:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 272d69e2206..c9443702d00 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -137,6 +137,11 @@ check for new CONFIG symbols outside Kconfig:
 :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
 :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+check usage of CONFIG_IS_ENABLED vs IS_ENABLED:
+  stage: testsuites
+  script:
+- ./test/usage_of_is_enabled_check.sh
+
 # QA jobs for code analytics
 # static code analysis with cppcheck (we can add --enable=all later)
 cppcheck:
diff --git a/test/usage_of_is_enabled_check.sh 
b/test/usage_of_is_enabled_check.sh
new file mode 100755
index 000..6bd5d9c1ac7
--- /dev/null
+++ b/test/usage_of_is_enabled_check.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+${scriptdir}/usage_of_is_enabled_list.sh | grep -vw FOO;
+if [ $? -eq 0 ] ; then
+   echo "The above may have incorrect usage of IS_ENABLED/"\
+"CONFIG_IS_ENABLED"
+   echo "Run test/usage_of_is_enabled_commit.sh and "\
+"squash with appropriate commit"
+   ret=1;
+else
+   ret=0;
+fi
+
+rm ${scriptdir}/splcfg.tmp ${scriptdir}/exclude.tmp
+exit ${ret}
diff --git a/test/usage_of_is_enabled_commit.sh 
b/test/usage_of_is_enabled_commit.sh
new file mode 100755
index 000..593dbd1428c
--- /dev/null
+++ b/test/usage_of_is_enabled_commit.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+${scriptdir}/usage_of_is_enabled_list.sh | \
+xargs -I {} sh -c "${scriptdir}/usage_of_is_enabled_correct.sh {}; \
+git commit -a -m\"CONFIG_{}: correct usage of CONFIG_IS_ENABLED/IS_ENABLED\";"
+
+
+rm ${scriptdir}/splcfg.tmp ${scriptdir}/exclude.tmp
diff --git a/test/usage_of_is_enabled_correct.sh 
b/test/usage_of_is_enabled_correct.sh
new file mode 100755
index 000..8724747beed
--- /dev/null
+++ b/test/usage_of_is_enabled_correct.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Written by Troy Kisky 
+
+scriptdir=`dirname "$0"`;
+
+if [ -z "$1" ] ; then
+   echo missing config
+   exit 1;
+fi
+if [ ! -f "${scriptdir}/splcfg.tmp" ] ; then
+   echo missing splcfg.tmp
+   exit 1;
+fi
+
+
+grep -qw $1 ${scriptdir}/splcfg.tmp
+if [ $? -ne 0 ] ; then
+# not splcfg
+# change CONFIG_IS_ENABLED to IS_ENABLED
+git grep -l \
+-e "CONFIG_IS_ENABLED($1)" \
+ | \
+xargs -IFile sh -c \
+" \
+sed -i -E \"\
+s/CONFIG_IS_ENABLED\($1\)/IS_ENABLED\(CONFIG_$1\)/g; \
+\" File";
+else
+# splcfg
+# change IS_ENABLED to CONFIG_IS_ENABLED
+# change ifdef to C

[PATCH v1 22/24] power: pmic: add dm style definitions if not CONFIG_IS_ENABLED(POWER_LEGACY)

2023-02-21 Thread Troy Kisky
This avoids an error in converting to CONFIG_IS_ENABLED(DM_PMIC).
Many boards SPL code needs these definitions to compile, even if
the functions are not linked.

Signed-off-by: Troy Kisky 
---

 include/power/pmic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/power/pmic.h b/include/power/pmic.h
index 70f2709bd0b..636221692d0 100644
--- a/include/power/pmic.h
+++ b/include/power/pmic.h
@@ -86,7 +86,7 @@ struct pmic {
 #endif /* CONFIG_IS_ENABLED(POWER_LEGACY) */
 
 /* TODO: Change to CONFIG_IS_ENABLED(DM_PMIC) when SPL_DM_PMIC exists */
-#ifdef CONFIG_DM_PMIC
+#if defined(CONFIG_DM_PMIC) || !CONFIG_IS_ENABLED(POWER_LEGACY)
 /**
  * U-Boot PMIC Framework
  * =
-- 
2.34.1



[PATCH v1 20/24] x86: cpu: i386: cpu: only set pci_ram_top if CONFIG_IS_ENABLED(PCI)

2023-02-21 Thread Troy Kisky
This avoids an error when ifdef CONFIG_PCI is changed to
if CONFIG_IS_ENABLED(PCI)

Signed-off-by: Troy Kisky 
---

 arch/x86/cpu/i386/cpu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/cpu/i386/cpu.c b/arch/x86/cpu/i386/cpu.c
index c7f6c5a013e..07a73f79768 100644
--- a/arch/x86/cpu/i386/cpu.c
+++ b/arch/x86/cpu/i386/cpu.c
@@ -415,7 +415,9 @@ int cpu_phys_address_size(void)
 /* Don't allow PCI region 3 to use memory in the 2-4GB memory hole */
 static void setup_pci_ram_top(void)
 {
+#if CONFIG_IS_ENABLED(PCI)
gd->pci_ram_top = 0x8000U;
+#endif
 }
 
 static void setup_mtrr(void)
-- 
2.34.1



[PATCH v1 19/24] arm: mach-imx: use CONFIG_$(SPL_)SATA instead of CONFIG_SATA

2023-02-21 Thread Troy Kisky
This avoid an error with enable_sata_clock when
defined(CONFIG_SATA) is changed to CONFIG_IS_ENABLED(SATA).

Signed-off-by: Troy Kisky 
---

 arch/arm/mach-imx/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 4dfc60eedc4..50f26975eac 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -54,7 +54,7 @@ obj-$(CONFIG_IMX_RDC) += rdc-sema.o
 ifneq ($(CONFIG_SPL_BUILD),y)
 obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
 endif
-obj-$(CONFIG_SATA) += sata.o
+obj-$(CONFIG_$(SPL_)SATA) += sata.o
 obj-$(CONFIG_IMX_HAB)+= hab.o
 obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
 endif
-- 
2.34.1



[PATCH v1 21/24] gateworks: venice: surround call of setup_fec with if IS_ENABLED(CONFIG_NET)

2023-02-21 Thread Troy Kisky
This is the same as the definition is surrounded by.
It avoids an error in converting to CONFIG_IS_ENABLED(NET).

Signed-off-by: Troy Kisky 
---

 board/gateworks/venice/venice.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/board/gateworks/venice/venice.c b/board/gateworks/venice/venice.c
index c4d86c26a9b..ad27835caaf 100644
--- a/board/gateworks/venice/venice.c
+++ b/board/gateworks/venice/venice.c
@@ -41,7 +41,7 @@ int board_fit_config_name_match(const char *name)
return -1;
 }
 
-#if (IS_ENABLED(CONFIG_NET))
+#if IS_ENABLED(CONFIG_NET)
 static int setup_fec(void)
 {
struct iomuxc_gpr_base_regs *gpr =
@@ -113,10 +113,12 @@ int board_init(void)
 {
venice_eeprom_init(1);
 
+#if IS_ENABLED(CONFIG_NET)
if (IS_ENABLED(CONFIG_FEC_MXC))
setup_fec();
if (IS_ENABLED(CONFIG_DWC_ETH_QOS))
setup_eqos();
+#endif
 
return 0;
 }
-- 
2.34.1



[PATCH v1 16/24] freescale: common: pfuze: define pfuze_mode_init only if defined(CONFIG_DM_PMIC)

2023-02-21 Thread Troy Kisky
pfuze_mode_init calls pmic_reg_read which is only available from

obj-$(CONFIG_$(SPL_TPL_)DM_PMIC) += pmic-uclass.o

Prepare for conversion of defined(CONFIG_DM_PMIC) to
CONFIG_IS_ENABLED(DM_PMIC).

Signed-off-by: Troy Kisky 
---

 board/freescale/common/pfuze.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/freescale/common/pfuze.c b/board/freescale/common/pfuze.c
index 6dca22960bf..a9288820b2e 100644
--- a/board/freescale/common/pfuze.c
+++ b/board/freescale/common/pfuze.c
@@ -91,7 +91,7 @@ struct pmic *pfuze_common_init(unsigned char i2cbus)
 
return p;
 }
-#else
+#elif defined(CONFIG_DM_PMIC)
 int pfuze_mode_init(struct udevice *dev, u32 mode)
 {
unsigned char offset, i, switch_num;
-- 
2.34.1



[PATCH v1 17/24] ns16550: match when to define bdf with uart code

2023-02-21 Thread Troy Kisky
When switching defined(CONFIG_PCI) to CONFIG_IS_ENABLED(PCI)
bdf is no longer accessible. So change to preprocessor to avoid access.

Signed-off-by: Troy Kisky 
---

 arch/x86/cpu/apollolake/uart.c | 6 +++---
 include/ns16550.h  | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/cpu/apollolake/uart.c b/arch/x86/cpu/apollolake/uart.c
index a9362436000..143217755ff 100644
--- a/arch/x86/cpu/apollolake/uart.c
+++ b/arch/x86/cpu/apollolake/uart.c
@@ -79,11 +79,11 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
 
 static int apl_ns16550_probe(struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(PCI)
struct apl_ns16550_plat *plat = dev_get_plat(dev);
 
-   if (!CONFIG_IS_ENABLED(PCI))
-   apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
-
+   apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
+#endif
return ns16550_serial_probe(dev);
 }
 
diff --git a/include/ns16550.h b/include/ns16550.h
index e7e68663d03..8d7eb7d8f9c 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -74,7 +74,7 @@ struct ns16550_plat {
int clock;
u32 fcr;
int flags;
-#if defined(CONFIG_PCI) && defined(CONFIG_SPL)
+#if !CONFIG_IS_ENABLED(PCI) || CONFIG_IS_ENABLED(OF_PLATDATA)
int bdf;
 #endif
 };
-- 
2.34.1



[PATCH v1 15/24] m53menlo: define ft_board_setup only if CONFIG_IS_ENABLED(OF_LIBFDT)

2023-02-21 Thread Troy Kisky
The function ft_board_setup calls do_fixup_by_path_string
which is only available on CONFIG_IS_ENABLED(OF_LIBFDT).
This prepares for the conversion.

ft_board_setup is only called from image-fdt which is linked by
obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o

Signed-off-by: Troy Kisky 
---

 board/menlo/m53menlo/m53menlo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/board/menlo/m53menlo/m53menlo.c b/board/menlo/m53menlo/m53menlo.c
index 14324c7087d..ca3b81c57ff 100644
--- a/board/menlo/m53menlo/m53menlo.c
+++ b/board/menlo/m53menlo/m53menlo.c
@@ -264,6 +264,7 @@ void board_preboot_os(void)
gpio_direction_output(IMX_GPIO_NR(6, 0), 0);
 }
 
+#if CONFIG_IS_ENABLED(OF_LIBFDT)
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
if (lvds_compat_string)
@@ -272,6 +273,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 
return 0;
 }
+#endif
 
 struct display_info_t const displays[] = {
{
-- 
2.34.1



[PATCH v1 18/24] solidrun: mx6cuboxi: use CONFIG_IS_ENABLED(SATA) instead of CONFIG_CMD_SATA

2023-02-21 Thread Troy Kisky
setup_sata is linked with
obj-$(CONFIG_SATA) += sata.o

So use SATA instead of CMD_SATA.

Signed-off-by: Troy Kisky 
---

 board/solidrun/mx6cuboxi/mx6cuboxi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c 
b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 7c44379ec4a..e31a7e9552f 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -275,7 +275,7 @@ int board_early_init_f(void)
 {
setup_iomux_uart();
 
-#ifdef CONFIG_CMD_SATA
+#if CONFIG_IS_ENABLED(SATA)
setup_sata();
 #endif
setup_fec();
-- 
2.34.1



[PATCH v1 13/24] puma-rk3399: remove check for ENV_IS_NOWHERE, it is an SPL config

2023-02-21 Thread Troy Kisky
When IS_ENABLED(CONFIG_ENV_IS_NOWHERE) is converted to
CONFIG_IS_ENABLED(ENV_IS_NOWHERE) this will give unwanted errors
on spl builds.

Signed-off-by: Troy Kisky 
---

 board/theobroma-systems/puma_rk3399/puma-rk3399.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c 
b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
index 97f398bd754..614a60ee8f9 100644
--- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c
+++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
@@ -136,10 +136,6 @@ int mmc_get_env_dev(void)
return CONFIG_SYS_MMC_ENV_DEV;
 }
 
-#if !IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
-#error Please enable CONFIG_ENV_IS_NOWHERE
-#endif
-
 enum env_location arch_env_get_location(enum env_operation op, int prio)
 {
const char *boot_device =
-- 
2.34.1



[PATCH v1 14/24] fdt_support: always define fdt_fixup_mtdparts

2023-02-21 Thread Troy Kisky
SPL code wants fdt_fixup_mtdparts defined as a NOP
when the function isn't linked in.

Prepare for ifdef CONFIG_OF_LIBFDT being converted to
 if CONFIG_IS_ENABLED(OF_LIBFDT)

Signed-off-by: Troy Kisky 
---

 include/fdt_support.h | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/include/fdt_support.h b/include/fdt_support.h
index eeb83e6251d..94497d755a3 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -245,16 +245,6 @@ int fdt_increase_size(void *fdt, int add_len);
 int fdt_delete_disabled_nodes(void *blob);
 
 struct node_info;
-#if defined(CONFIG_FDT_FIXUP_PARTITIONS)
-void fdt_fixup_mtdparts(void *fdt, const struct node_info *node_info,
-   int node_info_size);
-#else
-static inline void fdt_fixup_mtdparts(void *fdt,
- const struct node_info *node_info,
- int node_info_size)
-{
-}
-#endif
 
 void fdt_del_node_and_alias(void *blob, const char *alias);
 
@@ -412,6 +402,19 @@ int fdt_get_cells_len(const void *blob, char 
*nr_cells_name);
 
 #endif /* ifdef CONFIG_OF_LIBFDT */
 
+#if CONFIG_IS_ENABLED(OF_LIBFDT) && defined(CONFIG_FDT_FIXUP_PARTITIONS)
+struct node_info;
+void fdt_fixup_mtdparts(void *fdt, const struct node_info *node_info,
+   int node_info_size);
+#else
+struct node_info;
+static inline void fdt_fixup_mtdparts(void *fdt,
+ const struct node_info *node_info,
+ int node_info_size)
+{
+}
+#endif
+
 #ifdef USE_HOSTCC
 int fdtdec_get_int(const void *blob, int node, const char *prop_name,
int default_val);
-- 
2.34.1



[PATCH v1 12/24] ringneck-px30: remove check for ENV_IS_NOWHERE, it is an SPL config

2023-02-21 Thread Troy Kisky
When IS_ENABLED(CONFIG_ENV_IS_NOWHERE) is converted to
CONFIG_IS_ENABLED(ENV_IS_NOWHERE) this will give unwanted errors
on spl builds.

Signed-off-by: Troy Kisky 
---

 board/theobroma-systems/ringneck_px30/ringneck-px30.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/board/theobroma-systems/ringneck_px30/ringneck-px30.c 
b/board/theobroma-systems/ringneck_px30/ringneck-px30.c
index 47d1a40ef7c..bb1bb4acf5c 100644
--- a/board/theobroma-systems/ringneck_px30/ringneck-px30.c
+++ b/board/theobroma-systems/ringneck_px30/ringneck-px30.c
@@ -118,10 +118,6 @@ int mmc_get_env_dev(void)
return CONFIG_SYS_MMC_ENV_DEV;
 }
 
-#if !IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
-#error Please enable CONFIG_ENV_IS_NOWHERE
-#endif
-
 enum env_location arch_env_get_location(enum env_operation op, int prio)
 {
const char *boot_device =
-- 
2.34.1



[PATCH v1 09/24] x86: cpu: qemu: qemu: remove SPL use with CONFIG_IS_ENABLED

2023-02-21 Thread Troy Kisky
CONFIG_IS_ENABLED(SPL_X86_32BIT_INIT)
would check for CONFIG_SPL_SPL_X86_32BIT_INIT for SPL builds

Signed-off-by: Troy Kisky 
---

 arch/x86/cpu/qemu/qemu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/cpu/qemu/qemu.c b/arch/x86/cpu/qemu/qemu.c
index e54082df7f9..274978c023b 100644
--- a/arch/x86/cpu/qemu/qemu.c
+++ b/arch/x86/cpu/qemu/qemu.c
@@ -97,7 +97,7 @@ static void qemu_chipset_init(void)
}
 }
 
-#if !CONFIG_IS_ENABLED(SPL_X86_32BIT_INIT)
+#if CONFIG_IS_ENABLED(X86_32BIT_INIT)
 int arch_cpu_init(void)
 {
post_code(POST_CPU_INIT);
-- 
2.34.1



[PATCH v1 11/24] ofnode: fdt_support definitions needed if OF_CONTROL is enabled

2023-02-21 Thread Troy Kisky
With the use of CONFIG_IS_ENABLED in code, instead of at the preprocessor
level, these defines are still needed if OF_CONTROL is enabled.

Signed-off-by: Troy Kisky 
---

 include/fdt_support.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/fdt_support.h b/include/fdt_support.h
index 5638bd4f165..eeb83e6251d 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -7,7 +7,8 @@
 #ifndef __FDT_SUPPORT_H
 #define __FDT_SUPPORT_H
 
-#if defined(CONFIG_OF_LIBFDT) && !defined(USE_HOSTCC)
+#if (defined(CONFIG_OF_LIBFDT) || defined(CONFIG_OF_CONTROL)) && \
+   !defined(USE_HOSTCC)
 
 #include 
 #include 
-- 
2.34.1



[PATCH v1 10/24] config_distro_bootcmd: remove booting environment variables from SPL environment

2023-02-21 Thread Troy Kisky
SPL environments don't need command that they can never use.
Avoid errors with CONFIG_IS_ENABLED conversions by skipping them now.

Signed-off-by: Troy Kisky 
---

 include/config_distro_bootcmd.h | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 9d2a225e7eb..2a136b96a6d 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -35,11 +35,15 @@
#devtypel "_boot=" \
BOOTENV_SHARED_BLKDEV_BODY(devtypel)
 
+#define BOOTENV_DEV_BLKDEV_NONE(devtypeu, devtypel, instance)
+
 #define BOOTENV_DEV_BLKDEV(devtypeu, devtypel, instance) \
"bootcmd_" #devtypel #instance "=" \
"devnum=" #instance "; " \
"run " #devtypel "_boot\0"
 
+#define BOOTENV_DEV_NAME_BLKDEV_NONE(devtypeu, devtypel, instance)
+
 #define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \
#devtypel #instance " "
 
@@ -59,6 +63,10 @@
 #define BOOTENV_SHARED_MMC BOOTENV_SHARED_BLKDEV(mmc)
 #define BOOTENV_DEV_MMCBOOTENV_DEV_BLKDEV
 #define BOOTENV_DEV_NAME_MMC   BOOTENV_DEV_NAME_BLKDEV
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_SHARED_MMC
+#define BOOTENV_DEV_MMCBOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_MMC   BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_SHARED_MMC
 #define BOOTENV_DEV_MMC \
@@ -190,6 +198,10 @@
 #define BOOTENV_SHARED_SATABOOTENV_SHARED_BLKDEV(sata)
 #define BOOTENV_DEV_SATA   BOOTENV_DEV_BLKDEV
 #define BOOTENV_DEV_NAME_SATA  BOOTENV_DEV_NAME_BLKDEV
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_SHARED_SATA
+#define BOOTENV_DEV_SATA   BOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_SATA  BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_SHARED_SATA
 #define BOOTENV_DEV_SATA \
@@ -293,6 +305,11 @@
BOOTENV_SHARED_BLKDEV_BODY(usb)
 #define BOOTENV_DEV_USBBOOTENV_DEV_BLKDEV
 #define BOOTENV_DEV_NAME_USB   BOOTENV_DEV_NAME_BLKDEV
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_RUN_NET_USB_START
+#define BOOTENV_SHARED_USB
+#define BOOTENV_DEV_USBBOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_USB   BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_RUN_NET_USB_START
 #define BOOTENV_SHARED_USB
@@ -395,6 +412,9 @@
"\0"
 #define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \
"dhcp "
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_DEV_DHCP   BOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_DHCP  BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_DEV_DHCP \
BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP
@@ -413,6 +433,9 @@
"fi\0"
 #define BOOTENV_DEV_NAME_PXE(devtypeu, devtypel, instance) \
"pxe "
+#elif defined(CONFIG_SPL_BUILD)
+#define BOOTENV_DEV_PXEBOOTENV_DEV_BLKDEV_NONE
+#define BOOTENV_DEV_NAME_PXE   BOOTENV_DEV_NAME_BLKDEV_NONE
 #else
 #define BOOTENV_DEV_PXE \
BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
-- 
2.34.1



[PATCH v1 08/24] tools: Makefile: prepare for CONFIG_IS_ENABLED changes by adding CONFIG_TOOLS_xxx

2023-02-21 Thread Troy Kisky
CONFIG_IS_ENABLED(FIT_SIGNATURE) will check for
CONFIG_TOOLS_FIT_SIGNATURE. So define it now in preparation.

Signed-off-by: Troy Kisky 
---

 tools/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/Makefile b/tools/Makefile
index e13effbb66a..2670c77b2cb 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -162,8 +162,10 @@ ifdef CONFIG_TOOLS_LIBCRYPTO
 # This affects include/image.h, but including the board config file
 # is tricky, so manually define this options here.
 HOST_EXTRACFLAGS   += -DCONFIG_FIT_SIGNATURE
+HOST_EXTRACFLAGS   += -DCONFIG_TOOLS_FIT_SIGNATURE=1
 HOST_EXTRACFLAGS   += -DCONFIG_FIT_SIGNATURE_MAX_SIZE=0x
 HOST_EXTRACFLAGS   += -DCONFIG_FIT_CIPHER
+HOST_EXTRACFLAGS   += -DCONFIG_TOOLS_FIT_CIPHER=1
 endif
 
 # MXSImage needs LibSSL
-- 
2.34.1



[PATCH v1 07/24] tools: prevent CONFIG_IS_ENABLED errors by including linux/kconfig.h

2023-02-21 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED.

Signed-off-by: Troy Kisky 
---

 boot/fdt_region.c   | 1 +
 lib/fdtdec_common.c | 1 +
 lib/hash-checksum.c | 1 +
 tools/env/fw_env.c  | 1 +
 tools/fdt_host.h| 1 +
 tools/mkimage.h | 1 +
 6 files changed, 6 insertions(+)

diff --git a/boot/fdt_region.c b/boot/fdt_region.c
index 295ea08ac91..5331fbbfb50 100644
--- a/boot/fdt_region.c
+++ b/boot/fdt_region.c
@@ -5,6 +5,7 @@
  * Written by Simon Glass 
  */
 
+#include 
 #include 
 #include 
 #include 
diff --git a/lib/fdtdec_common.c b/lib/fdtdec_common.c
index ddaca0087e1..76719fb59b2 100644
--- a/lib/fdtdec_common.c
+++ b/lib/fdtdec_common.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #else
+#include 
 #include "libfdt.h"
 #include "fdt_support.h"
 
diff --git a/lib/hash-checksum.c b/lib/hash-checksum.c
index 8f2a42f9a08..062c3a54db4 100644
--- a/lib/hash-checksum.c
+++ b/lib/hash-checksum.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #else
+#include 
 #include "fdt_host.h"
 #endif
 #include 
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index c9a8774acef..abe9977fad3 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/tools/fdt_host.h b/tools/fdt_host.h
index bc42306c9e5..6c7788db3c6 100644
--- a/tools/fdt_host.h
+++ b/tools/fdt_host.h
@@ -7,6 +7,7 @@
 #define __FDT_HOST_H__
 
 /* Make sure to include u-boot version of libfdt include files */
+#include "../include/linux/kconfig.h"
 #include "../include/linux/libfdt.h"
 #include "../include/fdt_support.h"
 
diff --git a/tools/mkimage.h b/tools/mkimage.h
index f5ca65e2edf..5cbb372d7b1 100644
--- a/tools/mkimage.h
+++ b/tools/mkimage.h
@@ -8,6 +8,7 @@
 #ifndef _MKIIMAGE_H_
 #define _MKIIMAGE_H_
 
+#include 
 #include "os_support.h"
 #include 
 #include 
-- 
2.34.1



[PATCH v1 05/24] lib: sha256: prepare for CONFIG_IS_ENABLED changes

2023-02-21 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
don't pet the watchdog when USE_HOSTCC is defined.

Signed-off-by: Troy Kisky 
---

 lib/sha256.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/sha256.c b/lib/sha256.c
index 4d26aea1c8c..eb31d16f996 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -8,7 +8,11 @@
 #ifndef USE_HOSTCC
 #include 
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#define PET_WDG
+#endif
 #else
+#include 
 #include 
 #endif /* USE_HOSTCC */
 #include 
@@ -276,7 +280,7 @@ void sha256_csum_wd(const unsigned char *input, unsigned 
int ilen,
unsigned char *output, unsigned int chunk_sz)
 {
sha256_context ctx;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end;
unsigned char *curr;
int chunk;
@@ -284,7 +288,7 @@ void sha256_csum_wd(const unsigned char *input, unsigned 
int ilen,
 
sha256_starts(&ctx);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = (unsigned char *)input;
end = input + ilen;
while (curr < end) {
-- 
2.34.1



[PATCH v1 06/24] lib: sha512: prepare for CONFIG_IS_ENABLED changes

2023-02-21 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
don't pet the watchdog when USE_HOSTCC is defined.

Signed-off-by: Troy Kisky 
---

 lib/sha512.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/sha512.c b/lib/sha512.c
index fbe8d5f5bfe..4db2e5c08e4 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -13,7 +13,11 @@
 #ifndef USE_HOSTCC
 #include 
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#define PET_WDG
+#endif
 #else
+#include 
 #include 
 #endif /* USE_HOSTCC */
 #include 
@@ -292,7 +296,7 @@ void sha384_csum_wd(const unsigned char *input, unsigned 
int ilen,
unsigned char *output, unsigned int chunk_sz)
 {
sha512_context ctx;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end;
unsigned char *curr;
int chunk;
@@ -300,7 +304,7 @@ void sha384_csum_wd(const unsigned char *input, unsigned 
int ilen,
 
sha384_starts(&ctx);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = (unsigned char *)input;
end = input + ilen;
while (curr < end) {
@@ -355,7 +359,7 @@ void sha512_csum_wd(const unsigned char *input, unsigned 
int ilen,
unsigned char *output, unsigned int chunk_sz)
 {
sha512_context ctx;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end;
unsigned char *curr;
int chunk;
@@ -363,7 +367,7 @@ void sha512_csum_wd(const unsigned char *input, unsigned 
int ilen,
 
sha512_starts(&ctx);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = (unsigned char *)input;
end = input + ilen;
while (curr < end) {
-- 
2.34.1



[PATCH v1 04/24] lib: sha1: prepare for CONFIG_IS_ENABLED changes

2023-02-21 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
don't pet the watchdog when USE_HOSTCC is defined.

Signed-off-by: Troy Kisky 
---

 lib/sha1.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/sha1.c b/lib/sha1.c
index 8d074078934..af49535e5d2 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -19,7 +19,11 @@
 #ifndef USE_HOSTCC
 #include 
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#define PET_WDG
+#endif
 #else
+#include 
 #include 
 #endif /* USE_HOSTCC */
 #include 
@@ -328,14 +332,14 @@ void sha1_csum_wd(const unsigned char *input, unsigned 
int ilen,
  unsigned char *output, unsigned int chunk_sz)
 {
sha1_context ctx;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end, *curr;
int chunk;
 #endif
 
sha1_starts (&ctx);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = input;
end = input + ilen;
while (curr < end) {
-- 
2.34.1



[PATCH v1 02/24] lib: crc32: prepare for CONFIG_IS_ENABLED changes

2023-02-21 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
be more direct with using defined(USE_HOSTCC).

Signed-off-by: Troy Kisky 
---

 lib/crc32.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/crc32.c b/lib/crc32.c
index aa94d70ef3e..b2fa9e06e55 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -11,14 +11,18 @@
 #ifdef USE_HOSTCC
 #include 
 #include 
+#include 
 #else
 #include 
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#define PET_WDG
+#endif
 #endif
 #include 
 #include 
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
 #include 
 #endif
 #include "u-boot/zlib.h"
@@ -84,7 +88,7 @@ static void __efi_runtime make_crc_table(void)
   }
   crc_table_empty = 0;
 }
-#elif !defined(CONFIG_ARM64_CRC32)
+#elif !defined(CONFIG_ARM64_CRC32) || defined(USE_HOSTCC)
 /* 
  * Table of CRC-32's of all single-byte values (made by make_crc_table)
  */
@@ -184,7 +188,7 @@ const uint32_t * ZEXPORT get_crc_table()
  */
 uint32_t __efi_runtime crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
 {
-#ifdef CONFIG_ARM64_CRC32
+#if defined(CONFIG_ARM64_CRC32) && !defined(USE_HOSTCC)
 crc = cpu_to_le32(crc);
 while (len--)
 crc = __builtin_aarch64_crc32b(crc, *buf++);
@@ -243,7 +247,7 @@ uint32_t __efi_runtime crc32(uint32_t crc, const Bytef *p, 
uInt len)
 uint32_t crc32_wd(uint32_t crc, const unsigned char *buf, uInt len,
  uInt chunk_sz)
 {
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end, *curr;
int chunk;
 
-- 
2.34.1



[PATCH v1 03/24] lib: md5: prepare for CONFIG_IS_ENABLED changes

2023-02-21 Thread Troy Kisky
We need to include  in order to include
files that use CONFIG_IS_ENABLED. TO prepare for that
don't pet the watchdog when USE_HOSTCC is defined.

Signed-off-by: Troy Kisky 
---

 lib/md5.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/md5.c b/lib/md5.c
index 1636ab93661..bd3d8fa9b2b 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -29,7 +29,12 @@
 
 #ifndef USE_HOSTCC
 #include 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
 #include 
+#define PET_WDG
+#endif
+#else
+#include 
 #endif /* USE_HOSTCC */
 #include 
 
@@ -288,14 +293,14 @@ md5_wd(const unsigned char *input, unsigned int len, 
unsigned char output[16],
unsigned int chunk_sz)
 {
struct MD5Context context;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
const unsigned char *end, *curr;
int chunk;
 #endif
 
MD5Init(&context);
 
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#ifdef PET_WDG
curr = input;
end = input + len;
while (curr < end) {
-- 
2.34.1



[PATCH v1 01/24] cmd: nvedit: check for ENV_SUPPORT

2023-02-21 Thread Troy Kisky
Avoid error messages when SPL,TPL,VPL build don't
have the environment options of the main build.
This is needed when defined(CONFIG_ENV_IS_IN_xxx) is changed
to CONFIG_IS_ENABLED(ENV_IS_IN_xxx).

Signed-off-by: Troy Kisky 
---

 cmd/nvedit.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 7cbc3fd573a..ef0fe55431c 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -43,6 +43,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if CONFIG_IS_ENABLED(ENV_SUPPORT)
 #ifdefined(CONFIG_ENV_IS_IN_EEPROM)|| \
defined(CONFIG_ENV_IS_IN_FLASH) || \
defined(CONFIG_ENV_IS_IN_MMC)   || \
@@ -60,10 +61,12 @@ DECLARE_GLOBAL_DATA_PTR;
 #endif
 
 #if!defined(ENV_IS_IN_DEVICE)  && \
-   !defined(CONFIG_ENV_IS_NOWHERE)
+   !defined(CONFIG_ENV_IS_NOWHERE) && \
+   !defined(CONFIG_VPL_BUILD)
 # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|\
 NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
 #endif
+#endif
 
 /*
  * Maximum expected input data size for import command
-- 
2.34.1



Re: [PATCH] RFC: CI: add test/usage_of_is_enabled_check.sh

2023-02-07 Thread Troy Kisky
Hi Guys

My recent CI runs for my is_enabled branch have failed
Run tests for Nokia RX-51 (aka N900) with

2023-02-07T17:38:08.1393984Z --2023-02-07 17:38:08--  (try:20)
http://repository.maemo.org/pool/maemo5.0/free/b/busybox/busybox_1.10.2.legal-1osso30+0m5_armel.deb
2023-02-07T17:40:17.4031492Z Connecting to repository.maemo.org
(repository.maemo.org)|213.128.137.22|:80... failed: Connection timed
out.
2023-02-07T17:40:17.4032676Z Giving up.
2023-02-07T17:40:17.4033026Z
2023-02-07T17:40:17.4104289Z ##[error]Bash exited with code '4'.
2023-02-07T17:40:17.4397078Z ##[section]Finishing: CmdLine

Any suggestions?


Thanks

Troy


Re: [PATCH] RFC: CI: add test/usage_of_is_enabled_check.sh

2023-02-01 Thread Troy Kisky
Hi Simon

On Wed, Feb 1, 2023 at 12:21 PM Simon Glass  wrote:

> Hi Troy,
>
> On Tue, 31 Jan 2023 at 12:57, Troy Kisky 
> wrote:
> >
> > Add script usage_of_is_enabled_check to print any configs that
> > use CONFIG_IS_ENABLED instead of IS_ENABLED and vice versa.
> >
> > Add usage_of_is_enabled_commit.sh to generate commits to fix the above
> > issues.
> >
> > Signed-off-by: Troy Kisky 
> > ---
> >  .azure-pipelines.yml   | 11 
> >  .gitlab-ci.yml |  5 
> >  test/usage_of_is_enabled_check.sh  | 41 ++
> >  test/usage_of_is_enabled_commit.sh | 38 +++
> >  4 files changed, 95 insertions(+)
> >  create mode 100755 test/usage_of_is_enabled_check.sh
> >  create mode 100755 test/usage_of_is_enabled_commit.sh
>
> This looks reasonable to me. I would of course prefer to just fix all
> these problems, since they make it impossible to move to split config.
>

So, this might help your effort ?
Do I need to have a body in these 200 commits  or is only a subject enough ?
Are you happy with the subject, or do I need to edit each individually ?

Currently I have
CONFIG_ZSTD: change IS_ENABLED to CONFIG_IS_ENABLED

Is there an easy way for "git send-email" to send each commit only to the
proper maintainer ?


>
> But we need this sort of check in CI to stop it happening again.
>
> >
> > diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
> > index 5673bb76afb..8e227512765 100644
> > --- a/.azure-pipelines.yml
> > +++ b/.azure-pipelines.yml
> > @@ -67,6 +67,17 @@ stages:
> >:^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
> >:^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
> >
> > +  - job: check_usage_of_is_enabled
> > +displayName: 'Check usage of CONFIG_IS_ENABLED vs IS_ENABLED'
> > +pool:
> > +  vmImage: $(ubuntu_vm)
> > +container:
> > +  image: $(ci_runner_image)
> > +  options: $(container_option)
> > +steps:
> > +  # generate list of SPL configs
> > +  - script: test/usage_of_is_enabled_check.sh
> > +
> >- job: cppcheck
> >  displayName: 'Static code analysis with cppcheck'
> >  pool:
> > diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> > index aaf9d25abfc..6bb8efef258 100644
> > --- a/.gitlab-ci.yml
> > +++ b/.gitlab-ci.yml
> > @@ -134,6 +134,11 @@ check for new CONFIG symbols outside Kconfig:
> >  :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
> >  :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
> >
> > +check usage of CONFIG_IS_ENABLED vs IS_ENABLED:
> > +  stage: testsuites
> > +  script:
> > +- ./test/usage_of_is_enabled_check.sh
> > +
> >  # QA jobs for code analytics
> >  # static code analysis with cppcheck (we can add --enable=all later)
> >  cppcheck:
> > diff --git a/test/usage_of_is_enabled_check.sh
> b/test/usage_of_is_enabled_check.sh
> > new file mode 100755
> > index 000..0bc9bff8bd1
> > --- /dev/null
> > +++ b/test/usage_of_is_enabled_check.sh
> > @@ -0,0 +1,41 @@
> > +#!/bin/bash
> > +# generate list of CONFIGs that should use CONFIG_IS_ENABLED
>
> Could you add a few comments about the steps in here?
>

+# 1. all obj-$(CONFIG_$(SPL_)xxx in Makefiles
+# 2. all SPL_xxx in Kconfig files
+# 3. all CONFIG_CMD_xxx which already use CONFIG_IS_ENABLED
+#The Makefile for most if these use ifndef CONFIG_SPL_BUILD
+#instead of obj-$(CONFIG_$(SPL_)xxx
+# 4. A list of other configs that should use CONFIG_IS_ENABLED
+#Note: CONFIG_CLK was included to prevent a change in
test_checkpatch.py
+#which is checking for an error.
+#This list could be reduced if obj-$(CONFIG_$(SPL_)xxx was used
instead of
+#ifndef CONFIG_SPL_BUILD in Makefiles


>
> > +{ { git grep 'obj-$(CONFIG_$(SPL_'|grep Makefile|sed -e
> "s/SPL_TPL_/SPL_/"| \
> > +sed -n -r
> 's/obj\-\$\(CONFIG_\$\(SPL_\)([0-9a-zA-Z_]+)\)/\n\{\1\}\n/gp'| \
> > +sed -n -r 's/\{([0-9a-zA-Z_]+)\}/\1/p'; } ;\
> > +{ git grep -E 'config [ST]PL_'|grep Kconfig| \
> > +sed -n -r "s/config [ST]PL_([0-9a-zA-Z_]+)/\n\{\1\}\n/p" |
> > +sed -n -r 's/\{([0-9a-zA-Z_]+)\}/\1/p'; } ; \
> > +git grep -E 'CONFIG_IS_ENABLED\(CMD_'|sed -n -e
> "s/\(CONFIG_IS_ENABLED(CMD_[0-9a-zA-Z_]*)\)/\n\1\n/gp"| \
> > +sed -n -r "s/CONFIG_IS_ENABLED\((CMD_[0-9a-zA-Z_]+)\)/\1/p"; \
> > +echo -e "\
> > +BZIP2\n\
&

[PATCH] RFC: CI: add test/usage_of_is_enabled_check.sh

2023-01-31 Thread Troy Kisky
Add script usage_of_is_enabled_check to print any configs that
use CONFIG_IS_ENABLED instead of IS_ENABLED and vice versa.

Add usage_of_is_enabled_commit.sh to generate commits to fix the above
issues.

Signed-off-by: Troy Kisky 
---
 .azure-pipelines.yml   | 11 
 .gitlab-ci.yml |  5 
 test/usage_of_is_enabled_check.sh  | 41 ++
 test/usage_of_is_enabled_commit.sh | 38 +++
 4 files changed, 95 insertions(+)
 create mode 100755 test/usage_of_is_enabled_check.sh
 create mode 100755 test/usage_of_is_enabled_commit.sh

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 5673bb76afb..8e227512765 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -67,6 +67,17 @@ stages:
   :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
   :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+  - job: check_usage_of_is_enabled
+displayName: 'Check usage of CONFIG_IS_ENABLED vs IS_ENABLED'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  # generate list of SPL configs
+  - script: test/usage_of_is_enabled_check.sh
+
   - job: cppcheck
 displayName: 'Static code analysis with cppcheck'
 pool:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index aaf9d25abfc..6bb8efef258 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -134,6 +134,11 @@ check for new CONFIG symbols outside Kconfig:
 :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
 :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+check usage of CONFIG_IS_ENABLED vs IS_ENABLED:
+  stage: testsuites
+  script:
+- ./test/usage_of_is_enabled_check.sh
+
 # QA jobs for code analytics
 # static code analysis with cppcheck (we can add --enable=all later)
 cppcheck:
diff --git a/test/usage_of_is_enabled_check.sh 
b/test/usage_of_is_enabled_check.sh
new file mode 100755
index 000..0bc9bff8bd1
--- /dev/null
+++ b/test/usage_of_is_enabled_check.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+# generate list of CONFIGs that should use CONFIG_IS_ENABLED
+{ { git grep 'obj-$(CONFIG_$(SPL_'|grep Makefile|sed -e "s/SPL_TPL_/SPL_/"| \
+sed -n -r 's/obj\-\$\(CONFIG_\$\(SPL_\)([0-9a-zA-Z_]+)\)/\n\{\1\}\n/gp'| \
+sed -n -r 's/\{([0-9a-zA-Z_]+)\}/\1/p'; } ;\
+{ git grep -E 'config [ST]PL_'|grep Kconfig| \
+sed -n -r "s/config [ST]PL_([0-9a-zA-Z_]+)/\n\{\1\}\n/p" |
+sed -n -r 's/\{([0-9a-zA-Z_]+)\}/\1/p'; } ; \
+git grep -E 'CONFIG_IS_ENABLED\(CMD_'|sed -n -e 
"s/\(CONFIG_IS_ENABLED(CMD_[0-9a-zA-Z_]*)\)/\n\1\n/gp"| \
+sed -n -r "s/CONFIG_IS_ENABLED\((CMD_[0-9a-zA-Z_]+)\)/\1/p"; \
+echo -e "\
+BZIP2\n\
+CONFIG_CLK\n\
+DM_EVENT\n\
+EFI_DEVICE_PATH_TO_TEXT\n\
+EFI_LOADER\n\
+ERRNO_STR\n\
+GENERATE_SMBIOS_TABLE\n\
+";\
+} | sort -u >splcfg.tmp
+
+{
+# generate list of CONFIGs that incorrectly use CONFIG_IS_ENABLED
+git grep CONFIG_IS_ENABLED|sed -n -e 
"s/\(CONFIG_IS_ENABLED([0-9a-zA-Z_]*)\)/\n\1\n/gp"| \
+sed -n -r "s/CONFIG_IS_ENABLED\(([0-9a-zA-Z_]+)\)/\1/p" |sort -u| comm -23 - 
splcfg.tmp ;
+
+# generate list of CONFIGs that incorrectly use IS_ENABLED
+git grep -w IS_ENABLED|sed -n -e 
"s/\(IS_ENABLED(CONFIG_[0-9a-zA-Z_]*)\)/\n\1\n/gp"| \
+sed -n -r "s/IS_ENABLED\(CONFIG_([0-9a-zA-Z_]+)\)/\1/p" |sort -u| join - 
splcfg.tmp;
+} | grep -vw FOO;
+if [ $? -eq 0 ] ; then
+   echo "The above may have incorrect usage of 
IS_ENABLED/CONFIG_IS_ENABLED"
+   echo "Run test/usage_of_is_enabled_commit.sh and squash with 
appropriate commit"
+   ret=1;
+else
+   ret=0;
+fi
+
+rm splcfg.tmp
+exit ${ret}
+
diff --git a/test/usage_of_is_enabled_commit.sh 
b/test/usage_of_is_enabled_commit.sh
new file mode 100755
index 000..f776d0c69ab
--- /dev/null
+++ b/test/usage_of_is_enabled_commit.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+# generate list of CONFIGs that should use CONFIG_IS_ENABLED
+{ { git grep 'obj-$(CONFIG_$(SPL_'|grep Makefile|sed -e "s/SPL_TPL_/SPL_/"| \
+sed -n -r 's/obj\-\$\(CONFIG_\$\(SPL_\)([0-9a-zA-Z_]+)\)/\n\{\1\}\n/gp'| \
+sed -n -r 's/\{([0-9a-zA-Z_]+)\}/\1/p'; } ;\
+{ git grep -E 'config [ST]PL_'|grep Kconfig| \
+sed -n -r "s/config [ST]PL_([0-9a-zA-Z_]+)/\n\{\1\}\n/p" |
+sed -n -r 's/\{([0-9a-zA-Z_]+)\}/\1/p'; } ; \
+git grep -E 'CONFIG_IS_ENABLED\(CMD_'|sed -n -e 
"s/\(CONFIG_IS_ENABLED(CMD_[0-9a-zA-Z_]*)\)/\n\1\n/gp"| \
+sed -n -r "s/CONFIG_IS_ENABLED\((CMD_[0-9a-zA-Z_]+)\)/\1/p"; \
+echo -e "\
+BZIP2\n\
+CONFIG_CLK\n\
+DM_EVENT\n\
+EFI_DEVICE_PATH_TO_TEXT\n\
+EFI_LOADER\n\
+ERRNO_STR\n\
+GENERATE_SMBIOS_TABLE\n\
+";\
+} | sort -u >splcfg.tmp
+
+
+git grep CONFIG_IS_ENABLED|sed 

Re: CONFIG_IS_ENABLED vs IS_ENABLED

2023-01-30 Thread Troy Kisky
On Mon, Jan 30, 2023 at 11:44 AM Tom Rini  wrote:

> On Mon, Jan 30, 2023 at 10:51:03AM -0800, Troy Kisky wrote:
> > Hi Tom
> >
> >
> > On Mon, Jan 30, 2023 at 9:18 AM Tom Rini  wrote:
> >
> > > On Sat, Jan 28, 2023 at 09:25:54AM -0800, Troy Kisky wrote:
> > > > Thanks Tom,
> > > >
> > > > I cleaned up the PR based on the CI results. Here's my current
> changes.
> > > >
> > > > Author: Troy Kisky 
> > > > Date:   Fri Jan 27 11:03:11 2023 -0800
> > > >
> > > > dm: device-internal: use EVENT instead of DM_EVENT, because
> > > > event_notify is built for EVENT
> > > >
> > > > Signed-off-by: Troy Kisky 
> > > >
> > > > diff --git a/include/dm/device-internal.h
> b/include/dm/device-internal.h
> > > > index f31c4702086..2e725aa9416 100644
> > > > --- a/include/dm/device-internal.h
> > > > +++ b/include/dm/device-internal.h
> > > > @@ -431,7 +431,7 @@ static inline void devres_release_all(struct
> udevice
> > > > *dev)
> > > >
> > > >  static inline int device_notify(const struct udevice *dev, enum
> event_t
> > > > type)
> > > >  {
> > > > -#if CONFIG_IS_ENABLED(DM_EVENT)
> > > > +#if CONFIG_IS_ENABLED(EVENT)
> > > > return event_notify(type, &dev, sizeof(dev));
> > > >  #else
> > > > return 0;
> > >
> > > Given 448e2b6327d0 ("event: Correct dependencies on the EVENT
> > > framework") I'm a little worried about this change here and want to be
> > > extra sure it doesn't break something inadvertently.
> >
> >
> > event_notify is in common/event, and the Makefile has
> > obj-$(CONFIG_$(SPL_TPL_)EVENT) += event.o
> >
> > So, the other option is to change the Makefile line to
> >   obj-$(CONFIG_$(SPL_TPL_)DM_EVENT) += event.o
> >
> > I don't know which is best.
>
> Right, event_notify is part of the general event framework. The function
> above, device_notify, is part of DM_EVENT. This should probably be
> IS_ENABLED and not CONFIG_IS_ENABLED.
>
>
I think DM_EVENT should be globally replaced by  EVENT. It doesn't seem to
control much.
Alternatively, I could add DM_EVENT to my SPL config list.
changing to IS_ENABLED  is what my script did before this patch, and caused
CI to fail.


Simon ?


> >   Aside from that,
> > > are you able to post your series?
> >
> >
> >
> > I was hoping each of the maintainers could run the script and see if the
> > patches for their area make sense.
> > I don't need my sign-off on any of the patches.
>
> Ah.  I'm not sure how likely that is to happen.
>
> >   And incorporate your checking script
> > > in to .gitlab-ci.yml / .azure-pipline.yml ?
> > >
> >
> > I'll post a patch for that as an RFC
>
> OK.
>
> --
> Tom
>


Re: CONFIG_IS_ENABLED vs IS_ENABLED

2023-01-30 Thread Troy Kisky
Hi Tom


On Mon, Jan 30, 2023 at 9:18 AM Tom Rini  wrote:

> On Sat, Jan 28, 2023 at 09:25:54AM -0800, Troy Kisky wrote:
> > Thanks Tom,
> >
> > I cleaned up the PR based on the CI results. Here's my current changes.
> >
> > Author: Troy Kisky 
> > Date:   Fri Jan 27 11:03:11 2023 -0800
> >
> > dm: device-internal: use EVENT instead of DM_EVENT, because
> > event_notify is built for EVENT
> >
> > Signed-off-by: Troy Kisky 
> >
> > diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
> > index f31c4702086..2e725aa9416 100644
> > --- a/include/dm/device-internal.h
> > +++ b/include/dm/device-internal.h
> > @@ -431,7 +431,7 @@ static inline void devres_release_all(struct udevice
> > *dev)
> >
> >  static inline int device_notify(const struct udevice *dev, enum event_t
> > type)
> >  {
> > -#if CONFIG_IS_ENABLED(DM_EVENT)
> > +#if CONFIG_IS_ENABLED(EVENT)
> > return event_notify(type, &dev, sizeof(dev));
> >  #else
> > return 0;
>
> Given 448e2b6327d0 ("event: Correct dependencies on the EVENT
> framework") I'm a little worried about this change here and want to be
> extra sure it doesn't break something inadvertently.


event_notify is in common/event, and the Makefile has
obj-$(CONFIG_$(SPL_TPL_)EVENT) += event.o

So, the other option is to change the Makefile line to
  obj-$(CONFIG_$(SPL_TPL_)DM_EVENT) += event.o

I don't know which is best.



>   Aside from that,
> are you able to post your series?



I was hoping each of the maintainers could run the script and see if the
patches for their area make sense.
I don't need my sign-off on any of the patches.

  And incorporate your checking script
> in to .gitlab-ci.yml / .azure-pipline.yml ?
>

I'll post a patch for that as an RFC


>
> --
> Tom
>


  1   2   3   4   5   6   7   8   >