[PATCH FIX] mfd: sec-irq: fix non-constant case labels in s2mu005_irq_get_reg

Łukasz Lebiedziński posted 1 patch 1 day, 16 hours ago
drivers/mfd/sec-irq.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
[PATCH FIX] mfd: sec-irq: fix non-constant case labels in s2mu005_irq_get_reg
Posted by Łukasz Lebiedziński 1 day, 16 hours ago
Case labels must be compile-time constants, but the original
implementation used array element values like irqf_regs[0], causing
a compilation error:

  drivers/mfd/sec-irq.c:218:9: error: case label does not reduce to
  an integer constant

Replace array-based case labels with explicit S2MU005_REG_* defines
for all four interrupt status and mask registers, preserving the
original logic.

This addresses an issue in the S2MU005 PMIC support patches [1].

Link: https://lore.kernel.org/all/20260126-s2mu005-pmic-v2-6-78f1a75f547a@disroot.org/#Z31drivers:mfd:sec-irq.c [1]
Signed-off-by: Łukasz Lebiedziński <kernel@lvkasz.us>
---
 drivers/mfd/sec-irq.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c
index 44a1eb074a08..73a611ba0502 100644
--- a/drivers/mfd/sec-irq.c
+++ b/drivers/mfd/sec-irq.c
@@ -215,9 +215,15 @@ static unsigned int s2mu005_irq_get_reg(struct regmap_irq_chip_data *data,
 	};
 
 	switch (base) {
-	case irqf_regs[0]:
+	case S2MU005_REG_CHGR_INT1:
+	case S2MU005_REG_FLED_INT1:
+	case S2MU005_REG_MUIC_INT1:
+	case S2MU005_REG_MUIC_INT2:
 		return irqf_regs[index];
-	case mask_regs[0]:
+	case S2MU005_REG_CHGR_INT1M:
+	case S2MU005_REG_FLED_INT1M:
+	case S2MU005_REG_MUIC_INT1M:
+	case S2MU005_REG_MUIC_INT2M:
 		return mask_regs[index];
 	}
 
-- 
2.53.0

Re: [PATCH FIX] mfd: sec-irq: fix non-constant case labels in s2mu005_irq_get_reg
Posted by Kaustabh Chakraborty 1 day, 7 hours ago
On 2026-02-09 05:03 +01:00, Łukasz Lebiedziński wrote:
> Case labels must be compile-time constants, but the original
> implementation used array element values like irqf_regs[0], causing
> a compilation error:
>
>   drivers/mfd/sec-irq.c:218:9: error: case label does not reduce to
>   an integer constant

This was already reported by lkp bot, and I have fixed it locally
already. Weirdly, I don't get this error somehow.

>
> Replace array-based case labels with explicit S2MU005_REG_* defines
> for all four interrupt status and mask registers, preserving the
> original logic.
>
> This addresses an issue in the S2MU005 PMIC support patches [1].
>
> Link: https://lore.kernel.org/all/20260126-s2mu005-pmic-v2-6-78f1a75f547a@disroot.org/#Z31drivers:mfd:sec-irq.c [1]
> Signed-off-by: Łukasz Lebiedziński <kernel@lvkasz.us>
> ---
>  drivers/mfd/sec-irq.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c
> index 44a1eb074a08..73a611ba0502 100644
> --- a/drivers/mfd/sec-irq.c
> +++ b/drivers/mfd/sec-irq.c
> @@ -215,9 +215,15 @@ static unsigned int s2mu005_irq_get_reg(struct regmap_irq_chip_data *data,
>  	};
>  
>  	switch (base) {
> -	case irqf_regs[0]:
> +	case S2MU005_REG_CHGR_INT1:
> +	case S2MU005_REG_FLED_INT1:
> +	case S2MU005_REG_MUIC_INT1:
> +	case S2MU005_REG_MUIC_INT2:

We're checking the base register here, so all other than the first one
is redundant.

>  		return irqf_regs[index];
> -	case mask_regs[0]:
> +	case S2MU005_REG_CHGR_INT1M:
> +	case S2MU005_REG_FLED_INT1M:
> +	case S2MU005_REG_MUIC_INT1M:
> +	case S2MU005_REG_MUIC_INT2M:
>  		return mask_regs[index];
>  	}
>  
Re: [PATCH FIX] mfd: sec-irq: fix non-constant case labels in s2mu005_irq_get_reg
Posted by David Laight 1 day, 10 hours ago
On Mon,  9 Feb 2026 05:03:58 +0100
Łukasz Lebiedziński <kernel@lvkasz.us> wrote:

> Case labels must be compile-time constants,

They must be 'integer constant expressions' which it stronger than
'compile time constant'.

> but the original
> implementation used array element values like irqf_regs[0], causing
> a compilation error:
> 
>   drivers/mfd/sec-irq.c:218:9: error: case label does not reduce to
>   an integer constant
> 
> Replace array-based case labels with explicit S2MU005_REG_* defines
> for all four interrupt status and mask registers, preserving the
> original logic.
> 
> This addresses an issue in the S2MU005 PMIC support patches [1].

Makes one wonder how the patches were tested.

> 
> Link: https://lore.kernel.org/all/20260126-s2mu005-pmic-v2-6-78f1a75f547a@disroot.org/#Z31drivers:mfd:sec-irq.c [1]
> Signed-off-by: Łukasz Lebiedziński <kernel@lvkasz.us>
> ---
>  drivers/mfd/sec-irq.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c
> index 44a1eb074a08..73a611ba0502 100644
> --- a/drivers/mfd/sec-irq.c
> +++ b/drivers/mfd/sec-irq.c
> @@ -215,9 +215,15 @@ static unsigned int s2mu005_irq_get_reg(struct regmap_irq_chip_data *data,
>  	};
>  
>  	switch (base) {
> -	case irqf_regs[0]:
> +	case S2MU005_REG_CHGR_INT1:
> +	case S2MU005_REG_FLED_INT1:
> +	case S2MU005_REG_MUIC_INT1:
> +	case S2MU005_REG_MUIC_INT2:
>  		return irqf_regs[index];
> -	case mask_regs[0]:
> +	case S2MU005_REG_CHGR_INT1M:
> +	case S2MU005_REG_FLED_INT1M:
> +	case S2MU005_REG_MUIC_INT1M:
> +	case S2MU005_REG_MUIC_INT2M:
>  		return mask_regs[index];
>  	}

That looks as though it ought to be an if statement (or two).

	David

>