diff options
Diffstat (limited to 'drivers/pwm/pwm-berlin.c')
| -rw-r--r-- | drivers/pwm/pwm-berlin.c | 29 | 
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/pwm/pwm-berlin.c b/drivers/pwm/pwm-berlin.c index 442913232dc0..831aed228caf 100644 --- a/drivers/pwm/pwm-berlin.c +++ b/drivers/pwm/pwm-berlin.c @@ -49,7 +49,6 @@ struct berlin_pwm_channel {  };  struct berlin_pwm_chip { -	struct pwm_chip chip;  	struct clk *clk;  	void __iomem *base;  	struct berlin_pwm_channel channel[BERLIN_PWM_NUMPWMS]; @@ -57,7 +56,7 @@ struct berlin_pwm_chip {  static inline struct berlin_pwm_chip *to_berlin_pwm_chip(struct pwm_chip *chip)  { -	return container_of(chip, struct berlin_pwm_chip, chip); +	return pwmchip_get_drvdata(chip);  }  static inline u32 berlin_pwm_readl(struct berlin_pwm_chip *bpc, @@ -198,12 +197,14 @@ 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; -	bpc = devm_kzalloc(&pdev->dev, sizeof(*bpc), GFP_KERNEL); -	if (!bpc) -		return -ENOMEM; +	chip = devm_pwmchip_alloc(&pdev->dev, BERLIN_PWM_NUMPWMS, sizeof(*bpc)); +	if (IS_ERR(chip)) +		return PTR_ERR(chip); +	bpc = to_berlin_pwm_chip(chip);  	bpc->base = devm_platform_ioremap_resource(pdev, 0);  	if (IS_ERR(bpc->base)) @@ -213,25 +214,24 @@ 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->ops = &berlin_pwm_ops; -	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 +247,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 +256,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);  | 
