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

pwm: atmel-hlcdc: Prepare removing pwm_chip from driver data

This prepares the driver for further changes that will drop struct
pwm_chip chip from struct atmel_hlcdc_pwm. Use the pwm_chip as driver
data instead of the atmel_hlcdc_pwm to get access to the pwm_chip in
the .suspend() and .resume() callbacks and atmel_hlcdc_pwm_remove()
without using atmel->chip.

Link: https://lore.kernel.org/r/0e97342f15540c7330d405eaaf3e68baa8e1e488.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 8de8ccac
...@@ -182,8 +182,9 @@ static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = { ...@@ -182,8 +182,9 @@ static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = {
static int atmel_hlcdc_pwm_suspend(struct device *dev) static int atmel_hlcdc_pwm_suspend(struct device *dev)
{ {
struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev); struct pwm_chip *chip = dev_get_drvdata(dev);
struct pwm_device *pwm = &atmel->chip.pwms[0]; struct atmel_hlcdc_pwm *atmel = to_atmel_hlcdc_pwm(chip);
struct pwm_device *pwm = &chip->pwms[0];
/* Keep the periph clock enabled if the PWM is still running. */ /* Keep the periph clock enabled if the PWM is still running. */
if (!pwm->state.enabled) if (!pwm->state.enabled)
...@@ -194,8 +195,9 @@ static int atmel_hlcdc_pwm_suspend(struct device *dev) ...@@ -194,8 +195,9 @@ static int atmel_hlcdc_pwm_suspend(struct device *dev)
static int atmel_hlcdc_pwm_resume(struct device *dev) static int atmel_hlcdc_pwm_resume(struct device *dev)
{ {
struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev); struct pwm_chip *chip = dev_get_drvdata(dev);
struct pwm_device *pwm = &atmel->chip.pwms[0]; struct atmel_hlcdc_pwm *atmel = to_atmel_hlcdc_pwm(chip);
struct pwm_device *pwm = &chip->pwms[0];
int ret; int ret;
/* Re-enable the periph clock it was stopped during suspend. */ /* Re-enable the periph clock it was stopped during suspend. */
...@@ -205,7 +207,7 @@ static int atmel_hlcdc_pwm_resume(struct device *dev) ...@@ -205,7 +207,7 @@ static int atmel_hlcdc_pwm_resume(struct device *dev)
return ret; return ret;
} }
return atmel_hlcdc_pwm_apply(&atmel->chip, pwm, &pwm->state); return atmel_hlcdc_pwm_apply(chip, pwm, &pwm->state);
} }
static DEFINE_SIMPLE_DEV_PM_OPS(atmel_hlcdc_pwm_pm_ops, static DEFINE_SIMPLE_DEV_PM_OPS(atmel_hlcdc_pwm_pm_ops,
...@@ -241,6 +243,7 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev) ...@@ -241,6 +243,7 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
{ {
const struct of_device_id *match; const struct of_device_id *match;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct pwm_chip *chip;
struct atmel_hlcdc_pwm *atmel; struct atmel_hlcdc_pwm *atmel;
struct atmel_hlcdc *hlcdc; struct atmel_hlcdc *hlcdc;
int ret; int ret;
...@@ -260,26 +263,28 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev) ...@@ -260,26 +263,28 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
atmel->errata = match->data; atmel->errata = match->data;
atmel->hlcdc = hlcdc; atmel->hlcdc = hlcdc;
atmel->chip.ops = &atmel_hlcdc_pwm_ops; chip = &atmel->chip;
atmel->chip.dev = dev; chip->ops = &atmel_hlcdc_pwm_ops;
atmel->chip.npwm = 1; chip->dev = dev;
chip->npwm = 1;
ret = pwmchip_add(&atmel->chip); ret = pwmchip_add(chip);
if (ret) { if (ret) {
clk_disable_unprepare(hlcdc->periph_clk); clk_disable_unprepare(hlcdc->periph_clk);
return ret; return ret;
} }
platform_set_drvdata(pdev, atmel); platform_set_drvdata(pdev, chip);
return 0; return 0;
} }
static void atmel_hlcdc_pwm_remove(struct platform_device *pdev) static void atmel_hlcdc_pwm_remove(struct platform_device *pdev)
{ {
struct atmel_hlcdc_pwm *atmel = platform_get_drvdata(pdev); struct pwm_chip *chip = platform_get_drvdata(pdev);
struct atmel_hlcdc_pwm *atmel = to_atmel_hlcdc_pwm(chip);
pwmchip_remove(&atmel->chip); pwmchip_remove(chip);
clk_disable_unprepare(atmel->hlcdc->periph_clk); clk_disable_unprepare(atmel->hlcdc->periph_clk);
} }
......
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