Commit f0d90760 authored by Uwe Kleine-König's avatar Uwe Kleine-König

pwm: rcar: Make use of devm_pwmchip_alloc() function

This prepares the pwm-rcar 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/a37a167364366b6cbe2dd299dce02731706213b2.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent aa1b9f16
......@@ -38,14 +38,13 @@
#define RCAR_PWMCNT_PH0_SHIFT 0
struct rcar_pwm_chip {
struct pwm_chip chip;
void __iomem *base;
struct clk *clk;
};
static inline struct rcar_pwm_chip *to_rcar_pwm_chip(struct pwm_chip *chip)
{
return container_of(chip, struct rcar_pwm_chip, chip);
return pwmchip_get_drvdata(chip);
}
static void rcar_pwm_write(struct rcar_pwm_chip *rp, u32 data,
......@@ -206,9 +205,10 @@ static int rcar_pwm_probe(struct platform_device *pdev)
struct rcar_pwm_chip *rcar_pwm;
int ret;
rcar_pwm = devm_kzalloc(&pdev->dev, sizeof(*rcar_pwm), GFP_KERNEL);
if (rcar_pwm == NULL)
return -ENOMEM;
chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*rcar_pwm));
if (IS_ERR(chip))
return PTR_ERR(chip);
rcar_pwm = to_rcar_pwm_chip(chip);
rcar_pwm->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(rcar_pwm->base))
......@@ -220,10 +220,7 @@ static int rcar_pwm_probe(struct platform_device *pdev)
return PTR_ERR(rcar_pwm->clk);
}
chip = &rcar_pwm->chip;
chip->dev = &pdev->dev;
chip->ops = &rcar_pwm_ops;
chip->npwm = 1;
platform_set_drvdata(pdev, chip);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment