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

pwm: ep93xx: Make use of devm_pwmchip_alloc() function

This prepares the pwm-ep93xx 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/9420eeca1eb18fada4a15c897f60696b7b22b532.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent ecb4ec5a
...@@ -36,12 +36,11 @@ ...@@ -36,12 +36,11 @@
struct ep93xx_pwm { struct ep93xx_pwm {
void __iomem *base; void __iomem *base;
struct clk *clk; struct clk *clk;
struct pwm_chip chip;
}; };
static inline struct ep93xx_pwm *to_ep93xx_pwm(struct pwm_chip *chip) static inline struct ep93xx_pwm *to_ep93xx_pwm(struct pwm_chip *chip)
{ {
return container_of(chip, struct ep93xx_pwm, chip); return pwmchip_get_drvdata(chip);
} }
static int ep93xx_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) static int ep93xx_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
...@@ -163,12 +162,14 @@ static const struct pwm_ops ep93xx_pwm_ops = { ...@@ -163,12 +162,14 @@ static const struct pwm_ops ep93xx_pwm_ops = {
static int ep93xx_pwm_probe(struct platform_device *pdev) static int ep93xx_pwm_probe(struct platform_device *pdev)
{ {
struct pwm_chip *chip;
struct ep93xx_pwm *ep93xx_pwm; struct ep93xx_pwm *ep93xx_pwm;
int ret; int ret;
ep93xx_pwm = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_pwm), GFP_KERNEL); chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*ep93xx_pwm));
if (!ep93xx_pwm) if (IS_ERR(chip))
return -ENOMEM; return PTR_ERR(chip);
ep93xx_pwm = to_ep93xx_pwm(chip);
ep93xx_pwm->base = devm_platform_ioremap_resource(pdev, 0); ep93xx_pwm->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(ep93xx_pwm->base)) if (IS_ERR(ep93xx_pwm->base))
...@@ -178,11 +179,9 @@ static int ep93xx_pwm_probe(struct platform_device *pdev) ...@@ -178,11 +179,9 @@ static int ep93xx_pwm_probe(struct platform_device *pdev)
if (IS_ERR(ep93xx_pwm->clk)) if (IS_ERR(ep93xx_pwm->clk))
return PTR_ERR(ep93xx_pwm->clk); return PTR_ERR(ep93xx_pwm->clk);
ep93xx_pwm->chip.dev = &pdev->dev; chip->ops = &ep93xx_pwm_ops;
ep93xx_pwm->chip.ops = &ep93xx_pwm_ops;
ep93xx_pwm->chip.npwm = 1;
ret = devm_pwmchip_add(&pdev->dev, &ep93xx_pwm->chip); ret = devm_pwmchip_add(&pdev->dev, chip);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
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