linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] pinctrl: mpfs-iomux0: fix compile-time constant warning for LLVM prior to 17
@ 2025-10-29 15:29 Conor Dooley
  2025-10-29 17:20 ` Nathan Chancellor
  2025-10-30  8:18 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Conor Dooley @ 2025-10-29 15:29 UTC (permalink / raw)
  To: linux-gpio
  Cc: conor, Conor Dooley, Nathan Chancellor, Daire McNamara,
	Linus Walleij, Nick Desaulniers, Bill Wendling, Justin Stitt,
	linux-riscv, linux-kernel, llvm

From: Conor Dooley <conor.dooley@microchip.com>

With LLVM prior to 17.0.0:

drivers/pinctrl/pinctrl-mpfs-iomux0.c:89:2: error: initializer element is not a compile-time constant
        MPFS_IOMUX0_GROUP(spi0),
        ^~~~~~~~~~~~~~~~~~~~~~~
drivers/pinctrl/pinctrl-mpfs-iomux0.c:79:10: note: expanded from macro 'MPFS_IOMUX0_GROUP'
        .mask = BIT(mpfs_iomux0_##_name##_pins[0]),     \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/vdso/bits.h:7:19: note: expanded from macro 'BIT'
\#define BIT(nr)                 (UL(1) << (nr))
                                ^~~~~~~~~~~~~~~

This is a constant, but LLVM prior to a change from Nick to match the
gcc behaviour did not allow this. The macro isn't really all that much
of an idiot-proofing, just change it to the same sort that's in the
gpio2 driver, where a second argument provides the mask/setting.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: https://github.com/ClangBuiltLinux/linux/issues/2140
Fixes: 46397274da22 ("pinctrl: add polarfire soc iomux0 pinmux driver")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
---

Not entirely sold on the fixes tag since it's to shut up an old
compiler, but no harm in it I guess.

CC: Conor Dooley <conor.dooley@microchip.com>
CC: Daire McNamara <daire.mcnamara@microchip.com>
CC: Linus Walleij <linus.walleij@linaro.org>
CC: Nathan Chancellor <nathan@kernel.org>
CC: Nick Desaulniers <nick.desaulniers+lkml@gmail.com>
CC: Bill Wendling <morbo@google.com>
CC: Justin Stitt <justinstitt@google.com>
CC: linux-riscv@lists.infradead.org
CC: linux-gpio@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: llvm@lists.linux.dev
---
 drivers/pinctrl/pinctrl-mpfs-iomux0.c | 36 +++++++++++++--------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-mpfs-iomux0.c b/drivers/pinctrl/pinctrl-mpfs-iomux0.c
index 49d9fcec0a16..cf5b2e4e8f5b 100644
--- a/drivers/pinctrl/pinctrl-mpfs-iomux0.c
+++ b/drivers/pinctrl/pinctrl-mpfs-iomux0.c
@@ -73,33 +73,33 @@ static const unsigned int mpfs_iomux0_uart4_pins[] = { 11 };
 static const unsigned int mpfs_iomux0_mdio0_pins[] = { 12 };
 static const unsigned int mpfs_iomux0_mdio1_pins[] = { 13 };
 
-#define MPFS_IOMUX0_GROUP(_name) { \
+#define MPFS_IOMUX0_GROUP(_name, _mask) { \
 	.name = #_name "_mssio",	\
 	.pins = mpfs_iomux0_##_name##_pins,	\
-	.mask = BIT(mpfs_iomux0_##_name##_pins[0]),	\
+	.mask = _mask,	\
 	.setting = 0x0,	\
 }, { \
 	.name = #_name "_fabric",	\
 	.pins = mpfs_iomux0_##_name##_pins,	\
-	.mask = BIT(mpfs_iomux0_##_name##_pins[0]),	\
-	.setting = BIT(mpfs_iomux0_##_name##_pins[0]),	\
+	.mask = _mask,	\
+	.setting = _mask,	\
 }
 
 static const struct mpfs_iomux0_pin_group mpfs_iomux0_pin_groups[] = {
-	MPFS_IOMUX0_GROUP(spi0),
-	MPFS_IOMUX0_GROUP(spi1),
-	MPFS_IOMUX0_GROUP(i2c0),
-	MPFS_IOMUX0_GROUP(i2c1),
-	MPFS_IOMUX0_GROUP(can0),
-	MPFS_IOMUX0_GROUP(can1),
-	MPFS_IOMUX0_GROUP(qspi),
-	MPFS_IOMUX0_GROUP(uart0),
-	MPFS_IOMUX0_GROUP(uart1),
-	MPFS_IOMUX0_GROUP(uart2),
-	MPFS_IOMUX0_GROUP(uart3),
-	MPFS_IOMUX0_GROUP(uart4),
-	MPFS_IOMUX0_GROUP(mdio0),
-	MPFS_IOMUX0_GROUP(mdio1),
+	MPFS_IOMUX0_GROUP(spi0, BIT(0)),
+	MPFS_IOMUX0_GROUP(spi1, BIT(1)),
+	MPFS_IOMUX0_GROUP(i2c0, BIT(2)),
+	MPFS_IOMUX0_GROUP(i2c1, BIT(3)),
+	MPFS_IOMUX0_GROUP(can0, BIT(4)),
+	MPFS_IOMUX0_GROUP(can1, BIT(5)),
+	MPFS_IOMUX0_GROUP(qspi, BIT(6)),
+	MPFS_IOMUX0_GROUP(uart0, BIT(7)),
+	MPFS_IOMUX0_GROUP(uart1, BIT(8)),
+	MPFS_IOMUX0_GROUP(uart2, BIT(9)),
+	MPFS_IOMUX0_GROUP(uart3, BIT(10)),
+	MPFS_IOMUX0_GROUP(uart4, BIT(11)),
+	MPFS_IOMUX0_GROUP(mdio0, BIT(12)),
+	MPFS_IOMUX0_GROUP(mdio1, BIT(13)),
 };
 
 static const char * const mpfs_iomux0_spi0_groups[] = { "spi0_mssio", "spi0_fabric" };
-- 
2.51.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] pinctrl: mpfs-iomux0: fix compile-time constant warning for LLVM prior to 17
  2025-10-29 15:29 [PATCH v1] pinctrl: mpfs-iomux0: fix compile-time constant warning for LLVM prior to 17 Conor Dooley
@ 2025-10-29 17:20 ` Nathan Chancellor
  2025-10-30  8:18 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2025-10-29 17:20 UTC (permalink / raw)
  To: Conor Dooley
  Cc: linux-gpio, Conor Dooley, Daire McNamara, Linus Walleij,
	Nick Desaulniers, Bill Wendling, Justin Stitt, linux-riscv,
	linux-kernel, llvm

