pwm: berlin: Prepare removing pwm_chip from driver data
This prepares the driver for further changes that will drop struct pwm_chip chip from struct berlin_pwm_chip. Use the pwm_chip as driver data instead of the berlin_pwm_chip to get access to the pwm_chip in berlin_pwm_suspend() and berlin_pwm_resume() without using bpc->chip. Link: https://lore.kernel.org/r/d2a0c5b664ef1bfd4719c645c069717d63fb4e65.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This commit is contained in:
parent
e5c368b821
commit
5874eaf869
@ -198,6 +198,7 @@ MODULE_DEVICE_TABLE(of, berlin_pwm_match);
|
||||
|
||||
static int berlin_pwm_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct pwm_chip *chip;
|
||||
struct berlin_pwm_chip *bpc;
|
||||
int ret;
|
||||
|
||||
@ -213,25 +214,27 @@ static int berlin_pwm_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(bpc->clk))
|
||||
return PTR_ERR(bpc->clk);
|
||||
|
||||
bpc->chip.dev = &pdev->dev;
|
||||
bpc->chip.ops = &berlin_pwm_ops;
|
||||
bpc->chip.npwm = BERLIN_PWM_NUMPWMS;
|
||||
chip = &bpc->chip;
|
||||
chip->dev = &pdev->dev;
|
||||
chip->ops = &berlin_pwm_ops;
|
||||
chip->npwm = BERLIN_PWM_NUMPWMS;
|
||||
|
||||
ret = devm_pwmchip_add(&pdev->dev, &bpc->chip);
|
||||
ret = devm_pwmchip_add(&pdev->dev, chip);
|
||||
if (ret < 0)
|
||||
return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n");
|
||||
|
||||
platform_set_drvdata(pdev, bpc);
|
||||
platform_set_drvdata(pdev, chip);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int berlin_pwm_suspend(struct device *dev)
|
||||
{
|
||||
struct berlin_pwm_chip *bpc = dev_get_drvdata(dev);
|
||||
struct pwm_chip *chip = dev_get_drvdata(dev);
|
||||
struct berlin_pwm_chip *bpc = to_berlin_pwm_chip(chip);
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < bpc->chip.npwm; i++) {
|
||||
for (i = 0; i < chip->npwm; i++) {
|
||||
struct berlin_pwm_channel *channel = &bpc->channel[i];
|
||||
|
||||
channel->enable = berlin_pwm_readl(bpc, i, BERLIN_PWM_ENABLE);
|
||||
@ -247,7 +250,8 @@ static int berlin_pwm_suspend(struct device *dev)
|
||||
|
||||
static int berlin_pwm_resume(struct device *dev)
|
||||
{
|
||||
struct berlin_pwm_chip *bpc = dev_get_drvdata(dev);
|
||||
struct pwm_chip *chip = dev_get_drvdata(dev);
|
||||
struct berlin_pwm_chip *bpc = to_berlin_pwm_chip(chip);
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
@ -255,7 +259,7 @@ static int berlin_pwm_resume(struct device *dev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < bpc->chip.npwm; i++) {
|
||||
for (i = 0; i < chip->npwm; i++) {
|
||||
struct berlin_pwm_channel *channel = &bpc->channel[i];
|
||||
|
||||
berlin_pwm_writel(bpc, i, channel->ctrl, BERLIN_PWM_CONTROL);
|
||||
|
Loading…
Reference in New Issue
Block a user