[PATCH 01/16] gpio: dwapb: Use modern PM macros

Andy Shevchenko andy.shevchenko at gmail.com
Wed Aug 20 09:54:44 PDT 2025


On Wed, Aug 20, 2025 at 6:58 PM Jisheng Zhang <jszhang at kernel.org> wrote:
>
> Use the modern PM macros for the suspend and resume functions to be
> automatically dropped by the compiler when CONFIG_PM or
> CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.
>
> This has the advantage of always compiling these functions in,
> independently of any Kconfig option. Thanks to that, bugs and other
> regressions are subsequently easier to catch.
>
> The dwapb_context structure is always embedded into struct
> dwapb_gpio_port to simplify code. Sure this brings a tiny 36 bytes
> data overhead for !CONFIG_PM_SLEP.

I don't think it's a good approach to add a lot of data for peanuts in
case of PM_SLEEP=n.
Can you just drop that part from the patch and we can discuss it separately?


...

> -#ifdef CONFIG_PM_SLEEP
>  static int dwapb_irq_set_wake(struct irq_data *d, unsigned int enable)
>  {
>         struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
>         struct dwapb_gpio *gpio = to_dwapb_gpio(gc);
> -       struct dwapb_context *ctx = gpio->ports[0].ctx;
> +       struct dwapb_context *ctx = &gpio->ports[0].ctx;
>         irq_hw_number_t bit = irqd_to_hwirq(d);
>
>         if (enable)
> @@ -372,9 +367,6 @@ static int dwapb_irq_set_wake(struct irq_data *d, unsigned int enable)
>
>         return 0;
>  }
> -#else
> -#define dwapb_irq_set_wake     NULL
> -#endif
>
>  static const struct irq_chip dwapb_irq_chip = {
>         .name           = DWAPB_DRIVER_NAME,
> @@ -384,7 +376,7 @@ static const struct irq_chip dwapb_irq_chip = {
>         .irq_set_type   = dwapb_irq_set_type,
>         .irq_enable     = dwapb_irq_enable,
>         .irq_disable    = dwapb_irq_disable,
> -       .irq_set_wake   = dwapb_irq_set_wake,
> +       .irq_set_wake   = pm_sleep_ptr(dwapb_irq_set_wake),
>         .flags          = IRQCHIP_IMMUTABLE,
>         GPIOCHIP_IRQ_RESOURCE_HELPERS,
>  };

This is an interesting piece. I haven't seen much similar in other
GPIO drivers, I would suggest to split it to a separate patch. Also, I
would always have a callback assigned.

...

> -static SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, dwapb_gpio_suspend,
> -                        dwapb_gpio_resume);
> +static DEFINE_SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, dwapb_gpio_suspend, dwapb_gpio_resume);

I think Bart wants the 80 limit to be enforced. Can you just make the
split rather logical?

static DEFINE_SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops,
              dwapb_gpio_suspend, dwapb_gpio_resume);

-- 
With Best Regards,
Andy Shevchenko



More information about the linux-arm-kernel mailing list