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

pwm: clk: Prepare removing pwm_chip from driver data

This prepares the driver for further changes that will drop struct
pwm_chip chip from struct pwm_clk_chip. Use the pwm_chip as driver data
instead of the pwm_clk_chip to get access to the pwm_chip in
pwm_clk_remove() without using pcchip->chip.

Link: https://lore.kernel.org/r/cfbb7c571489ac3d9ca13835b3bd038aaca69638.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent f3d1efd0
...@@ -81,35 +81,38 @@ static const struct pwm_ops pwm_clk_ops = { ...@@ -81,35 +81,38 @@ static const struct pwm_ops pwm_clk_ops = {
static int pwm_clk_probe(struct platform_device *pdev) static int pwm_clk_probe(struct platform_device *pdev)
{ {
struct pwm_chip *chip;
struct pwm_clk_chip *pcchip; struct pwm_clk_chip *pcchip;
int ret; int ret;
pcchip = devm_kzalloc(&pdev->dev, sizeof(*pcchip), GFP_KERNEL); pcchip = devm_kzalloc(&pdev->dev, sizeof(*pcchip), GFP_KERNEL);
if (!pcchip) if (!pcchip)
return -ENOMEM; return -ENOMEM;
chip = &pcchip->chip;
pcchip->clk = devm_clk_get_prepared(&pdev->dev, NULL); pcchip->clk = devm_clk_get_prepared(&pdev->dev, NULL);
if (IS_ERR(pcchip->clk)) if (IS_ERR(pcchip->clk))
return dev_err_probe(&pdev->dev, PTR_ERR(pcchip->clk), return dev_err_probe(&pdev->dev, PTR_ERR(pcchip->clk),
"Failed to get clock\n"); "Failed to get clock\n");
pcchip->chip.dev = &pdev->dev; chip->dev = &pdev->dev;
pcchip->chip.ops = &pwm_clk_ops; chip->ops = &pwm_clk_ops;
pcchip->chip.npwm = 1; chip->npwm = 1;
ret = pwmchip_add(&pcchip->chip); ret = pwmchip_add(chip);
if (ret < 0) if (ret < 0)
return dev_err_probe(&pdev->dev, ret, "Failed to add pwm chip\n"); return dev_err_probe(&pdev->dev, ret, "Failed to add pwm chip\n");
platform_set_drvdata(pdev, pcchip); platform_set_drvdata(pdev, chip);
return 0; return 0;
} }
static void pwm_clk_remove(struct platform_device *pdev) static void pwm_clk_remove(struct platform_device *pdev)
{ {
struct pwm_clk_chip *pcchip = platform_get_drvdata(pdev); struct pwm_chip *chip = platform_get_drvdata(pdev);
struct pwm_clk_chip *pcchip = to_pwm_clk_chip(chip);
pwmchip_remove(&pcchip->chip); pwmchip_remove(chip);
if (pcchip->clk_enabled) if (pcchip->clk_enabled)
clk_disable(pcchip->clk); clk_disable(pcchip->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