* [PATCH v3] pwm: meson: modify and simplify calculation in meson_pwm_get_state
@ 2023-05-02 20:33 Heiner Kallweit
2023-05-08 19:44 ` Martin Blumenstingl
2023-05-11 14:34 ` Dmitry Rokosov
0 siblings, 2 replies; 3+ messages in thread
From: Heiner Kallweit @ 2023-05-02 20:33 UTC (permalink / raw)
To: Jerome Brunet, Martin Blumenstingl, Neil Armstrong, Kevin Hilman,
Uwe Kleine-König, thierry.reding
Cc: linux-arm-kernel, open list:ARM/Amlogic Meson...,
linux-pwm, Dmitry Rokosov
I don't see a reason why we should treat the case lo < hi differently
and return 0 as period and duty_cycle. The current logic was added with
c375bcbaabdb ("pwm: meson: Read the full hardware state in
meson_pwm_get_state()"), Martin as original author doesn't remember why
it was implemented this way back then.
So let's handle it as normal use case and also remove the optimization
for lo == 0. I think the improved readability is worth it.
Fixes: c375bcbaabdb ("pwm: meson: Read the full hardware state in meson_pwm_get_state()")
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: stable@vger.kernel.org
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
v2:
- improve commit description
v3:
- make patch a fix
---
drivers/pwm/pwm-meson.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 5732300eb..3865538dd 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -351,18 +351,8 @@ static int meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
channel->lo = FIELD_GET(PWM_LOW_MASK, value);
channel->hi = FIELD_GET(PWM_HIGH_MASK, value);
- if (channel->lo == 0) {
- state->period = meson_pwm_cnt_to_ns(chip, pwm, channel->hi);
- state->duty_cycle = state->period;
- } else if (channel->lo >= channel->hi) {
- state->period = meson_pwm_cnt_to_ns(chip, pwm,
- channel->lo + channel->hi);
- state->duty_cycle = meson_pwm_cnt_to_ns(chip, pwm,
- channel->hi);
- } else {
- state->period = 0;
- state->duty_cycle = 0;
- }
+ state->period = meson_pwm_cnt_to_ns(chip, pwm, channel->lo + channel->hi);
+ state->duty_cycle = meson_pwm_cnt_to_ns(chip, pwm, channel->hi);
state->polarity = PWM_POLARITY_NORMAL;
--
2.40.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] pwm: meson: modify and simplify calculation in meson_pwm_get_state
2023-05-02 20:33 [PATCH v3] pwm: meson: modify and simplify calculation in meson_pwm_get_state Heiner Kallweit
@ 2023-05-08 19:44 ` Martin Blumenstingl
2023-05-11 14:34 ` Dmitry Rokosov
1 sibling, 0 replies; 3+ messages in thread
From: Martin Blumenstingl @ 2023-05-08 19:44 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Jerome Brunet, Neil Armstrong, Kevin Hilman,
Uwe Kleine-König, thierry.reding, linux-arm-kernel,
open list:ARM/Amlogic Meson...,
linux-pwm, Dmitry Rokosov
On Tue, May 2, 2023 at 10:33 PM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>
> I don't see a reason why we should treat the case lo < hi differently
> and return 0 as period and duty_cycle. The current logic was added with
> c375bcbaabdb ("pwm: meson: Read the full hardware state in
> meson_pwm_get_state()"), Martin as original author doesn't remember why
> it was implemented this way back then.
> So let's handle it as normal use case and also remove the optimization
> for lo == 0. I think the improved readability is worth it.
>
> Fixes: c375bcbaabdb ("pwm: meson: Read the full hardware state in meson_pwm_get_state()")
> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: stable@vger.kernel.org
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] pwm: meson: modify and simplify calculation in meson_pwm_get_state
2023-05-02 20:33 [PATCH v3] pwm: meson: modify and simplify calculation in meson_pwm_get_state Heiner Kallweit
2023-05-08 19:44 ` Martin Blumenstingl
@ 2023-05-11 14:34 ` Dmitry Rokosov
1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Rokosov @ 2023-05-11 14:34 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Jerome Brunet, Martin Blumenstingl, Neil Armstrong, Kevin Hilman,
Uwe Kleine-König, thierry.reding, linux-arm-kernel,
open list:ARM/Amlogic Meson...,
linux-pwm
On Tue, May 02, 2023 at 10:33:42PM +0200, Heiner Kallweit wrote:
> I don't see a reason why we should treat the case lo < hi differently
> and return 0 as period and duty_cycle. The current logic was added with
> c375bcbaabdb ("pwm: meson: Read the full hardware state in
> meson_pwm_get_state()"), Martin as original author doesn't remember why
> it was implemented this way back then.
> So let's handle it as normal use case and also remove the optimization
> for lo == 0. I think the improved readability is worth it.
>
> Fixes: c375bcbaabdb ("pwm: meson: Read the full hardware state in meson_pwm_get_state()")
> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: stable@vger.kernel.org
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> v2:
> - improve commit description
> v3:
> - make patch a fix
> ---
> drivers/pwm/pwm-meson.c | 14 ++------------
> 1 file changed, 2 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
> index 5732300eb..3865538dd 100644
> --- a/drivers/pwm/pwm-meson.c
> +++ b/drivers/pwm/pwm-meson.c
> @@ -351,18 +351,8 @@ static int meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
> channel->lo = FIELD_GET(PWM_LOW_MASK, value);
> channel->hi = FIELD_GET(PWM_HIGH_MASK, value);
>
> - if (channel->lo == 0) {
> - state->period = meson_pwm_cnt_to_ns(chip, pwm, channel->hi);
> - state->duty_cycle = state->period;
> - } else if (channel->lo >= channel->hi) {
> - state->period = meson_pwm_cnt_to_ns(chip, pwm,
> - channel->lo + channel->hi);
> - state->duty_cycle = meson_pwm_cnt_to_ns(chip, pwm,
> - channel->hi);
> - } else {
> - state->period = 0;
> - state->duty_cycle = 0;
> - }
> + state->period = meson_pwm_cnt_to_ns(chip, pwm, channel->lo + channel->hi);
> + state->duty_cycle = meson_pwm_cnt_to_ns(chip, pwm, channel->hi);
>
> state->polarity = PWM_POLARITY_NORMAL;
>
> --
> 2.40.0
Reviewed-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
--
Thank you,
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-11 14:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-02 20:33 [PATCH v3] pwm: meson: modify and simplify calculation in meson_pwm_get_state Heiner Kallweit
2023-05-08 19:44 ` Martin Blumenstingl
2023-05-11 14:34 ` Dmitry Rokosov
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).