From: Bjorn Helgaas <helgaas@kernel.org>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
Len Brown <len.brown@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Bjorn Helgaas <bhelgaas@google.com>
Subject: [PATCH] PM: runtime: Simplify __rpm_get_callback()
Date: Thu, 15 Dec 2022 12:18:48 -0600 [thread overview]
Message-ID: <20221215181848.129326-1-helgaas@kernel.org> (raw)
From: Bjorn Helgaas <bhelgaas@google.com>
Simplify __rpm_get_callback() slightly by returning as soon as the return
value is known. No functional change intended.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/base/power/runtime.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 50e726b6c2cf..7171ed0668f3 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -20,8 +20,7 @@ typedef int (*pm_callback_t)(struct device *);
static pm_callback_t __rpm_get_callback(struct device *dev, size_t cb_offset)
{
- pm_callback_t cb;
- const struct dev_pm_ops *ops;
+ const struct dev_pm_ops *ops = NULL;
if (dev->pm_domain)
ops = &dev->pm_domain->ops;
@@ -31,18 +30,14 @@ static pm_callback_t __rpm_get_callback(struct device *dev, size_t cb_offset)
ops = dev->class->pm;
else if (dev->bus && dev->bus->pm)
ops = dev->bus->pm;
- else
- ops = NULL;
if (ops)
- cb = *(pm_callback_t *)((void *)ops + cb_offset);
- else
- cb = NULL;
+ return *(pm_callback_t *)((void *)ops + cb_offset);
- if (!cb && dev->driver && dev->driver->pm)
- cb = *(pm_callback_t *)((void *)dev->driver->pm + cb_offset);
+ if (dev->driver && dev->driver->pm)
+ return *(pm_callback_t *)((void *)dev->driver->pm + cb_offset);
- return cb;
+ return NULL;
}
#define RPM_GET_CALLBACK(dev, callback) \
--
2.25.1
next reply other threads:[~2022-12-15 18:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-15 18:18 Bjorn Helgaas [this message]
2023-01-13 20:01 ` Rafael J. Wysocki
2023-01-24 11:19 ` Geert Uytterhoeven
2023-01-24 14:07 ` Rafael J. Wysocki
2023-01-24 14:37 ` Geert Uytterhoeven
2023-01-24 14:45 ` Rafael J. Wysocki
2023-01-24 15:05 ` Bjorn Helgaas
2023-01-24 16:14 ` Geert Uytterhoeven
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=20221215181848.129326-1-helgaas@kernel.org \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.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
all inboxes | Powered by JetHome®