Skip to content

Commit e5c38ba

Browse files
andy-shevthierryreding
authored andcommitted
pwm: core: Reuse fwnode_to_pwmchip() in ACPI case
In ACPI case we may use matching by fwnode as provided via fwnode_to_pwmchip(). This makes device_to_pwmchip() not needed anymore. Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent ca06616 commit e5c38ba

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

drivers/pwm/core.c

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -827,28 +827,6 @@ struct pwm_device *of_pwm_get(struct device *dev, struct device_node *np,
827827
}
828828
EXPORT_SYMBOL_GPL(of_pwm_get);
829829

830-
#if IS_ENABLED(CONFIG_ACPI)
831-
static struct pwm_chip *device_to_pwmchip(struct device *dev)
832-
{
833-
struct pwm_chip *chip;
834-
835-
mutex_lock(&pwm_lock);
836-
837-
list_for_each_entry(chip, &pwm_chips, list) {
838-
struct acpi_device *adev = ACPI_COMPANION(chip->dev);
839-
840-
if ((chip->dev == dev) || (adev && &adev->dev == dev)) {
841-
mutex_unlock(&pwm_lock);
842-
return chip;
843-
}
844-
}
845-
846-
mutex_unlock(&pwm_lock);
847-
848-
return ERR_PTR(-EPROBE_DEFER);
849-
}
850-
#endif
851-
852830
/**
853831
* acpi_pwm_get() - request a PWM via parsing "pwms" property in ACPI
854832
* @fwnode: firmware node to get the "pwm" property from
@@ -869,9 +847,7 @@ static struct pwm_chip *device_to_pwmchip(struct device *dev)
869847
static struct pwm_device *acpi_pwm_get(struct fwnode_handle *fwnode)
870848
{
871849
struct pwm_device *pwm = ERR_PTR(-ENODEV);
872-
#if IS_ENABLED(CONFIG_ACPI)
873850
struct fwnode_reference_args args;
874-
struct acpi_device *acpi;
875851
struct pwm_chip *chip;
876852
int ret;
877853

@@ -881,14 +857,10 @@ static struct pwm_device *acpi_pwm_get(struct fwnode_handle *fwnode)
881857
if (ret < 0)
882858
return ERR_PTR(ret);
883859

884-
acpi = to_acpi_device_node(args.fwnode);
885-
if (!acpi)
886-
return ERR_PTR(-EINVAL);
887-
888860
if (args.nargs < 2)
889861
return ERR_PTR(-EPROTO);
890862

891-
chip = device_to_pwmchip(&acpi->dev);
863+
chip = fwnode_to_pwmchip(args.fwnode);
892864
if (IS_ERR(chip))
893865
return ERR_CAST(chip);
894866

@@ -901,7 +873,6 @@ static struct pwm_device *acpi_pwm_get(struct fwnode_handle *fwnode)
901873

902874
if (args.nargs > 2 && args.args[2] & PWM_POLARITY_INVERTED)
903875
pwm->args.polarity = PWM_POLARITY_INVERSED;
904-
#endif
905876

906877
return pwm;
907878
}

0 commit comments

Comments
 (0)