On Sun, May 17, 2026 at 4:01 PM Linus Walleij <[email protected]> wrote:
>
> Use IS_ENABLED() inline assigning a variable instead of ifdeffery.
>
> Cc: Rosen Penev <[email protected]>
> Suggested-by: Geert Uytterhoeven <[email protected]>
> Link: 
> https://lore.kernel.org/linux-gpio/camuhmdx7t7vhtzybjyo3s8su3xleh9gksxmlbbh7p4d1ct3...@mail.gmail.com/
> Signed-off-by: Linus Walleij <[email protected]>
> ---
>  drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c 
> b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
> index 3fb9aa8ddf07..ec359cb873c4 100644
> --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
> +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
> @@ -845,6 +845,7 @@ int jh7110_pinctrl_probe(struct platform_device *pdev)
>         struct jh7110_pinctrl *sfp;
>         struct pinctrl_desc *jh7110_pinctrl_desc;
>         struct reset_control *rst;
> +       unsigned int num_saved_regs;
>         struct clk *clk;
>         int ret;
>
> @@ -857,15 +858,12 @@ int jh7110_pinctrl_probe(struct platform_device *pdev)
>                 return -EINVAL;
>         }
>
> -#if IS_ENABLED(CONFIG_PM_SLEEP)
> -       sfp = devm_kzalloc(dev, struct_size(sfp, saved_regs, 
> info->nsaved_regs),
> -                       GFP_KERNEL);
> -#else
> -       sfp = devm_kzalloc(dev, sizeof(*sfp), GFP_KERNEL);
> -#endif
> +       num_saved_regs = IS_ENABLED(CONFIG_PM_SLEEP) ? info->nsaved_regs : 0;
> +       sfp = devm_kzalloc(dev, struct_size(sfp, saved_regs, num_saved_regs),
> +                          GFP_KERNEL);
>         if (!sfp)
>                 return -ENOMEM;
> -       sfp->num_saved_regs = info->nsaved_regs;
> +       sfp->num_saved_regs = num_saved_regs;
yeah and this is used absolutely nowhere. Both for loops are of the form

for (i = 0 ; i < sfp->info->nsaved_regs ; i++)

I really don't think __counted_by is worth it here.
>
>         sfp->base = devm_platform_ioremap_resource(pdev, 0);
>         if (IS_ERR(sfp->base))
>
> --
> 2.54.0
>

Reply via email to