* [PATCH 0/8] pwm: Get rid of pwm_[sg]et_chip_data()
@ 2023-06-29 9:48 Uwe Kleine-König
2023-06-29 9:48 ` [PATCH 3/8] pwm: jz4740: Put per-channel clk into driver data Uwe Kleine-König
0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2023-06-29 9:48 UTC (permalink / raw)
To: Thierry Reding, Benson Leung
Cc: linux-pwm, kernel, Krzysztof Kozlowski, Alim Akhtar,
linux-arm-kernel, linux-samsung-soc, Paul Cercueil, linux-mips,
Lee Jones, Guenter Roeck, chrome-platform
Hello,
the semantic of pwm_[sg]et_chip_data() overlaps with that of the
standard dev_[sg]et_drvdata() functions. Also as noted by George Stark
there is a problem in pwm-sti that relies on chipdata being available
even after a pwm_put (which clears chipdata).
To improve the situation this series converts all drivers that make use
of pwm chipdata to use well-known driver data instead and drop chipdata
support from the pwm framework.
Best regards
Uwe
Uwe Kleine-König (8):
pwm: berlin: Put channel config into driver data
pwm: samsung: Put channel data into driver data
pwm: jz4740: Put per-channel clk into driver data
pwm: lp3943: Drop usage of pwm_[gs]et_chip_data()
pwm: renesas: Drop usage of pwm_[gs]et_chip_data()
pwm: sti: Reduce number of allocations and drop usage of chip_data
pwm: cros-ec: Put per channel data into driver data
pwm: Drop pwm_[sg]et_chip_data()
drivers/pwm/core.c | 31 -----------------------------
drivers/pwm/pwm-berlin.c | 37 ++++++-----------------------------
drivers/pwm/pwm-cros-ec.c | 31 +++++++----------------------
drivers/pwm/pwm-jz4740.c | 11 +++++++----
drivers/pwm/pwm-lp3943.c | 21 +++++++-------------
drivers/pwm/pwm-renesas-tpu.c | 22 ++++++++++-----------
drivers/pwm/pwm-samsung.c | 20 +++++--------------
drivers/pwm/pwm-sti.c | 29 +++++++++++++--------------
include/linux/pwm.h | 14 -------------
9 files changed, 57 insertions(+), 159 deletions(-)
base-commit: 92554cdd428fce212d2a71a06939e7cab90f7c77
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/8] pwm: jz4740: Put per-channel clk into driver data
2023-06-29 9:48 [PATCH 0/8] pwm: Get rid of pwm_[sg]et_chip_data() Uwe Kleine-König
@ 2023-06-29 9:48 ` Uwe Kleine-König
2023-06-30 10:25 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2023-06-29 9:48 UTC (permalink / raw)
To: Thierry Reding; +Cc: Paul Cercueil, linux-mips, linux-pwm, kernel
Stop using chip_data which is about to go away. Instead track the
per-channel clk in struct jz4740_pwm_chip.
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(-)
diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
index 3b7067f6cd0d..e0a57d71a60c 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, sizeof(*jz4740) + info->num_pwms * sizeof(jz4740->clk[0]),
+ GFP_KERNEL);
if (!jz4740)
return -ENOMEM;
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/8] pwm: jz4740: Put per-channel clk into driver data
2023-06-29 9:48 ` [PATCH 3/8] pwm: jz4740: Put per-channel clk into driver data Uwe Kleine-König
@ 2023-06-30 10:25 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-30 10:25 UTC (permalink / raw)
To: Uwe Kleine-König, Thierry Reding
Cc: Paul Cercueil, linux-mips, linux-pwm, kernel
On 29/6/23 11:48, Uwe Kleine-König wrote:
> Stop using chip_data which is about to go away. Instead track the
> per-channel clk in struct jz4740_pwm_chip.
>
> 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(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/8] pwm: jz4740: Put per-channel clk into driver data
2023-06-29 14:07 ` Uwe Kleine-König
2023-06-29 22:55 ` Paul Cercueil
@ 2023-06-30 10:28 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-30 10:28 UTC (permalink / raw)
To: Uwe Kleine-König, Paul Cercueil
Cc: linux-pwm, kernel, Thierry Reding, linux-mips
On 29/6/23 16:07, Uwe Kleine-König wrote:
> On Thu, Jun 29, 2023 at 01:12:25PM +0200, Paul Cercueil wrote:
>> Le 29 juin 2023 11:48, Uwe Kleine-König <u.kleine-koenig@pengutronix.de> a écrit :
>>>
>>> Stop using chip_data which is about to go away. Instead track the
>>> per-channel clk in struct jz4740_pwm_chip.
>>>
>>> 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(-)
>>> @@ -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, sizeof(*jz4740) + info->num_pwms * sizeof(jz4740->clk[0]),
>>> + GFP_KERNEL);
>>
>> LGTM, but please use struct_size() from <linux/overflow.h>.
>
> Ah, I thought there is such a macro, but I didn't find it neither by
> grepping nor by asking in #kernelnewbies. Thanks, will respin the series
> in a few days.
Oh, TIL too :) R-b stands in respin.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/8] pwm: jz4740: Put per-channel clk into driver data
2023-06-29 14:07 ` Uwe Kleine-König
@ 2023-06-29 22:55 ` Paul Cercueil
2023-06-30 10:28 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 6+ messages in thread
From: Paul Cercueil @ 2023-06-29 22:55 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: linux-pwm, kernel, Thierry Reding, linux-mips
Le jeu. 29 juin 2023 à 16:07:45 +0200, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> a écrit :
> Hello Paul,
>
> first of all, your mail is strange. I think the problem is that it
> doesn't contain a Message-Id. The result is that I got it twice and in
> return vger.kernel.org seems to have refused to take it. At least it's
> neither in lore.kernel.org nor in
> https://patchwork.ozlabs.org/project/linux-pwm/patch/20230629094839.757092-4-u.kleine-koenig@pengutronix.de/
> .
Sorry about that, I'm at the Embedded Linux conference in Prague
without my computer, so I just answered from my Android phone. I didn't
know it would cause problems, I guess I'll refrain from doing that from
now on.
Cheers,
-Paul
>
> On Thu, Jun 29, 2023 at 01:12:25PM +0200, Paul Cercueil wrote:
>> Le 29 juin 2023 11:48, Uwe Kleine-König
>> <u.kleine-koenig@pengutronix.de> a écrit :
>> >
>> > Stop using chip_data which is about to go away. Instead track the
>> > per-channel clk in struct jz4740_pwm_chip.
>> >
>> > 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(-)
>> >
>> > diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
>> > index 3b7067f6cd0d..e0a57d71a60c 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, sizeof(*jz4740) + info->num_pwms *
>> sizeof(jz4740->clk[0]),
>> > + GFP_KERNEL);
>>
>> LGTM, but please use struct_size() from <linux/overflow.h>.
>
> Ah, I thought there is such a macro, but I didn't find it neither by
> grepping nor by asking in #kernelnewbies. Thanks, will respin the
> series
> in a few days.
>
> Best regards
> Uwe
>
> --
> Pengutronix e.K. | Uwe Kleine-König
> |
> Industrial Linux Solutions |
> https://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/8] pwm: jz4740: Put per-channel clk into driver data
[not found] <notmuch-sha1-d2bb15a9dcb5470a6eebca0b1a01c57918a22695>
@ 2023-06-29 14:07 ` Uwe Kleine-König
2023-06-29 22:55 ` Paul Cercueil
2023-06-30 10:28 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2023-06-29 14:07 UTC (permalink / raw)
To: Paul Cercueil; +Cc: linux-pwm, kernel, Thierry Reding, linux-mips
[-- Attachment #1: Type: text/plain, Size: 2938 bytes --]
Hello Paul,
first of all, your mail is strange. I think the problem is that it
doesn't contain a Message-Id. The result is that I got it twice and in
return vger.kernel.org seems to have refused to take it. At least it's
neither in lore.kernel.org nor in
https://patchwork.ozlabs.org/project/linux-pwm/patch/20230629094839.757092-4-u.kleine-koenig@pengutronix.de/
.
On Thu, Jun 29, 2023 at 01:12:25PM +0200, Paul Cercueil wrote:
> Le 29 juin 2023 11:48, Uwe Kleine-König <u.kleine-koenig@pengutronix.de> a écrit :
> >
> > Stop using chip_data which is about to go away. Instead track the
> > per-channel clk in struct jz4740_pwm_chip.
> >
> > 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(-)
> >
> > diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
> > index 3b7067f6cd0d..e0a57d71a60c 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, sizeof(*jz4740) + info->num_pwms * sizeof(jz4740->clk[0]),
> > + GFP_KERNEL);
>
> LGTM, but please use struct_size() from <linux/overflow.h>.
Ah, I thought there is such a macro, but I didn't find it neither by
grepping nor by asking in #kernelnewbies. Thanks, will respin the series
in a few days.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-06-30 10:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-29 9:48 [PATCH 0/8] pwm: Get rid of pwm_[sg]et_chip_data() Uwe Kleine-König
2023-06-29 9:48 ` [PATCH 3/8] pwm: jz4740: Put per-channel clk into driver data Uwe Kleine-König
2023-06-30 10:25 ` Philippe Mathieu-Daudé
[not found] <notmuch-sha1-d2bb15a9dcb5470a6eebca0b1a01c57918a22695>
2023-06-29 14:07 ` Uwe Kleine-König
2023-06-29 22:55 ` Paul Cercueil
2023-06-30 10:28 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).