Re: [PATCH v2 01/15] gpio: dwapb: Use modern PM macros

Jisheng Zhang
2025-11-19T13:17:05Z

On Wed, Nov 19, 2025 at 08:42:05PM +0800, Jisheng Zhang wrote:
> On Tue, Nov 18, 2025 at 12:15:35PM +0200, Andy Shevchenko wrote:
> > On Tue, Nov 18, 2025 at 2:50 AM Jisheng Zhang <jszhang@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. After greping the arm/arm64/riscv
> >
> > SLEEP
> > grepping
> >
> > > dts dir, the max port number is 6, the berlin2q soc families, so this
> > > means current we have wasted 216 bytes memory which is trivial
> >
> > currently
> >
> > > compared to the system memory.
> >
> > I still think the embedding is not related to this change and should
> > be justified in a separate patch. W/o that part the rest looks fine.
>
> I got your mind now: it looks like you prefer a seperate patch for the
> embedding. Let me explain why I have the embedding within this patch:
> the pm_ptr() or pm_sleep_ptr() just optimizes out the PM functions, but the
> PM funtions are still compiled, so w/o the embedding, it's impossible
> to clean up the code with the modern PM macros.

For dwapb, I can still acchieve the clean up w/ only embedding the
pointer. But I'm not sure whether embedding the struture deserve a seperate
patch.

BTW: as Michael mentioned during v1 review, the driver allocates the
struct with kzalloc and stores a pointer to it, so considering the
pointer itself and the kmalloc overhead/alignment etc, current gpio-dwapb
have an overhead in the same order of magnitude when PM=y