linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] meson pwm small fixes
@ 2024-04-23 16:13 George Stark
  2024-04-23 16:13 ` [PATCH 1/2] pwm: meson: drop unneeded check in get_state callback George Stark
  2024-04-23 16:13 ` [PATCH 2/2] pwm: meson: add check for error from clk_round_rate() George Stark
  0 siblings, 2 replies; 6+ messages in thread
From: George Stark @ 2024-04-23 16:13 UTC (permalink / raw)
  To: u.kleine-koenig, neil.armstrong, khilman, jbrunet,
	martin.blumenstingl, thierry.reding, hkallweit1
  Cc: linux-pwm, linux-amlogic, linux-arm-kernel, linux-kernel, kernel,
	George Stark

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] pwm: meson: drop unneeded check in get_state callback
  2024-04-23 16:13 [PATCH 0/2] meson pwm small fixes George Stark
@ 2024-04-23 16:13 ` George Stark
  2024-04-24  7:19   ` Uwe Kleine-König
  2024-04-23 16:13 ` [PATCH 2/2] pwm: meson: add check for error from clk_round_rate() George Stark
  1 sibling, 1 reply; 6+ messages in thread
From: George Stark @ 2024-04-23 16:13 UTC (permalink / raw)
  To: u.kleine-koenig, neil.armstrong, khilman, jbrunet,
	martin.blumenstingl, thierry.reding, hkallweit1
  Cc: linux-pwm, linux-amlogic, linux-arm-kernel, linux-kernel, kernel,
	George Stark, Dmitry Rokosov

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 <gnstark@salutedevices.com>
Signed-off-by: Dmitry Rokosov <ddrokosov@salutedevices.com>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] pwm: meson: add check for error from clk_round_rate()
  2024-04-23 16:13 [PATCH 0/2] meson pwm small fixes George Stark
  2024-04-23 16:13 ` [PATCH 1/2] pwm: meson: drop unneeded check in get_state callback George Stark
@ 2024-04-23 16:13 ` George Stark
  2024-04-24  7:13   ` Uwe Kleine-König
  1 sibling, 1 reply; 6+ messages in thread
From: George Stark @ 2024-04-23 16:13 UTC (permalink / raw)
  To: u.kleine-koenig, neil.armstrong, khilman, jbrunet,
	martin.blumenstingl, thierry.reding, hkallweit1
  Cc: linux-pwm, linux-amlogic, linux-arm-kernel, linux-kernel, kernel,
	George Stark, Dmitry Rokosov

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 <gnstark@salutedevices.com>
Signed-off-by: Dmitry Rokosov <ddrokosov@salutedevices.com>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] pwm: meson: add check for error from clk_round_rate()
  2024-04-23 16:13 ` [PATCH 2/2] pwm: meson: add check for error from clk_round_rate() George Stark
@ 2024-04-24  7:13   ` Uwe Kleine-König
  0 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2024-04-24  7:13 UTC (permalink / raw)
  To: George Stark
  Cc: neil.armstrong, khilman, jbrunet, martin.blumenstingl,
	thierry.reding, hkallweit1, linux-pwm, linux-amlogic,
	linux-arm-kernel, linux-kernel, kernel, Dmitry Rokosov

[-- Attachment #1: Type: text/plain, Size: 1289 bytes --]

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 <gnstark@salutedevices.com>
> Signed-off-by: Dmitry Rokosov <ddrokosov@salutedevices.com>
> ---
>  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/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] pwm: meson: drop unneeded check in get_state callback
  2024-04-23 16:13 ` [PATCH 1/2] pwm: meson: drop unneeded check in get_state callback George Stark
@ 2024-04-24  7:19   ` Uwe Kleine-König
  2024-04-24  7:57     ` George Stark
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2024-04-24  7:19 UTC (permalink / raw)
  To: George Stark
  Cc: neil.armstrong, khilman, jbrunet, martin.blumenstingl,
	thierry.reding, hkallweit1, linux-pwm, linux-amlogic,
	linux-arm-kernel, linux-kernel, kernel, Dmitry Rokosov

[-- Attachment #1: Type: text/plain, Size: 930 bytes --]

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 <gnstark@salutedevices.com>
> Signed-off-by: Dmitry Rokosov <ddrokosov@salutedevices.com>

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/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] pwm: meson: drop unneeded check in get_state callback
  2024-04-24  7:19   ` Uwe Kleine-König
@ 2024-04-24  7:57     ` George Stark
  0 siblings, 0 replies; 6+ messages in thread
From: George Stark @ 2024-04-24  7:57 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: neil.armstrong, khilman, jbrunet, martin.blumenstingl,
	thierry.reding, hkallweit1, linux-pwm, linux-amlogic,
	linux-arm-kernel, linux-kernel, kernel, Dmitry Rokosov

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 <gnstark@salutedevices.com>
>> Signed-off-by: Dmitry Rokosov <ddrokosov@salutedevices.com>
> 
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-24  7:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 16:13 [PATCH 0/2] meson pwm small fixes George Stark
2024-04-23 16:13 ` [PATCH 1/2] pwm: meson: drop unneeded check in get_state callback George Stark
2024-04-24  7:19   ` Uwe Kleine-König
2024-04-24  7:57     ` George Stark
2024-04-23 16:13 ` [PATCH 2/2] pwm: meson: add check for error from clk_round_rate() George Stark
2024-04-24  7:13   ` Uwe Kleine-König

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).