summaryrefslogtreecommitdiffstats
path: root/drivers/pwm/pwm-clk.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2024-02-14 10:31:10 +0100
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>2024-02-15 12:59:20 +0100
commitfc6549a9368302bb029058aa049cc472989e2735 (patch)
treef47dc834242362126bd77723dc3179ef8eb2a063 /drivers/pwm/pwm-clk.c
parentpwm: brcmstb: Make use of devm_pwmchip_alloc() function (diff)
downloadlinux-fc6549a9368302bb029058aa049cc472989e2735.tar.xz
linux-fc6549a9368302bb029058aa049cc472989e2735.zip
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.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Diffstat (limited to 'drivers/pwm/pwm-clk.c')
-rw-r--r--drivers/pwm/pwm-clk.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/pwm/pwm-clk.c b/drivers/pwm/pwm-clk.c
index 9dd88b386907..aef35d9a6a61 100644
--- a/drivers/pwm/pwm-clk.c
+++ b/drivers/pwm/pwm-clk.c
@@ -81,35 +81,38 @@ static const struct pwm_ops pwm_clk_ops = {
static int pwm_clk_probe(struct platform_device *pdev)
{
+ struct pwm_chip *chip;
struct pwm_clk_chip *pcchip;
int ret;
pcchip = devm_kzalloc(&pdev->dev, sizeof(*pcchip), GFP_KERNEL);
if (!pcchip)
return -ENOMEM;
+ chip = &pcchip->chip;
pcchip->clk = devm_clk_get_prepared(&pdev->dev, NULL);
if (IS_ERR(pcchip->clk))
return dev_err_probe(&pdev->dev, PTR_ERR(pcchip->clk),
"Failed to get clock\n");
- pcchip->chip.dev = &pdev->dev;
- pcchip->chip.ops = &pwm_clk_ops;
- pcchip->chip.npwm = 1;
+ chip->dev = &pdev->dev;
+ chip->ops = &pwm_clk_ops;
+ chip->npwm = 1;
- ret = pwmchip_add(&pcchip->chip);
+ ret = pwmchip_add(chip);
if (ret < 0)
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;
}
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)
clk_disable(pcchip->clk);