On Wed, Oct 29, 2025 at 03:29:35PM +0000, Conor Dooley wrote:
> From: Conor Dooley <conor.dooley@microchip.com>
> 
> With LLVM prior to 17.0.0:
> 
> drivers/pinctrl/pinctrl-mpfs-iomux0.c:89:2: error: initializer element is not a compile-time constant
>         MPFS_IOMUX0_GROUP(spi0),
>         ^~~~~~~~~~~~~~~~~~~~~~~
> drivers/pinctrl/pinctrl-mpfs-iomux0.c:79:10: note: expanded from macro 'MPFS_IOMUX0_GROUP'
>         .mask = BIT(mpfs_iomux0_##_name##_pins[0]),     \
>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/vdso/bits.h:7:19: note: expanded from macro 'BIT'
> \#define BIT(nr)                 (UL(1) << (nr))
>                                 ^~~~~~~~~~~~~~~
> 
> This is a constant, but LLVM prior to a change from Nick to match the
> gcc behaviour did not allow this. The macro isn't really all that much
> of an idiot-proofing, just change it to the same sort that's in the
> gpio2 driver, where a second argument provides the mask/setting.
> 
> Reported-by: Nathan Chancellor <nathan@kernel.org>
> Link: https://github.com/ClangBuiltLinux/linux/issues/2140
> Fixes: 46397274da22 ("pinctrl: add polarfire soc iomux0 pinmux driver")
> Signed-off-by: Conor Dooley <conor.dooley@microchip.com>

Thanks a lot for the quick fix!

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
> Not entirely sold on the fixes tag since it's to shut up an old
> compiler, but no harm in it I guess.
> 
> CC: Conor Dooley <conor.dooley@microchip.com>
> CC: Daire McNamara <daire.mcnamara@microchip.com>
> CC: Linus Walleij <linus.walleij@linaro.org>
> CC: Nathan Chancellor <nathan@kernel.org>
> CC: Nick Desaulniers <nick.desaulniers+lkml@gmail.com>
> CC: Bill Wendling <morbo@google.com>
> CC: Justin Stitt <justinstitt@google.com>
> CC: linux-riscv@lists.infradead.org
> CC: linux-gpio@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: llvm@lists.linux.dev
> ---
>  drivers/pinctrl/pinctrl-mpfs-iomux0.c | 36 +++++++++++++--------------
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-mpfs-iomux0.c b/drivers/pinctrl/pinctrl-mpfs-iomux0.c
> index 49d9fcec0a16..cf5b2e4e8f5b 100644
> --- a/drivers/pinctrl/pinctrl-mpfs-iomux0.c
> +++ b/drivers/pinctrl/pinctrl-mpfs-iomux0.c
> @@ -73,33 +73,33 @@ static const unsigned int mpfs_iomux0_uart4_pins[] = { 11 };
>  static const unsigned int mpfs_iomux0_mdio0_pins[] = { 12 };
>  static const unsigned int mpfs_iomux0_mdio1_pins[] = { 13 };
>  
> -#define MPFS_IOMUX0_GROUP(_name) { \
> +#define MPFS_IOMUX0_GROUP(_name, _mask) { \
>  	.name = #_name "_mssio",	\
>  	.pins = mpfs_iomux0_##_name##_pins,	\
> -	.mask = BIT(mpfs_iomux0_##_name##_pins[0]),	\
> +	.mask = _mask,	\
>  	.setting = 0x0,	\
>  }, { \
>  	.name = #_name "_fabric",	\
>  	.pins = mpfs_iomux0_##_name##_pins,	\
> -	.mask = BIT(mpfs_iomux0_##_name##_pins[0]),	\
> -	.setting = BIT(mpfs_iomux0_##_name##_pins[0]),	\
> +	.mask = _mask,	\
> +	.setting = _mask,	\
>  }
>  
>  static const struct mpfs_iomux0_pin_group mpfs_iomux0_pin_groups[] = {
> -	MPFS_IOMUX0_GROUP(spi0),
> -	MPFS_IOMUX0_GROUP(spi1),
> -	MPFS_IOMUX0_GROUP(i2c0),
> -	MPFS_IOMUX0_GROUP(i2c1),
> -	MPFS_IOMUX0_GROUP(can0),
> -	MPFS_IOMUX0_GROUP(can1),
> -	MPFS_IOMUX0_GROUP(qspi),
> -	MPFS_IOMUX0_GROUP(uart0),
> -	MPFS_IOMUX0_GROUP(uart1),
> -	MPFS_IOMUX0_GROUP(uart2),
> -	MPFS_IOMUX0_GROUP(uart3),
> -	MPFS_IOMUX0_GROUP(uart4),
> -	MPFS_IOMUX0_GROUP(mdio0),
> -	MPFS_IOMUX0_GROUP(mdio1),
> +	MPFS_IOMUX0_GROUP(spi0, BIT(0)),
> +	MPFS_IOMUX0_GROUP(spi1, BIT(1)),
> +	MPFS_IOMUX0_GROUP(i2c0, BIT(2)),
> +	MPFS_IOMUX0_GROUP(i2c1, BIT(3)),
> +	MPFS_IOMUX0_GROUP(can0, BIT(4)),
> +	MPFS_IOMUX0_GROUP(can1, BIT(5)),
> +	MPFS_IOMUX0_GROUP(qspi, BIT(6)),
> +	MPFS_IOMUX0_GROUP(uart0, BIT(7)),
> +	MPFS_IOMUX0_GROUP(uart1, BIT(8)),
> +	MPFS_IOMUX0_GROUP(uart2, BIT(9)),
> +	MPFS_IOMUX0_GROUP(uart3, BIT(10)),
> +	MPFS_IOMUX0_GROUP(uart4, BIT(11)),
> +	MPFS_IOMUX0_GROUP(mdio0, BIT(12)),
> +	MPFS_IOMUX0_GROUP(mdio1, BIT(13)),
>  };
>  
>  static const char * const mpfs_iomux0_spi0_groups[] = { "spi0_mssio", "spi0_fabric" };
> -- 
> 2.51.0
> 

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] pinctrl: mpfs-iomux0: fix compile-time constant warning for LLVM prior to 17
  2025-10-29 15:29 [PATCH v1] pinctrl: mpfs-iomux0: fix compile-time constant warning for LLVM prior to 17 Conor Dooley
  2025-10-29 17:20 ` Nathan Chancellor
@ 2025-10-30  8:18 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2025-10-30  8:18 UTC (permalink / raw)
  To: Conor Dooley
  Cc: linux-gpio, Conor Dooley, Nathan Chancellor, Daire McNamara,
	Nick Desaulniers, Bill Wendling, Justin Stitt, linux-riscv,
	linux-kernel, llvm

On Wed, Oct 29, 2025 at 4:30 PM Conor Dooley <conor@kernel.org> wrote:

> From: Conor Dooley <conor.dooley@microchip.com>
>
> With LLVM prior to 17.0.0:
>
> drivers/pinctrl/pinctrl-mpfs-iomux0.c:89:2: error: initializer element is not a compile-time constant
>         MPFS_IOMUX0_GROUP(spi0),
>         ^~~~~~~~~~~~~~~~~~~~~~~
> drivers/pinctrl/pinctrl-mpfs-iomux0.c:79:10: note: expanded from macro 'MPFS_IOMUX0_GROUP'
>         .mask = BIT(mpfs_iomux0_##_name##_pins[0]),     \
>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/vdso/bits.h:7:19: note: expanded from macro 'BIT'
> \#define BIT(nr)                 (UL(1) << (nr))
>                                 ^~~~~~~~~~~~~~~
>
> This is a constant, but LLVM prior to a change from Nick to match the
> gcc behaviour did not allow this. The macro isn't really all that much
> of an idiot-proofing, just change it to the same sort that's in the
> gpio2 driver, where a second argument provides the mask/setting.
>
> Reported-by: Nathan Chancellor <nathan@kernel.org>
> Link: https://github.com/ClangBuiltLinux/linux/issues/2140
> Fixes: 46397274da22 ("pinctrl: add polarfire soc iomux0 pinmux driver")
> Signed-off-by: Conor Dooley <conor.dooley@microchip.com>

Patch applied!

Yours,
Linus Walleij

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-30  8:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-29 15:29 [PATCH v1] pinctrl: mpfs-iomux0: fix compile-time constant warning for LLVM prior to 17 Conor Dooley
2025-10-29 17:20 ` Nathan Chancellor
2025-10-30  8:18 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).