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

pwm: sunplus: Make use of devm_pwmchip_alloc() function

This prepares the pwm-sunplus 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/192be7e428eff17dd922c9c0d0d168225b89bb34.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 362e3f88
...@@ -43,14 +43,13 @@ ...@@ -43,14 +43,13 @@
#define SP7021_PWM_NUM 4 #define SP7021_PWM_NUM 4
struct sunplus_pwm { struct sunplus_pwm {
struct pwm_chip chip;
void __iomem *base; void __iomem *base;
struct clk *clk; struct clk *clk;
}; };
static inline struct sunplus_pwm *to_sunplus_pwm(struct pwm_chip *chip) static inline struct sunplus_pwm *to_sunplus_pwm(struct pwm_chip *chip)
{ {
return container_of(chip, struct sunplus_pwm, chip); return pwmchip_get_drvdata(chip);
} }
static int sunplus_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, static int sunplus_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
...@@ -175,12 +174,14 @@ static void sunplus_pwm_clk_release(void *data) ...@@ -175,12 +174,14 @@ static void sunplus_pwm_clk_release(void *data)
static int sunplus_pwm_probe(struct platform_device *pdev) static int sunplus_pwm_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct pwm_chip *chip;
struct sunplus_pwm *priv; struct sunplus_pwm *priv;
int ret; int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); chip = devm_pwmchip_alloc(dev, SP7021_PWM_NUM, sizeof(*priv));
if (!priv) if (IS_ERR(chip))
return -ENOMEM; return PTR_ERR(chip);
priv = to_sunplus_pwm(chip);
priv->base = devm_platform_ioremap_resource(pdev, 0); priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base)) if (IS_ERR(priv->base))
...@@ -203,11 +204,9 @@ static int sunplus_pwm_probe(struct platform_device *pdev) ...@@ -203,11 +204,9 @@ static int sunplus_pwm_probe(struct platform_device *pdev)
return ret; return ret;
} }
priv->chip.dev = dev; chip->ops = &sunplus_pwm_ops;
priv->chip.ops = &sunplus_pwm_ops;
priv->chip.npwm = SP7021_PWM_NUM;
ret = devm_pwmchip_add(dev, &priv->chip); ret = devm_pwmchip_add(dev, chip);
if (ret < 0) if (ret < 0)
return dev_err_probe(dev, ret, "Cannot register sunplus PWM\n"); return dev_err_probe(dev, ret, "Cannot register sunplus PWM\n");
......
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