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

pwm: intel-lgm: Make use of devm_pwmchip_alloc() function

This prepares the pwm-intel-lgm 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/3b2be81b046fe2213736ad37153131d5f4c859f5.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent abf6569d
...@@ -42,14 +42,13 @@ ...@@ -42,14 +42,13 @@
#define LGM_PWM_PERIOD_2WIRE_NS (40 * NSEC_PER_MSEC) #define LGM_PWM_PERIOD_2WIRE_NS (40 * NSEC_PER_MSEC)
struct lgm_pwm_chip { struct lgm_pwm_chip {
struct pwm_chip chip;
struct regmap *regmap; struct regmap *regmap;
u32 period; u32 period;
}; };
static inline struct lgm_pwm_chip *to_lgm_pwm_chip(struct pwm_chip *chip) static inline struct lgm_pwm_chip *to_lgm_pwm_chip(struct pwm_chip *chip)
{ {
return container_of(chip, struct lgm_pwm_chip, chip); return pwmchip_get_drvdata(chip);
} }
static int lgm_pwm_enable(struct pwm_chip *chip, bool enable) static int lgm_pwm_enable(struct pwm_chip *chip, bool enable)
...@@ -168,14 +167,16 @@ static int lgm_pwm_probe(struct platform_device *pdev) ...@@ -168,14 +167,16 @@ static int lgm_pwm_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct reset_control *rst; struct reset_control *rst;
struct pwm_chip *chip;
struct lgm_pwm_chip *pc; struct lgm_pwm_chip *pc;
void __iomem *io_base; void __iomem *io_base;
struct clk *clk; struct clk *clk;
int ret; int ret;
pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL); chip = devm_pwmchip_alloc(dev, 1, sizeof(*pc));
if (!pc) if (IS_ERR(chip))
return -ENOMEM; return PTR_ERR(chip);
pc = to_lgm_pwm_chip(chip);
io_base = devm_platform_ioremap_resource(pdev, 0); io_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(io_base)) if (IS_ERR(io_base))
...@@ -203,13 +204,11 @@ static int lgm_pwm_probe(struct platform_device *pdev) ...@@ -203,13 +204,11 @@ static int lgm_pwm_probe(struct platform_device *pdev)
if (ret) if (ret)
return dev_err_probe(dev, ret, "cannot deassert reset control\n"); return dev_err_probe(dev, ret, "cannot deassert reset control\n");
pc->chip.dev = dev; chip->ops = &lgm_pwm_ops;
pc->chip.ops = &lgm_pwm_ops;
pc->chip.npwm = 1;
lgm_pwm_init(pc); lgm_pwm_init(pc);
ret = devm_pwmchip_add(dev, &pc->chip); ret = devm_pwmchip_add(dev, chip);
if (ret < 0) if (ret < 0)
return dev_err_probe(dev, ret, "failed to add PWM chip\n"); return dev_err_probe(dev, ret, "failed to add PWM chip\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