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

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

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

Link: https://lore.kernel.org/r/6a90083e9d1ab1c34422161593d6d7a669143217.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 44fe6578
...@@ -388,6 +388,7 @@ static const struct of_device_id atmel_tcb_of_match[] = { ...@@ -388,6 +388,7 @@ static const struct of_device_id atmel_tcb_of_match[] = {
static int atmel_tcb_pwm_probe(struct platform_device *pdev) static int atmel_tcb_pwm_probe(struct platform_device *pdev)
{ {
struct pwm_chip *chip;
const struct of_device_id *match; const struct of_device_id *match;
struct atmel_tcb_pwm_chip *tcbpwm; struct atmel_tcb_pwm_chip *tcbpwm;
const struct atmel_tcb_config *config; const struct atmel_tcb_config *config;
...@@ -436,9 +437,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) ...@@ -436,9 +437,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
} }
} }
tcbpwm->chip.dev = &pdev->dev; chip = &tcbpwm->chip;
tcbpwm->chip.ops = &atmel_tcb_pwm_ops; chip->dev = &pdev->dev;
tcbpwm->chip.npwm = NPWM; chip->ops = &atmel_tcb_pwm_ops;
chip->npwm = NPWM;
tcbpwm->channel = channel; tcbpwm->channel = channel;
tcbpwm->width = config->counter_width; tcbpwm->width = config->counter_width;
...@@ -448,11 +450,11 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) ...@@ -448,11 +450,11 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
spin_lock_init(&tcbpwm->lock); spin_lock_init(&tcbpwm->lock);
err = pwmchip_add(&tcbpwm->chip); err = pwmchip_add(chip);
if (err < 0) if (err < 0)
goto err_disable_clk; goto err_disable_clk;
platform_set_drvdata(pdev, tcbpwm); platform_set_drvdata(pdev, chip);
return 0; return 0;
...@@ -473,9 +475,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) ...@@ -473,9 +475,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
static void atmel_tcb_pwm_remove(struct platform_device *pdev) static void atmel_tcb_pwm_remove(struct platform_device *pdev)
{ {
struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev); struct pwm_chip *chip = platform_get_drvdata(pdev);
struct atmel_tcb_pwm_chip *tcbpwm = to_tcb_chip(chip);
pwmchip_remove(&tcbpwm->chip); pwmchip_remove(chip);
clk_disable_unprepare(tcbpwm->slow_clk); clk_disable_unprepare(tcbpwm->slow_clk);
clk_put(tcbpwm->gclk); clk_put(tcbpwm->gclk);
...@@ -491,7 +494,8 @@ MODULE_DEVICE_TABLE(of, atmel_tcb_pwm_dt_ids); ...@@ -491,7 +494,8 @@ MODULE_DEVICE_TABLE(of, atmel_tcb_pwm_dt_ids);
static int atmel_tcb_pwm_suspend(struct device *dev) static int atmel_tcb_pwm_suspend(struct device *dev)
{ {
struct atmel_tcb_pwm_chip *tcbpwm = dev_get_drvdata(dev); struct pwm_chip *chip = dev_get_drvdata(dev);
struct atmel_tcb_pwm_chip *tcbpwm = to_tcb_chip(chip);
struct atmel_tcb_channel *chan = &tcbpwm->bkup; struct atmel_tcb_channel *chan = &tcbpwm->bkup;
unsigned int channel = tcbpwm->channel; unsigned int channel = tcbpwm->channel;
...@@ -505,7 +509,8 @@ static int atmel_tcb_pwm_suspend(struct device *dev) ...@@ -505,7 +509,8 @@ static int atmel_tcb_pwm_suspend(struct device *dev)
static int atmel_tcb_pwm_resume(struct device *dev) static int atmel_tcb_pwm_resume(struct device *dev)
{ {
struct atmel_tcb_pwm_chip *tcbpwm = dev_get_drvdata(dev); struct pwm_chip *chip = dev_get_drvdata(dev);
struct atmel_tcb_pwm_chip *tcbpwm = to_tcb_chip(chip);
struct atmel_tcb_channel *chan = &tcbpwm->bkup; struct atmel_tcb_channel *chan = &tcbpwm->bkup;
unsigned int channel = tcbpwm->channel; unsigned int channel = tcbpwm->channel;
......
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