diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 21:00:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 21:00:37 +0000 |
commit | 94ac2ab3fff96814d7460a27a0e9d004abbd4128 (patch) | |
tree | 9a4eb8cc234b540b0f4b93363109cdd37a20540b /drivers/pwm/pwm-clk.c | |
parent | Adding debian version 6.8.12-1. (diff) | |
download | linux-94ac2ab3fff96814d7460a27a0e9d004abbd4128.tar.xz linux-94ac2ab3fff96814d7460a27a0e9d004abbd4128.zip |
Merging upstream version 6.9.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'drivers/pwm/pwm-clk.c')
-rw-r--r-- | drivers/pwm/pwm-clk.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/pwm/pwm-clk.c b/drivers/pwm/pwm-clk.c index 9dd88b3869..c19a482d7e 100644 --- a/drivers/pwm/pwm-clk.c +++ b/drivers/pwm/pwm-clk.c @@ -28,12 +28,14 @@ #include <linux/pwm.h> struct pwm_clk_chip { - struct pwm_chip chip; struct clk *clk; bool clk_enabled; }; -#define to_pwm_clk_chip(_chip) container_of(_chip, struct pwm_clk_chip, chip) +static inline struct pwm_clk_chip *to_pwm_clk_chip(struct pwm_chip *chip) +{ + return pwmchip_get_drvdata(chip); +} static int pwm_clk_apply(struct pwm_chip *chip, struct pwm_device *pwm, const struct pwm_state *state) @@ -81,35 +83,36 @@ 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 = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*pcchip)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + pcchip = to_pwm_clk_chip(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->ops = &pwm_clk_ops; - 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); |