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

pwm: lpc18xx-sct: Make use of devm_pwmchip_alloc() function

This prepares the pwm-lpc18xx-sct 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/d480891340e927705843cd09e5777d4daaa6c9cc.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 6a79dc83
...@@ -92,7 +92,6 @@ struct lpc18xx_pwm_data { ...@@ -92,7 +92,6 @@ struct lpc18xx_pwm_data {
}; };
struct lpc18xx_pwm_chip { struct lpc18xx_pwm_chip {
struct pwm_chip chip;
void __iomem *base; void __iomem *base;
struct clk *pwm_clk; struct clk *pwm_clk;
unsigned long clk_rate; unsigned long clk_rate;
...@@ -109,7 +108,7 @@ struct lpc18xx_pwm_chip { ...@@ -109,7 +108,7 @@ struct lpc18xx_pwm_chip {
static inline struct lpc18xx_pwm_chip * static inline struct lpc18xx_pwm_chip *
to_lpc18xx_pwm_chip(struct pwm_chip *chip) to_lpc18xx_pwm_chip(struct pwm_chip *chip)
{ {
return container_of(chip, struct lpc18xx_pwm_chip, chip); return pwmchip_get_drvdata(chip);
} }
static inline void lpc18xx_pwm_writel(struct lpc18xx_pwm_chip *lpc18xx_pwm, static inline void lpc18xx_pwm_writel(struct lpc18xx_pwm_chip *lpc18xx_pwm,
...@@ -353,11 +352,10 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev) ...@@ -353,11 +352,10 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev)
int ret; int ret;
u64 val; u64 val;
lpc18xx_pwm = devm_kzalloc(&pdev->dev, sizeof(*lpc18xx_pwm), chip = devm_pwmchip_alloc(&pdev->dev, LPC18XX_NUM_PWMS, sizeof(*lpc18xx_pwm));
GFP_KERNEL); if (IS_ERR(chip))
if (!lpc18xx_pwm) return PTR_ERR(chip);
return -ENOMEM; lpc18xx_pwm = to_lpc18xx_pwm_chip(chip);
chip = &lpc18xx_pwm->chip;
lpc18xx_pwm->base = devm_platform_ioremap_resource(pdev, 0); lpc18xx_pwm->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(lpc18xx_pwm->base)) if (IS_ERR(lpc18xx_pwm->base))
...@@ -388,9 +386,7 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev) ...@@ -388,9 +386,7 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev)
lpc18xx_pwm->min_period_ns = DIV_ROUND_UP(NSEC_PER_SEC, lpc18xx_pwm->min_period_ns = DIV_ROUND_UP(NSEC_PER_SEC,
lpc18xx_pwm->clk_rate); lpc18xx_pwm->clk_rate);
chip->dev = &pdev->dev;
chip->ops = &lpc18xx_pwm_ops; chip->ops = &lpc18xx_pwm_ops;
chip->npwm = LPC18XX_NUM_PWMS;
/* SCT counter must be in unify (32 bit) mode */ /* SCT counter must be in unify (32 bit) mode */
lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CONFIG, lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CONFIG,
......
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