From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Flavio Suligoi" <f.suligoi@asem.it>,
"Thierry Reding" <thierry.reding@gmail.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pwm@vger.kernel.org, linux-acpi@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>,
Lee Jones <lee.jones@linaro.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <lenb@kernel.org>
Subject: [PATCH v2 5/7] pwm: core: Unify fwnode checks in the module
Date: Mon, 31 May 2021 22:49:45 +0300 [thread overview]
Message-ID: <20210531194947.10770-5-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20210531194947.10770-1-andriy.shevchenko@linux.intel.com>
Historically we have two different approaches on how to check type of fwnode.
Unify them using the latest and greatest fwnode related APIs.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: corrected property name in kernel doc
drivers/pwm/core.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 2223a9b6644b..a27d7c2aa6fe 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -821,7 +821,7 @@ EXPORT_SYMBOL_GPL(of_pwm_get);
/**
* acpi_pwm_get() - request a PWM via parsing "pwms" property in ACPI
- * @fwnode: firmware node to get the "pwm" property from
+ * @fwnode: firmware node to get the "pwms" property from
*
* Returns the PWM device parsed from the fwnode and index specified in the
* "pwms" property or a negative error-code on failure.
@@ -838,7 +838,7 @@ EXPORT_SYMBOL_GPL(of_pwm_get);
* Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
* error code on failure.
*/
-static struct pwm_device *acpi_pwm_get(struct fwnode_handle *fwnode)
+static struct pwm_device *acpi_pwm_get(const struct fwnode_handle *fwnode)
{
struct pwm_device *pwm = ERR_PTR(-ENODEV);
struct fwnode_reference_args args;
@@ -922,6 +922,7 @@ void pwm_remove_table(struct pwm_lookup *table, size_t num)
*/
struct pwm_device *pwm_get(struct device *dev, const char *con_id)
{
+ const struct fwnode_handle *fwnode = dev ? dev_fwnode(dev) : NULL;
const char *dev_id = dev ? dev_name(dev) : NULL;
struct pwm_device *pwm;
struct pwm_chip *chip;
@@ -932,12 +933,12 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
int err;
/* look up via DT first */
- if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node)
- return of_pwm_get(dev, dev->of_node, con_id);
+ if (is_of_node(fwnode))
+ return of_pwm_get(dev, to_of_node(fwnode), con_id);
/* then lookup via ACPI */
- if (dev && is_acpi_node(dev->fwnode)) {
- pwm = acpi_pwm_get(dev->fwnode);
+ if (is_acpi_node(fwnode)) {
+ pwm = acpi_pwm_get(fwnode);
if (!IS_ERR(pwm) || PTR_ERR(pwm) != -ENOENT)
return pwm;
}
--
2.30.2
next prev parent reply other threads:[~2021-05-31 19:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-31 19:49 [PATCH v2 1/7] docs: firmware-guide: ACPI: Add a PWM example Andy Shevchenko
2021-05-31 19:49 ` [PATCH v2 2/7] pwm: core: Always require PWM flags to be provided Andy Shevchenko
2021-06-06 21:30 ` Uwe Kleine-König
2021-06-07 9:02 ` Andy Shevchenko
2021-06-07 9:53 ` Uwe Kleine-König
2021-06-07 10:15 ` Andy Shevchenko
2021-06-07 10:21 ` Andy Shevchenko
2021-06-07 11:49 ` Andy Shevchenko
2021-06-07 14:11 ` Uwe Kleine-König
2021-05-31 19:49 ` [PATCH v2 3/7] pwm: core: Convert to use fwnode for matching Andy Shevchenko
2021-05-31 19:49 ` [PATCH v2 4/7] pwm: core: Reuse fwnode_to_pwmchip() in ACPI case Andy Shevchenko
2021-05-31 19:49 ` Andy Shevchenko [this message]
2021-05-31 19:49 ` [PATCH v2 6/7] pwm: core: Remove unused devm_pwm_put() Andy Shevchenko
2021-06-06 21:40 ` Uwe Kleine-König
2021-05-31 19:49 ` [PATCH v2 7/7] pwm: core: Simplify some devm_*pwm*() functions Andy Shevchenko
2021-06-06 21:45 ` Uwe Kleine-König
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=20210531194947.10770-5-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=corbet@lwn.net \
--cc=f.suligoi@asem.it \
--cc=lee.jones@linaro.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).