pwm: rochchip: Prepare removing pwm_chip from driver data

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

Link: https://lore.kernel.org/r/301657442c578cc8d330ad2b07463d59fed4bff6.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This commit is contained in:
Uwe Kleine-König 2024-02-14 10:32:18 +01:00
parent 3a284e0eae
commit 77e94c37db

View File

@ -296,6 +296,7 @@ MODULE_DEVICE_TABLE(of, rockchip_pwm_dt_ids);
static int rockchip_pwm_probe(struct platform_device *pdev)
{
struct pwm_chip *chip;
struct rockchip_pwm_chip *pc;
u32 enable_conf, ctrl;
bool enabled;
@ -304,6 +305,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
if (!pc)
return -ENOMEM;
chip = &pc->chip;
pc->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(pc->base))
@ -337,18 +339,18 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
goto err_clk;
}
platform_set_drvdata(pdev, pc);
platform_set_drvdata(pdev, chip);
pc->data = device_get_match_data(&pdev->dev);
pc->chip.dev = &pdev->dev;
pc->chip.ops = &rockchip_pwm_ops;
pc->chip.npwm = 1;
chip->dev = &pdev->dev;
chip->ops = &rockchip_pwm_ops;
chip->npwm = 1;
enable_conf = pc->data->enable_conf;
ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl);
enabled = (ctrl & enable_conf) == enable_conf;
ret = pwmchip_add(&pc->chip);
ret = pwmchip_add(chip);
if (ret < 0) {
dev_err_probe(&pdev->dev, ret, "pwmchip_add() failed\n");
goto err_pclk;
@ -372,9 +374,10 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
static void rockchip_pwm_remove(struct platform_device *pdev)
{
struct rockchip_pwm_chip *pc = platform_get_drvdata(pdev);
struct pwm_chip *chip = platform_get_drvdata(pdev);
struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip);
pwmchip_remove(&pc->chip);
pwmchip_remove(chip);
clk_unprepare(pc->pclk);
clk_unprepare(pc->clk);