[PATCH 0/5] Fix inclusion guards

A patch by Sam [1] reminded me to check for misspelled inclusion guards. I wrote some crude tool, with a high false positive rate, and was able to find some other occurences where the "#ifndef" and "#define" parts were not matching.
Those patches fix those preprocessor symbols. One header wasn't actually used anymore, so just remove that whole file.
Cheers, Andre
[1] https://lore.kernel.org/u-boot/20230512212214.130908-1-CFSworks@gmail.com/
Andre Przywara (5): imx: fix header inclusion guards arm: uniphier: fix header inclusion guard freescale: fix header inclusion guard exynos: fix header inclusion guard faraday: remove orphaned header file
arch/arm/include/asm/arch-imx8m/sys_proto.h | 2 +- arch/arm/include/asm/arch-imx8ulp/sys_proto.h | 2 +- arch/arm/include/asm/arch-imx9/sys_proto.h | 2 +- arch/arm/mach-uniphier/dram/ddrphy-init.h | 2 +- board/freescale/common/vsc3316_3308.h | 2 +- drivers/pinctrl/exynos/pinctrl-exynos.h | 2 +- include/faraday/ftahbc020s.h | 46 ------------------- include/imx_sip.h | 2 +- 8 files changed, 7 insertions(+), 53 deletions(-) delete mode 100644 include/faraday/ftahbc020s.h

It seems like the header inclusion guards for some IMX related headers were misspelled or got out of sync.
Make the preprocessor symbols for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com --- arch/arm/include/asm/arch-imx8m/sys_proto.h | 2 +- arch/arm/include/asm/arch-imx8ulp/sys_proto.h | 2 +- arch/arm/include/asm/arch-imx9/sys_proto.h | 2 +- include/imx_sip.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/include/asm/arch-imx8m/sys_proto.h b/arch/arm/include/asm/arch-imx8m/sys_proto.h index 55b46afaf78..4ed8e954e31 100644 --- a/arch/arm/include/asm/arch-imx8m/sys_proto.h +++ b/arch/arm/include/asm/arch-imx8m/sys_proto.h @@ -4,7 +4,7 @@ */
#ifndef __ARCH_IMX8M_SYS_PROTO_H -#define __ARCH_NMX8M_SYS_PROTO_H +#define __ARCH_IMX8M_SYS_PROTO_H
#include <asm/mach-imx/sys_proto.h> #include <asm/arch/imx-regs.h> diff --git a/arch/arm/include/asm/arch-imx8ulp/sys_proto.h b/arch/arm/include/asm/arch-imx8ulp/sys_proto.h index 5bbae21e37c..95bf753a766 100644 --- a/arch/arm/include/asm/arch-imx8ulp/sys_proto.h +++ b/arch/arm/include/asm/arch-imx8ulp/sys_proto.h @@ -4,7 +4,7 @@ */
#ifndef __ARCH_IMX8ULP_SYS_PROTO_H -#define __ARCH_NMX8ULP_SYS_PROTO_H +#define __ARCH_IMX8ULP_SYS_PROTO_H
#include <asm/mach-imx/sys_proto.h>
diff --git a/arch/arm/include/asm/arch-imx9/sys_proto.h b/arch/arm/include/asm/arch-imx9/sys_proto.h index ba97f92f5ae..2f7a1292758 100644 --- a/arch/arm/include/asm/arch-imx9/sys_proto.h +++ b/arch/arm/include/asm/arch-imx9/sys_proto.h @@ -4,7 +4,7 @@ */
#ifndef __ARCH_IMX9_SYS_PROTO_H -#define __ARCH_NMX9_SYS_PROTO_H +#define __ARCH_IMX9_SYS_PROTO_H
#include <asm/mach-imx/sys_proto.h>
diff --git a/include/imx_sip.h b/include/imx_sip.h index 1b873f231be..ebbb3a16d7e 100644 --- a/include/imx_sip.h +++ b/include/imx_sip.h @@ -4,7 +4,7 @@ */
#ifndef _IMX_SIP_H__ -#define _IMX_SIP_H_ +#define _IMX_SIP_H__
#define IMX_SIP_GPC 0xC2000000 #define IMX_SIP_GPC_PM_DOMAIN 0x03

On Mon, May 15, 2023 at 02:52:10PM +0100, Andre Przywara wrote:
It seems like the header inclusion guards for some IMX related headers were misspelled or got out of sync.
Make the preprocessor symbols for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com
Reviewed-by: Tom Rini trini@konsulko.com

On Mon, May 15, 2023 at 02:52:10PM +0100, Andre Przywara wrote:
It seems like the header inclusion guards for some IMX related headers were misspelled or got out of sync.
Make the preprocessor symbols for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/next, thanks!

