Commit 89c8de78 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Thierry Reding

pwm: jz4740: Put per-channel clk into driver data

Stop using chip_data which is about to go away. Instead track the
per-channel clk in struct jz4740_pwm_chip.
Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: default avatarPaul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20230705080650.2353391-4-u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent e3fe982b
...@@ -27,6 +27,7 @@ struct soc_info { ...@@ -27,6 +27,7 @@ struct soc_info {
struct jz4740_pwm_chip { struct jz4740_pwm_chip {
struct pwm_chip chip; struct pwm_chip chip;
struct regmap *map; struct regmap *map;
struct clk *clk[];
}; };
static inline struct jz4740_pwm_chip *to_jz4740(struct pwm_chip *chip) 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) ...@@ -70,14 +71,15 @@ static int jz4740_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
return err; return err;
} }
pwm_set_chip_data(pwm, clk); jz->clk[pwm->hwpwm] = clk;
return 0; return 0;
} }
static void jz4740_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) 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_disable_unprepare(clk);
clk_put(clk); clk_put(clk);
...@@ -123,7 +125,7 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -123,7 +125,7 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
{ {
struct jz4740_pwm_chip *jz = to_jz4740(pwm->chip); struct jz4740_pwm_chip *jz = to_jz4740(pwm->chip);
unsigned long long tmp = 0xffffull * NSEC_PER_SEC; unsigned long long tmp = 0xffffull * NSEC_PER_SEC;
struct clk *clk = pwm_get_chip_data(pwm); struct clk *clk = jz->clk[pwm->hwpwm];
unsigned long period, duty; unsigned long period, duty;
long rate; long rate;
int err; int err;
...@@ -228,7 +230,8 @@ static int jz4740_pwm_probe(struct platform_device *pdev) ...@@ -228,7 +230,8 @@ static int jz4740_pwm_probe(struct platform_device *pdev)
if (!info) if (!info)
return -EINVAL; return -EINVAL;
jz = devm_kzalloc(dev, sizeof(*jz), GFP_KERNEL); jz = devm_kzalloc(dev, struct_size(jz, clk, info->num_pwms),
GFP_KERNEL);
if (!jz) if (!jz)
return -ENOMEM; return -ENOMEM;
......
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