Skip to content

Commit e625fb7

Browse files
andy-shevthierryreding
authored andcommitted
pwm: core: Unify fwnode checks in the module
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 <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent e5c38ba commit e625fb7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/pwm/core.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ EXPORT_SYMBOL_GPL(of_pwm_get);
829829

830830
/**
831831
* acpi_pwm_get() - request a PWM via parsing "pwms" property in ACPI
832-
* @fwnode: firmware node to get the "pwm" property from
832+
* @fwnode: firmware node to get the "pwms" property from
833833
*
834834
* Returns the PWM device parsed from the fwnode and index specified in the
835835
* "pwms" property or a negative error-code on failure.
@@ -844,7 +844,7 @@ EXPORT_SYMBOL_GPL(of_pwm_get);
844844
* Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
845845
* error code on failure.
846846
*/
847-
static struct pwm_device *acpi_pwm_get(struct fwnode_handle *fwnode)
847+
static struct pwm_device *acpi_pwm_get(const struct fwnode_handle *fwnode)
848848
{
849849
struct pwm_device *pwm = ERR_PTR(-ENODEV);
850850
struct fwnode_reference_args args;
@@ -928,6 +928,7 @@ void pwm_remove_table(struct pwm_lookup *table, size_t num)
928928
*/
929929
struct pwm_device *pwm_get(struct device *dev, const char *con_id)
930930
{
931+
const struct fwnode_handle *fwnode = dev ? dev_fwnode(dev) : NULL;
931932
const char *dev_id = dev ? dev_name(dev) : NULL;
932933
struct pwm_device *pwm;
933934
struct pwm_chip *chip;
@@ -938,12 +939,12 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
938939
int err;
939940

940941
/* look up via DT first */
941-
if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node)
942-
return of_pwm_get(dev, dev->of_node, con_id);
942+
if (is_of_node(fwnode))
943+
return of_pwm_get(dev, to_of_node(fwnode), con_id);
943944

944945
/* then lookup via ACPI */
945-
if (dev && is_acpi_node(dev->fwnode)) {
946-
pwm = acpi_pwm_get(dev->fwnode);
946+
if (is_acpi_node(fwnode)) {
947+
pwm = acpi_pwm_get(fwnode);
947948
if (!IS_ERR(pwm) || PTR_ERR(pwm) != -ENOENT)
948949
return pwm;
949950
}

0 commit comments

Comments
 (0)