pwm: raspberrypi-poe: Make use of devm_pwmchip_alloc() function
This prepares the pwm-raspberrypi-poe driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Link: https://lore.kernel.org/r/4654a6438ab618574afc3bb73bf402df7c254ee2.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This commit is contained in:
parent
fd20a3e1fc
commit
05aa788c06
@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
struct raspberrypi_pwm {
|
struct raspberrypi_pwm {
|
||||||
struct rpi_firmware *firmware;
|
struct rpi_firmware *firmware;
|
||||||
struct pwm_chip chip;
|
|
||||||
unsigned int duty_cycle;
|
unsigned int duty_cycle;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ struct raspberrypi_pwm_prop {
|
|||||||
static inline
|
static inline
|
||||||
struct raspberrypi_pwm *raspberrypi_pwm_from_chip(struct pwm_chip *chip)
|
struct raspberrypi_pwm *raspberrypi_pwm_from_chip(struct pwm_chip *chip)
|
||||||
{
|
{
|
||||||
return container_of(chip, struct raspberrypi_pwm, chip);
|
return pwmchip_get_drvdata(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int raspberrypi_pwm_set_property(struct rpi_firmware *firmware,
|
static int raspberrypi_pwm_set_property(struct rpi_firmware *firmware,
|
||||||
@ -142,6 +141,7 @@ static int raspberrypi_pwm_probe(struct platform_device *pdev)
|
|||||||
struct device_node *firmware_node;
|
struct device_node *firmware_node;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct rpi_firmware *firmware;
|
struct rpi_firmware *firmware;
|
||||||
|
struct pwm_chip *chip;
|
||||||
struct raspberrypi_pwm *rpipwm;
|
struct raspberrypi_pwm *rpipwm;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -157,14 +157,14 @@ static int raspberrypi_pwm_probe(struct platform_device *pdev)
|
|||||||
return dev_err_probe(dev, -EPROBE_DEFER,
|
return dev_err_probe(dev, -EPROBE_DEFER,
|
||||||
"Failed to get firmware handle\n");
|
"Failed to get firmware handle\n");
|
||||||
|
|
||||||
rpipwm = devm_kzalloc(&pdev->dev, sizeof(*rpipwm), GFP_KERNEL);
|
chip = devm_pwmchip_alloc(&pdev->dev, RASPBERRYPI_FIRMWARE_PWM_NUM,
|
||||||
if (!rpipwm)
|
sizeof(*rpipwm));
|
||||||
return -ENOMEM;
|
if (IS_ERR(chip))
|
||||||
|
return PTR_ERR(chip);
|
||||||
|
rpipwm = raspberrypi_pwm_from_chip(chip);
|
||||||
|
|
||||||
rpipwm->firmware = firmware;
|
rpipwm->firmware = firmware;
|
||||||
rpipwm->chip.dev = dev;
|
chip->ops = &raspberrypi_pwm_ops;
|
||||||
rpipwm->chip.ops = &raspberrypi_pwm_ops;
|
|
||||||
rpipwm->chip.npwm = RASPBERRYPI_FIRMWARE_PWM_NUM;
|
|
||||||
|
|
||||||
ret = raspberrypi_pwm_get_property(rpipwm->firmware, RPI_PWM_CUR_DUTY_REG,
|
ret = raspberrypi_pwm_get_property(rpipwm->firmware, RPI_PWM_CUR_DUTY_REG,
|
||||||
&rpipwm->duty_cycle);
|
&rpipwm->duty_cycle);
|
||||||
@ -173,7 +173,7 @@ static int raspberrypi_pwm_probe(struct platform_device *pdev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return devm_pwmchip_add(dev, &rpipwm->chip);
|
return devm_pwmchip_add(dev, chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id raspberrypi_pwm_of_match[] = {
|
static const struct of_device_id raspberrypi_pwm_of_match[] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user