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

pwm: tiehrpwm: Make use of devm_pwmchip_alloc() function

This prepares the pwm-tiecap 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/62fbac428cae0942f8e88234bf249537fcd890a3.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent e003a687
...@@ -105,7 +105,6 @@ struct ehrpwm_context { ...@@ -105,7 +105,6 @@ struct ehrpwm_context {
}; };
struct ehrpwm_pwm_chip { struct ehrpwm_pwm_chip {
struct pwm_chip chip;
unsigned long clk_rate; unsigned long clk_rate;
void __iomem *mmio_base; void __iomem *mmio_base;
unsigned long period_cycles[NUM_PWM_CHANNEL]; unsigned long period_cycles[NUM_PWM_CHANNEL];
...@@ -116,7 +115,7 @@ struct ehrpwm_pwm_chip { ...@@ -116,7 +115,7 @@ struct ehrpwm_pwm_chip {
static inline struct ehrpwm_pwm_chip *to_ehrpwm_pwm_chip(struct pwm_chip *chip) static inline struct ehrpwm_pwm_chip *to_ehrpwm_pwm_chip(struct pwm_chip *chip)
{ {
return container_of(chip, struct ehrpwm_pwm_chip, chip); return pwmchip_get_drvdata(chip);
} }
static inline u16 ehrpwm_read(void __iomem *base, unsigned int offset) static inline u16 ehrpwm_read(void __iomem *base, unsigned int offset)
...@@ -454,9 +453,10 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev) ...@@ -454,9 +453,10 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
struct clk *clk; struct clk *clk;
int ret; int ret;
pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); chip = devm_pwmchip_alloc(&pdev->dev, NUM_PWM_CHANNEL, sizeof(*pc));
if (!pc) if (IS_ERR(chip))
return -ENOMEM; return PTR_ERR(chip);
pc = to_ehrpwm_pwm_chip(chip);
clk = devm_clk_get(&pdev->dev, "fck"); clk = devm_clk_get(&pdev->dev, "fck");
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
...@@ -475,10 +475,7 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev) ...@@ -475,10 +475,7 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
chip = &pc->chip;
chip->dev = &pdev->dev;
chip->ops = &ehrpwm_pwm_ops; chip->ops = &ehrpwm_pwm_ops;
chip->npwm = NUM_PWM_CHANNEL;
pc->mmio_base = devm_platform_ioremap_resource(pdev, 0); pc->mmio_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(pc->mmio_base)) if (IS_ERR(pc->mmio_base))
......
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