Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+13 -9
+13 -9
drivers/pwm/pwm-berlin.c
··· 198 198 199 199 static int berlin_pwm_probe(struct platform_device *pdev) 200 200 { 201 + struct pwm_chip *chip; 201 202 struct berlin_pwm_chip *bpc; 202 203 int ret; 203 204 ··· 214 213 if (IS_ERR(bpc->clk)) 215 214 return PTR_ERR(bpc->clk); 216 215 217 - bpc->chip.dev = &pdev->dev; 218 - bpc->chip.ops = &berlin_pwm_ops; 219 - bpc->chip.npwm = BERLIN_PWM_NUMPWMS; 216 + chip = &bpc->chip; 217 + chip->dev = &pdev->dev; 218 + chip->ops = &berlin_pwm_ops; 219 + chip->npwm = BERLIN_PWM_NUMPWMS; 220 220 221 - ret = devm_pwmchip_add(&pdev->dev, &bpc->chip); 221 + ret = devm_pwmchip_add(&pdev->dev, chip); 222 222 if (ret < 0) 223 223 return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); 224 224 225 - platform_set_drvdata(pdev, bpc); 225 + platform_set_drvdata(pdev, chip); 226 226 227 227 return 0; 228 228 } 229 229 230 230 static int berlin_pwm_suspend(struct device *dev) 231 231 { 232 - struct berlin_pwm_chip *bpc = dev_get_drvdata(dev); 232 + struct pwm_chip *chip = dev_get_drvdata(dev); 233 + struct berlin_pwm_chip *bpc = to_berlin_pwm_chip(chip); 233 234 unsigned int i; 234 235 235 - for (i = 0; i < bpc->chip.npwm; i++) { 236 + for (i = 0; i < chip->npwm; i++) { 236 237 struct berlin_pwm_channel *channel = &bpc->channel[i]; 237 238 238 239 channel->enable = berlin_pwm_readl(bpc, i, BERLIN_PWM_ENABLE); ··· 250 247 251 248 static int berlin_pwm_resume(struct device *dev) 252 249 { 253 - struct berlin_pwm_chip *bpc = dev_get_drvdata(dev); 250 + struct pwm_chip *chip = dev_get_drvdata(dev); 251 + struct berlin_pwm_chip *bpc = to_berlin_pwm_chip(chip); 254 252 unsigned int i; 255 253 int ret; 256 254 ··· 259 255 if (ret) 260 256 return ret; 261 257 262 - for (i = 0; i < bpc->chip.npwm; i++) { 258 + for (i = 0; i < chip->npwm; i++) { 263 259 struct berlin_pwm_channel *channel = &bpc->channel[i]; 264 260 265 261 berlin_pwm_writel(bpc, i, channel->ctrl, BERLIN_PWM_CONTROL);