It seems like the header inclusion guard for some Uniphier DDR PHY header was misspelled.
Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com --- arch/arm/mach-uniphier/dram/ddrphy-init.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-uniphier/dram/ddrphy-init.h b/arch/arm/mach-uniphier/dram/ddrphy-init.h index 09981f6e06f..4431f5c0ba6 100644 --- a/arch/arm/mach-uniphier/dram/ddrphy-init.h +++ b/arch/arm/mach-uniphier/dram/ddrphy-init.h @@ -4,7 +4,7 @@ */
#ifndef ARCH_DDRPHY_INIT_H -#define ARCH_DDRPHY_INTT_H +#define ARCH_DDRPHY_INIT_H
#include <linux/compiler.h> #include <linux/types.h>

On Mon, May 15, 2023 at 02:52:11PM +0100, Andre Przywara wrote:
It seems like the header inclusion guard for some Uniphier DDR PHY header was misspelled.
Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com
Reviewed-by: Tom Rini trini@konsulko.com

On Mon, May 15, 2023 at 02:52:11PM +0100, Andre Przywara wrote:
It seems like the header inclusion guard for some Uniphier DDR PHY header was misspelled.
Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/next, thanks!

It seems like the header inclusion guard for some Freescale crosspoint switch header was misspelled.
Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com --- board/freescale/common/vsc3316_3308.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/board/freescale/common/vsc3316_3308.h b/board/freescale/common/vsc3316_3308.h index 49a684f9f49..8d343ba4d65 100644 --- a/board/freescale/common/vsc3316_3308.h +++ b/board/freescale/common/vsc3316_3308.h @@ -4,7 +4,7 @@ */
#ifndef __VSC_CROSSBAR_H_ -#define __VSC_CROSSBAR_H 1_ +#define __VSC_CROSSBAR_H_
#include <common.h> #include <i2c.h>

H Andre,
On Mon, May 15, 2023 at 10:52 AM Andre Przywara andre.przywara@arm.com wrote:
It seems like the header inclusion guard for some Freescale crosspoint switch header was misspelled.
Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com
board/freescale/common/vsc3316_3308.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/board/freescale/common/vsc3316_3308.h b/board/freescale/common/vsc3316_3308.h index 49a684f9f49..8d343ba4d65 100644 --- a/board/freescale/common/vsc3316_3308.h +++ b/board/freescale/common/vsc3316_3308.h @@ -4,7 +4,7 @@ */
#ifndef __VSC_CROSSBAR_H_ -#define __VSC_CROSSBAR_H 1_ +#define __VSC_CROSSBAR_H_
The change is correct, but it does not match the Subject/commit log.

On Mon, 15 May 2023 11:17:14 -0300 Fabio Estevam festevam@gmail.com wrote:
Hi Fabio,
On Mon, May 15, 2023 at 10:52 AM Andre Przywara andre.przywara@arm.com wrote:
It seems like the header inclusion guard for some Freescale crosspoint switch header was misspelled.
Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com
board/freescale/common/vsc3316_3308.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/board/freescale/common/vsc3316_3308.h b/board/freescale/common/vsc3316_3308.h index 49a684f9f49..8d343ba4d65 100644 --- a/board/freescale/common/vsc3316_3308.h +++ b/board/freescale/common/vsc3316_3308.h @@ -4,7 +4,7 @@ */
#ifndef __VSC_CROSSBAR_H_ -#define __VSC_CROSSBAR_H 1_ +#define __VSC_CROSSBAR_H_
The change is correct, but it does not match the Subject/commit log.
What do you mean, exactly? To put *some* context into the commit message, I tried to find out what this "vsc" device is about, and found "crosspoint switch" somewhere (doc/README.VSC3316-3308). Is that not what it is about? Or is not a Freescale device, but just used by Freescale SoCs? Some T208 hardware seems to be the only user, though.
Can you suggest a better description?
Cheers, Andre

Hi Andre,
What do you mean, exactly? To put *some* context into the commit message, I tried to find out what this "vsc" device is about, and found "crosspoint switch" somewhere (doc/README.VSC3316-3308). Is that not what it is about? Or is not a Freescale device, but just used by Freescale SoCs? Some T208 hardware seems to be the only user, though.
The VSC3316 is a switch manufactured by Microchip: https://www.microsemi.com/product-directory/digital-crosspoint-switches/3998...
Can you suggest a better description?
What about:
Subject: freescale: vsc3316_3308: fix header inclusion guard
It seems like the header inclusion guard for the vsc3316_3308 switch header was misspelled.
Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

On Mon, May 15, 2023 at 02:52:12PM +0100, Andre Przywara wrote:
It seems like the header inclusion guard for some Freescale crosspoint switch header was misspelled.
Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com
Reviewed-by: Tom Rini trini@konsulko.com

On Mon, May 15, 2023 at 02:52:12PM +0100, Andre Przywara wrote:
It seems like the header inclusion guard for some Freescale crosspoint switch header was misspelled.
Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/next, thanks!

It seems like the header inclusion guard for the Exynos pinctrl header was misspelled.
Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com --- drivers/pinctrl/exynos/pinctrl-exynos.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/exynos/pinctrl-exynos.h b/drivers/pinctrl/exynos/pinctrl-exynos.h index a7788b76d90..cbc5174b48c 100644 --- a/drivers/pinctrl/exynos/pinctrl-exynos.h +++ b/drivers/pinctrl/exynos/pinctrl-exynos.h @@ -6,7 +6,7 @@ */
#ifndef __PINCTRL_EXYNOS_H_ -#define __PINCTRL_EXYNOS__H_ +#define __PINCTRL_EXYNOS_H_
#define PIN_CON 0x00 /* Offset of pin function register */ #define PIN_DAT 0x04 /* Offset of pin data register */

