diff mbox series

[v2,3/8] pwm: jz4740: Put per-channel clk into driver data

Message ID 20230705080650.2353391-4-u.kleine-koenig@pengutronix.de (mailing list archive)
State Handled Elsewhere
Headers show
Series pwm: Get rid of pwm_[sg]et_chip_data() | expand

Commit Message

Uwe Kleine-König July 5, 2023, 8:06 a.m. UTC
Stop using chip_data which is about to go away. Instead track the
per-channel clk in struct jz4740_pwm_chip.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-jz4740.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Paul Cercueil July 5, 2023, 8:10 a.m. UTC | #1
Le mercredi 05 juillet 2023 à 10:06 +0200, Uwe Kleine-König a écrit :
> Stop using chip_data which is about to go away. Instead track the
> per-channel clk in struct jz4740_pwm_chip.
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Paul Cercueil <paul@crapouillou.net>

Cheers,
-Paul

> ---
>  drivers/pwm/pwm-jz4740.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
> index 3b7067f6cd0d..8b01819df67d 100644
> --- a/drivers/pwm/pwm-jz4740.c
> +++ b/drivers/pwm/pwm-jz4740.c
> @@ -27,6 +27,7 @@ struct soc_info {
>  struct jz4740_pwm_chip {
>         struct pwm_chip chip;
>         struct regmap *map;
> +       struct clk *clk[];
>  };
>  
>  static inline struct jz4740_pwm_chip *to_jz4740(struct pwm_chip
> *chip)
> @@ -70,14 +71,15 @@ static int jz4740_pwm_request(struct pwm_chip
> *chip, struct pwm_device *pwm)
>                 return err;
>         }
>  
> -       pwm_set_chip_data(pwm, clk);
> +       jz->clk[pwm->hwpwm] = clk;
>  
>         return 0;
>  }
>  
>  static void jz4740_pwm_free(struct pwm_chip *chip, struct pwm_device
> *pwm)
>  {
> -       struct clk *clk = pwm_get_chip_data(pwm);
> +       struct jz4740_pwm_chip *jz = to_jz4740(chip);
> +       struct clk *clk = jz->clk[pwm->hwpwm];
>  
>         clk_disable_unprepare(clk);
>         clk_put(clk);
> @@ -123,7 +125,7 @@ static int jz4740_pwm_apply(struct pwm_chip
> *chip, struct pwm_device *pwm,
>  {
>         struct jz4740_pwm_chip *jz4740 = to_jz4740(pwm->chip);
>         unsigned long long tmp = 0xffffull * NSEC_PER_SEC;
> -       struct clk *clk = pwm_get_chip_data(pwm);
> +       struct clk *clk = jz4740->clk[pwm->hwpwm];
>         unsigned long period, duty;
>         long rate;
>         int err;
> @@ -229,7 +231,8 @@ static int jz4740_pwm_probe(struct
> platform_device *pdev)
>         if (!info)
>                 return -EINVAL;
>  
> -       jz4740 = devm_kzalloc(dev, sizeof(*jz4740), GFP_KERNEL);
> +       jz4740 = devm_kzalloc(dev, struct_size(jz4740, clk, info-
> >num_pwms),
> +                             GFP_KERNEL);
>         if (!jz4740)
>                 return -ENOMEM;
>
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
index 3b7067f6cd0d..8b01819df67d 100644
--- a/drivers/pwm/pwm-jz4740.c
+++ b/drivers/pwm/pwm-jz4740.c
@@ -27,6 +27,7 @@  struct soc_info {
 struct jz4740_pwm_chip {
 	struct pwm_chip chip;
 	struct regmap *map;
+	struct clk *clk[];
 };
 
 static inline struct jz4740_pwm_chip *to_jz4740(struct pwm_chip *chip)
@@ -70,14 +71,15 @@  static int jz4740_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
 		return err;
 	}
 
-	pwm_set_chip_data(pwm, clk);
+	jz->clk[pwm->hwpwm] = clk;
 
 	return 0;
 }
 
 static void jz4740_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
 {
-	struct clk *clk = pwm_get_chip_data(pwm);
+	struct jz4740_pwm_chip *jz = to_jz4740(chip);
+	struct clk *clk = jz->clk[pwm->hwpwm];
 
 	clk_disable_unprepare(clk);
 	clk_put(clk);
@@ -123,7 +125,7 @@  static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 {
 	struct jz4740_pwm_chip *jz4740 = to_jz4740(pwm->chip);
 	unsigned long long tmp = 0xffffull * NSEC_PER_SEC;
-	struct clk *clk = pwm_get_chip_data(pwm);
+	struct clk *clk = jz4740->clk[pwm->hwpwm];
 	unsigned long period, duty;
 	long rate;
 	int err;
@@ -229,7 +231,8 @@  static int jz4740_pwm_probe(struct platform_device *pdev)
 	if (!info)
 		return -EINVAL;
 
-	jz4740 = devm_kzalloc(dev, sizeof(*jz4740), GFP_KERNEL);
+	jz4740 = devm_kzalloc(dev, struct_size(jz4740, clk, info->num_pwms),
+			      GFP_KERNEL);
 	if (!jz4740)
 		return -ENOMEM;