2024-04-23 16:14:16

by George Stark

[permalink] [raw]
Subject: [PATCH 0/2] meson pwm small fixes

Just some small fixes for meson pwm.

George Stark (2):
pwm: meson: drop unneeded check in get_state callback
pwm: meson: add check for error from clk_round_rate()

drivers/pwm/pwm-meson.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

--
2.25.1



2024-04-23 16:14:18

by George Stark

[permalink] [raw]
Subject: [PATCH 1/2] pwm: meson: drop unneeded check in get_state callback

Drop checking state argument for null pointer in meson_pwm_get_state()
due to it is called only from pwm core with always valid arguments.

Fixes: 211ed630753d ("pwm: Add support for Meson PWM Controller")
Signed-off-by: George Stark <[email protected]>
Signed-off-by: Dmitry Rokosov <[email protected]>
---
drivers/pwm/pwm-meson.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 529a541ba7b6..ebe76298f6e2 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -311,9 +311,6 @@ static int meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
struct meson_pwm_channel *channel;
u32 value;

- if (!state)
- return 0;
-
channel = &meson->channels[pwm->hwpwm];
channel_data = &meson_pwm_per_channel_data[pwm->hwpwm];

--
2.25.1


2024-04-23 16:14:27

by George Stark

[permalink] [raw]
Subject: [PATCH 2/2] pwm: meson: add check for error from clk_round_rate()

clk_round_rate() can return not only zero if requested frequency can not
be provided but also negative error code so add check for it too.

Fixes: 329db102a26d ("pwm: meson: make full use of common clock framework")
Signed-off-by: George Stark <[email protected]>
Signed-off-by: Dmitry Rokosov <[email protected]>
---
drivers/pwm/pwm-meson.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index ebe76298f6e2..52604635b31e 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -168,9 +168,10 @@ static int meson_pwm_calc(struct pwm_chip *chip, struct pwm_device *pwm,
freq = ULONG_MAX;

fin_freq = clk_round_rate(channel->clk, freq);
- if (fin_freq == 0) {
- dev_err(pwmchip_parent(chip), "invalid source clock frequency\n");
- return -EINVAL;
+ if (fin_freq <= 0) {
+ dev_err(pwmchip_parent(chip),
+ "invalid source clock frequency %llu\n", freq);
+ return fin_freq ? fin_freq : -EINVAL;
}

dev_dbg(pwmchip_parent(chip), "fin_freq: %lu Hz\n", fin_freq);
--
2.25.1


2024-04-24 07:13:49

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 2/2] pwm: meson: add check for error from clk_round_rate()

Hello,

On Tue, Apr 23, 2024 at 07:13:56PM +0300, George Stark wrote:
> clk_round_rate() can return not only zero if requested frequency can not
> be provided but also negative error code so add check for it too.
>
> Fixes: 329db102a26d ("pwm: meson: make full use of common clock framework")
> Signed-off-by: George Stark <[email protected]>
> Signed-off-by: Dmitry Rokosov <[email protected]>
> ---
> drivers/pwm/pwm-meson.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
> index ebe76298f6e2..52604635b31e 100644
> --- a/drivers/pwm/pwm-meson.c
> +++ b/drivers/pwm/pwm-meson.c
> @@ -168,9 +168,10 @@ static int meson_pwm_calc(struct pwm_chip *chip, struct pwm_device *pwm,
> freq = ULONG_MAX;
>
> fin_freq = clk_round_rate(channel->clk, freq);
> - if (fin_freq == 0) {
> - dev_err(pwmchip_parent(chip), "invalid source clock frequency\n");
> - return -EINVAL;
> + if (fin_freq <= 0) {

fin_freq is an unsigned long, so your change doesn't have the intended
effect.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | https://www.pengutronix.de/ |


Attachments:
(No filename) (1.26 kB)
signature.asc (499.00 B)
Download all attachments

2024-04-24 07:23:00

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 1/2] pwm: meson: drop unneeded check in get_state callback

Hello George,

On Tue, Apr 23, 2024 at 07:13:55PM +0300, George Stark wrote:
> Drop checking state argument for null pointer in meson_pwm_get_state()
> due to it is called only from pwm core with always valid arguments.
>
> Fixes: 211ed630753d ("pwm: Add support for Meson PWM Controller")
> Signed-off-by: George Stark <[email protected]>
> Signed-off-by: Dmitry Rokosov <[email protected]>

I'd apply this one with the following changes if you agree:

- capitalize "drop" in the Subject line
- s/get_state/.get_state()/
- make "null" all caps (i.e. "NULL")
- swap the order of Signed-off-by lines to have yours last.

Alternatively send it in a v2 together with addressing the comment in
the second patch.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | https://www.pengutronix.de/ |


Attachments:
(No filename) (930.00 B)
signature.asc (499.00 B)
Download all attachments

2024-04-24 07:58:13

by George Stark

[permalink] [raw]
Subject: Re: [PATCH 1/2] pwm: meson: drop unneeded check in get_state callback

Hello Uwe

Thanks for the review

On 4/24/24 10:19, Uwe Kleine-König wrote:
> Hello George,
>
> On Tue, Apr 23, 2024 at 07:13:55PM +0300, George Stark wrote:
>> Drop checking state argument for null pointer in meson_pwm_get_state()
>> due to it is called only from pwm core with always valid arguments.
>>
>> Fixes: 211ed630753d ("pwm: Add support for Meson PWM Controller")
>> Signed-off-by: George Stark <[email protected]>
>> Signed-off-by: Dmitry Rokosov <[email protected]>
>
> I'd apply this one with the following changes if you agree:
>
> - capitalize "drop" in the Subject line
> - s/get_state/.get_state()/
> - make "null" all caps (i.e. "NULL")
> - swap the order of Signed-off-by lines to have yours last.
>
> Alternatively send it in a v2 together with addressing the comment in
> the second patch.

I agree with the proposed changes and
I'll clean it up after myself in v2

> Best regards
> Uwe
>

--
Best regards
George