On Mon, May 15, 2023 at 02:52:13PM +0100, Andre Przywara wrote:
It seems like the header inclusion guard for the Exynos pinctrl header was misspelled.
Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com
Reviewed-by: Tom Rini trini@konsulko.com

On Mon, May 15, 2023 at 02:52:13PM +0100, Andre Przywara wrote:
It seems like the header inclusion guard for the Exynos pinctrl header was misspelled.
Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.
Signed-off-by: Andre Przywara andre.przywara@arm.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/next, thanks!

Commit 11232139e399 ("nds32: Remove the architecture") removed the nds32 architecture, and with it the last user of the Faraday AHB controller header file.
Consequently remove that header file as well.
This was found because the inclusion guard was misspelled.
Signed-off-by: Andre Przywara andre.przywara@arm.com --- include/faraday/ftahbc020s.h | 46 ------------------------------------ 1 file changed, 46 deletions(-) delete mode 100644 include/faraday/ftahbc020s.h
diff --git a/include/faraday/ftahbc020s.h b/include/faraday/ftahbc020s.h deleted file mode 100644 index e628156c151..00000000000 --- a/include/faraday/ftahbc020s.h +++ /dev/null @@ -1,46 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Copyright (C) 2011 Andes Technology Corporation - * Macpaul Lin, Andes Technology Corporation macpaul@andestech.com - */ - -/* FTAHBC020S - AHB Controller (Arbiter/Decoder) definitions */ -#ifndef __FTAHBC020S_H -#define __FTAHBC202S_H - -/* Registers Offsets */ - -/* - * AHB Slave BSR, offset: n * 4, n=0~31 - */ -#ifndef __ASSEMBLY__ -struct ftahbc02s { - unsigned int s_bsr[32]; /* 0x00-0x7c - Slave n Base/Size Reg */ - unsigned int pcr; /* 0x80 - Priority Ctrl Reg */ - unsigned int tcrg; /* 0x84 - Transfer Ctrl Reg */ - unsigned int cr; /* 0x88 - Ctrl Reg */ -}; -#endif /* __ASSEMBLY__ */ - -/* - * FTAHBC020S_SLAVE_BSR - Slave n Base / Size Register - */ -#define FTAHBC020S_SLAVE_BSR_BASE(x) (((x) & 0xfff) << 20) -#define FTAHBC020S_SLAVE_BSR_SIZE(x) (((x) & 0xf) << 16) -/* The value of b(16:19)SLAVE_BSR_SIZE: 1M-2048M, must be power of 2 */ -#define FTAHBC020S_BSR_SIZE(x) (ffs(x) - 1) /* size of Addr Space */ - -/* - * FTAHBC020S_PCR - Priority Control Register - */ -#define FTAHBC020S_PCR_PLEVEL_(x) (1 << (x)) /* x: 1-15 */ - -/* - * FTAHBC020S_CR - Interrupt Control Register - */ -#define FTAHBC020S_CR_INTSTS (1 << 24) -#define FTAHBC020S_CR_RESP(x) (((x) & 0x3) << 20) -#define FTAHBC020S_CR_INTSMASK (1 << 16) -#define FTAHBC020S_CR_REMAP (1 << 0) - -#endif /* __FTAHBC020S_H */

On Mon, May 15, 2023 at 02:52:14PM +0100, Andre Przywara wrote:
Commit 11232139e399 ("nds32: Remove the architecture") removed the nds32 architecture, and with it the last user of the Faraday AHB controller header file.
Consequently remove that header file as well.
This was found because the inclusion guard was misspelled.
Signed-off-by: Andre Przywara andre.przywara@arm.com
Fixes: 11232139e399 ("nds32: Remove the architecture") Reviewed-by: Tom Rini trini@konsulko.com

On Mon, May 15, 2023 at 02:52:14PM +0100, Andre Przywara wrote:
Commit 11232139e399 ("nds32: Remove the architecture") removed the nds32 architecture, and with it the last user of the Faraday AHB controller header file.
Consequently remove that header file as well.
This was found because the inclusion guard was misspelled.
Signed-off-by: Andre Przywara andre.przywara@arm.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/next, thanks!

On Mon, May 15, 2023 at 02:52:09PM +0100, Andre Przywara wrote:
A patch by Sam [1] reminded me to check for misspelled inclusion guards. I wrote some crude tool, with a high false positive rate, and was able to find some other occurences where the "#ifndef" and "#define" parts were not matching.
Those patches fix those preprocessor symbols. One header wasn't actually used anymore, so just remove that whole file.
This got me to do a related quick check and I see a handful of unused include files. I'll follow up with that.
participants (3)
-
Andre Przywara
-
Fabio Estevam
-
Tom Rini