From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Wan Jiabing <wanjiabing@vivo.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
linux-pwm@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pwm: sifive: simplify if-if to if-else
Date: Fri, 8 Apr 2022 12:07:21 +0200 [thread overview]
Message-ID: <20220408100721.rinvvgard3nr5wff@pengutronix.de> (raw)
In-Reply-To: <20220408083007.41538-1-wanjiabing@vivo.com>
[-- Attachment #1.1: Type: text/plain, Size: 1430 bytes --]
On Fri, Apr 08, 2022 at 04:30:07PM +0800, Wan Jiabing wrote:
> use if and else instead of if(A) and if (!A).
>
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> ---
> drivers/pwm/pwm-sifive.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c
> index 253c4a17d255..e6d05a329002 100644
> --- a/drivers/pwm/pwm-sifive.c
> +++ b/drivers/pwm/pwm-sifive.c
> @@ -138,10 +138,9 @@ static int pwm_sifive_enable(struct pwm_chip *chip, bool enable)
> dev_err(ddata->chip.dev, "Enable clk failed\n");
> return ret;
> }
> - }
> -
> - if (!enable)
> + } else {
> clk_disable(ddata->clk);
> + }
>
> return 0;
> }
The patch looks fine. I wonder if it would be sensible to clean up even
more: pwm_sifive_apply() is only a single caller of
pwm_sifive_enable(). If this is optimized to skip the duty_cycle and
period calculation for the state->enabled = false case and just disables
the clock this should still work.
Also I wonder if there is a clk mismatch issue in this driver: .probe
enables the clk and if the PWM is off (i.e. .get_state diagnoses that)
the clock will never be disabled while the driver is bound, will it?
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 161 bytes --]
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2022-04-08 10:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-08 8:30 [PATCH] pwm: sifive: simplify if-if to if-else Wan Jiabing
2022-04-08 10:07 ` Uwe Kleine-König [this message]
2022-05-20 13:59 ` Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220408100721.rinvvgard3nr5wff@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=thierry.reding@gmail.com \
--cc=wanjiabing@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox