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

gpio: mvebu: Make use of devm_pwmchip_alloc() function

This prepares the pwm sub-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.
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/2edc3adbb2c40b76b3b3dac82de82f3036bec1d5.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent dda59d24
...@@ -99,7 +99,6 @@ struct mvebu_pwm { ...@@ -99,7 +99,6 @@ struct mvebu_pwm {
u32 offset; u32 offset;
unsigned long clk_rate; unsigned long clk_rate;
struct gpio_desc *gpiod; struct gpio_desc *gpiod;
struct pwm_chip chip;
spinlock_t lock; spinlock_t lock;
struct mvebu_gpio_chip *mvchip; struct mvebu_gpio_chip *mvchip;
...@@ -615,7 +614,7 @@ static const struct regmap_config mvebu_gpio_regmap_config = { ...@@ -615,7 +614,7 @@ static const struct regmap_config mvebu_gpio_regmap_config = {
*/ */
static struct mvebu_pwm *to_mvebu_pwm(struct pwm_chip *chip) static struct mvebu_pwm *to_mvebu_pwm(struct pwm_chip *chip)
{ {
return container_of(chip, struct mvebu_pwm, chip); return pwmchip_get_drvdata(chip);
} }
static int mvebu_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) static int mvebu_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
...@@ -789,6 +788,7 @@ static int mvebu_pwm_probe(struct platform_device *pdev, ...@@ -789,6 +788,7 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct mvebu_pwm *mvpwm; struct mvebu_pwm *mvpwm;
struct pwm_chip *chip;
void __iomem *base; void __iomem *base;
u32 offset; u32 offset;
u32 set; u32 set;
...@@ -813,9 +813,11 @@ static int mvebu_pwm_probe(struct platform_device *pdev, ...@@ -813,9 +813,11 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
if (IS_ERR(mvchip->clk)) if (IS_ERR(mvchip->clk))
return PTR_ERR(mvchip->clk); return PTR_ERR(mvchip->clk);
mvpwm = devm_kzalloc(dev, sizeof(struct mvebu_pwm), GFP_KERNEL); chip = devm_pwmchip_alloc(dev, mvchip->chip.ngpio, sizeof(*mvpwm));
if (!mvpwm) if (IS_ERR(chip))
return -ENOMEM; return PTR_ERR(chip);
mvpwm = to_mvebu_pwm(chip);
mvchip->mvpwm = mvpwm; mvchip->mvpwm = mvpwm;
mvpwm->mvchip = mvchip; mvpwm->mvchip = mvchip;
mvpwm->offset = offset; mvpwm->offset = offset;
...@@ -868,13 +870,11 @@ static int mvebu_pwm_probe(struct platform_device *pdev, ...@@ -868,13 +870,11 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
return -EINVAL; return -EINVAL;
} }
mvpwm->chip.dev = dev; chip->ops = &mvebu_pwm_ops;
mvpwm->chip.ops = &mvebu_pwm_ops;
mvpwm->chip.npwm = mvchip->chip.ngpio;
spin_lock_init(&mvpwm->lock); spin_lock_init(&mvpwm->lock);
return devm_pwmchip_add(dev, &mvpwm->chip); return devm_pwmchip_add(dev, chip);
} }
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
......
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