From: Dhruva Gole <d-gole@ti.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Kaushlendra Kumar <kaushlendra.kumar@intel.com>,
<pavel@kernel.org>, <gregkh@linuxfoundation.org>,
<dakr@kernel.org>, <linux-pm@vger.kernel.org>
Subject: Re: [PATCH] PM: Introduce CALL_PM_OP macro to reduce code duplication
Date: Wed, 15 Oct 2025 11:16:40 +0530 [thread overview]
Message-ID: <20251015054640.g2mjf4dccbn2tcma@lcpd911> (raw)
In-Reply-To: <CAJZ5v0iXAO6Z1t-LeGgutsJRbfL7+Xtszq0h_pG+QFfPbfET7Q@mail.gmail.com>
On Oct 13, 2025 at 20:56:40 +0200, Rafael J. Wysocki wrote:
> On Fri, Sep 19, 2025 at 2:46 PM Kaushlendra Kumar
> <kaushlendra.kumar@intel.com> wrote:
> >
> > Add CALL_PM_OP macro to eliminate repetitive code patterns in power
> > management generic operations. Replace identical driver PM callback
> > invocation logic across all pm_generic_* functions with a single
> > macro that handles the NULL pointer checks and function calls.
> >
> > This reduces code duplication significantly while maintaining the
> > same functionality and improving code maintainability.
> >
> > Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
> > ---
> > drivers/base/power/generic_ops.c | 85 ++++++++++----------------------
> > 1 file changed, 25 insertions(+), 60 deletions(-)
> >
> > diff --git a/drivers/base/power/generic_ops.c b/drivers/base/power/generic_ops.c
> > index 6502720bb564..c4fc802b8c65 100644
> > --- a/drivers/base/power/generic_ops.c
> > +++ b/drivers/base/power/generic_ops.c
> > @@ -8,6 +8,13 @@
> > #include <linux/pm_runtime.h>
> > #include <linux/export.h>
> >
> > +#define CALL_PM_OP(dev, op) \
> > +({ \
> > +struct device *_dev = (dev); \
> > +const struct dev_pm_ops *pm = _dev->driver ? _dev->driver->pm : NULL; \
> > +pm && pm->op ? pm->op(_dev) : 0; \
> > +})
>
> Why don't you include the function signature and symbol export into the macro?
>
As discussed in the [v2] I am more inclined toward this v1
implementation.
So for v1:
Reviewed-by: Dhruva Gole <d-gole@ti.com>
[v2] https://lore.kernel.org/linux-pm/CAJZ5v0iHcvXHdMfdakd5TUgcAiOGFW8hbvb2k-xb92dz81cGhA@mail.gmail.com
--
Best regards,
Dhruva Gole
Texas Instruments Incorporated
next prev parent reply other threads:[~2025-10-15 5:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-19 12:44 [PATCH] PM: Introduce CALL_PM_OP macro to reduce code duplication Kaushlendra Kumar
2025-10-13 18:56 ` Rafael J. Wysocki
2025-10-14 8:32 ` Kumar, Kaushlendra
2025-10-15 5:46 ` Dhruva Gole [this message]
2025-10-20 17:56 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251015054640.g2mjf4dccbn2tcma@lcpd911 \
--to=d-gole@ti.com \
--cc=dakr@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kaushlendra.kumar@intel.com \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox