* [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config
@ 2019-03-07 22:36 Nathan Chancellor
2019-03-08 0:23 ` Nick Desaulniers
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Nathan Chancellor @ 2019-03-07 22:36 UTC (permalink / raw)
To: Thierry Reding
Cc: linux-pwm, linux-kernel, clang-built-linux, Nick Desaulniers,
Nathan Chancellor
When building with -Wsometimes-uninitialized, Clang warns:
drivers/pwm/pwm-img.c:126:13: error: variable 'timebase' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
The final else if functions as an else; make that explicit so that Clang
understands that timebase cannot be used uninitialized.
Link: https://github.com/ClangBuiltLinux/linux/issues/400
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/pwm/pwm-img.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
index 815f5333bb8f..1cc5fbe1e1d3 100644
--- a/drivers/pwm/pwm-img.c
+++ b/drivers/pwm/pwm-img.c
@@ -123,7 +123,7 @@ static int img_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
} else if (mul <= max_timebase * 512) {
div = PWM_CTRL_CFG_SUB_DIV0_DIV1;
timebase = DIV_ROUND_UP(mul, 512);
- } else if (mul > max_timebase * 512) {
+ } else {
dev_err(chip->dev,
"failed to configure timebase steps/divider value\n");
return -EINVAL;
--
2.21.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config
2019-03-07 22:36 [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config Nathan Chancellor
@ 2019-03-08 0:23 ` Nick Desaulniers
2019-03-08 8:53 ` Uwe Kleine-König
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Nick Desaulniers @ 2019-03-08 0:23 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: Thierry Reding, linux-pwm, LKML, clang-built-linux
On Thu, Mar 7, 2019 at 2:36 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> When building with -Wsometimes-uninitialized, Clang warns:
>
> drivers/pwm/pwm-img.c:126:13: error: variable 'timebase' is used
> uninitialized whenever 'if' condition is false
> [-Werror,-Wsometimes-uninitialized]
>
> The final else if functions as an else; make that explicit so that Clang
> understands that timebase cannot be used uninitialized.
A welcome simplification! Thank you.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/400
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/pwm/pwm-img.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
> index 815f5333bb8f..1cc5fbe1e1d3 100644
> --- a/drivers/pwm/pwm-img.c
> +++ b/drivers/pwm/pwm-img.c
> @@ -123,7 +123,7 @@ static int img_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> } else if (mul <= max_timebase * 512) {
> div = PWM_CTRL_CFG_SUB_DIV0_DIV1;
> timebase = DIV_ROUND_UP(mul, 512);
> - } else if (mul > max_timebase * 512) {
> + } else {
> dev_err(chip->dev,
> "failed to configure timebase steps/divider value\n");
> return -EINVAL;
> --
> 2.21.0
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config
2019-03-07 22:36 [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config Nathan Chancellor
2019-03-08 0:23 ` Nick Desaulniers
@ 2019-03-08 8:53 ` Uwe Kleine-König
2019-03-08 18:38 ` Nick Desaulniers
2019-03-08 8:58 ` Uwe Kleine-König
2019-03-20 11:30 ` Thierry Reding
3 siblings, 1 reply; 10+ messages in thread
From: Uwe Kleine-König @ 2019-03-08 8:53 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Thierry Reding, linux-pwm, linux-kernel, clang-built-linux,
Nick Desaulniers
On Thu, Mar 07, 2019 at 03:36:28PM -0700, Nathan Chancellor wrote:
> When building with -Wsometimes-uninitialized, Clang warns:
>
> drivers/pwm/pwm-img.c:126:13: error: variable 'timebase' is used
> uninitialized whenever 'if' condition is false
> [-Werror,-Wsometimes-uninitialized]
>
> The final else if functions as an else; make that explicit so that Clang
> understands that timebase cannot be used uninitialized.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/400
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/pwm/pwm-img.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
> index 815f5333bb8f..1cc5fbe1e1d3 100644
> --- a/drivers/pwm/pwm-img.c
> +++ b/drivers/pwm/pwm-img.c
> @@ -123,7 +123,7 @@ static int img_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> } else if (mul <= max_timebase * 512) {
> div = PWM_CTRL_CFG_SUB_DIV0_DIV1;
> timebase = DIV_ROUND_UP(mul, 512);
> - } else if (mul > max_timebase * 512) {
> + } else {
> dev_err(chip->dev,
> "failed to configure timebase steps/divider value\n");
> return -EINVAL;
This can even be simplified further.
From the probe function we have:
pwm_chip->max_period_ns = NSEC_PER_SEC * 512 * max_timebase / input_clk_hz
Then in img_pwm_config there is:
mul = ⎡ input_clk_hz / ⎡ NSEC_PER_SEC / period_ns⎤⎤
(Not sure this term is the best we can come up with. The rounding
strategy looks strange because the first DIV_ROUND_UP makes mul smaller
while the second makes it bigger. This is similar to
⎡ input_clk_hz * period_ns / NSEC_PER_SEC ⎤
which is probably more exact and cheaper to calculate.)
If we now had
mul > max_timebase * 512
this results in (apart from rounding errors):
input_clk_hz * period_ns / NSEC_PER_SEC > max_timebase * 512
<=> period_ns > max_timebase * 512 * NSEC_PER_SEC / input_clk_hz
<=> period_ns > pwm_chip->max_period_ns
This however is already ruled out by the first check in
img_pwm_config().
So if the rounding would be fixed, the else is a dead branch and could
be dropped completely.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config
2019-03-07 22:36 [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config Nathan Chancellor
2019-03-08 0:23 ` Nick Desaulniers
2019-03-08 8:53 ` Uwe Kleine-König
@ 2019-03-08 8:58 ` Uwe Kleine-König
2019-03-08 18:18 ` Nick Desaulniers
2019-03-20 11:30 ` Thierry Reding
3 siblings, 1 reply; 10+ messages in thread
From: Uwe Kleine-König @ 2019-03-08 8:58 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Thierry Reding, linux-pwm, linux-kernel, Nick Desaulniers
Hello Nathan,
the copy of my mail sent to clang-built-linux@googlegroups.com was not
accepted. (So I dropped this address from the recipients for this
reply.) Probably this list isn't open for non-members to post to. This
is a bit annoying, so I ask you to either fix that or don't add this
address to the recipients of your posts where non-members might answer.
Thanks
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config
2019-03-08 8:58 ` Uwe Kleine-König
@ 2019-03-08 18:18 ` Nick Desaulniers
0 siblings, 0 replies; 10+ messages in thread
From: Nick Desaulniers @ 2019-03-08 18:18 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: Nathan Chancellor, Thierry Reding, linux-pwm, LKML
On Fri, Mar 8, 2019 at 12:58 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> Hello Nathan,
>
> the copy of my mail sent to clang-built-linux@googlegroups.com was not
> accepted. (So I dropped this address from the recipients for this
> reply.) Probably this list isn't open for non-members to post to. This
> is a bit annoying, so I ask you to either fix that or don't add this
> address to the recipients of your posts where non-members might answer.
Ah, sorry, I did not realize that it would annoy people like this when
I set it up. We've email vger post master to get us set up with a
list. No response yet.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config
2019-03-08 8:53 ` Uwe Kleine-König
@ 2019-03-08 18:38 ` Nick Desaulniers
2019-03-08 21:18 ` Uwe Kleine-König
0 siblings, 1 reply; 10+ messages in thread
From: Nick Desaulniers @ 2019-03-08 18:38 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: Nathan Chancellor, Thierry Reding, linux-pwm, LKML
On Fri, Mar 8, 2019 at 12:53 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> On Thu, Mar 07, 2019 at 03:36:28PM -0700, Nathan Chancellor wrote:
> > When building with -Wsometimes-uninitialized, Clang warns:
> >
> > drivers/pwm/pwm-img.c:126:13: error: variable 'timebase' is used
> > uninitialized whenever 'if' condition is false
> > [-Werror,-Wsometimes-uninitialized]
> >
> > The final else if functions as an else; make that explicit so that Clang
> > understands that timebase cannot be used uninitialized.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/400
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> > drivers/pwm/pwm-img.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
> > index 815f5333bb8f..1cc5fbe1e1d3 100644
> > --- a/drivers/pwm/pwm-img.c
> > +++ b/drivers/pwm/pwm-img.c
> > @@ -123,7 +123,7 @@ static int img_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> > } else if (mul <= max_timebase * 512) {
> > div = PWM_CTRL_CFG_SUB_DIV0_DIV1;
> > timebase = DIV_ROUND_UP(mul, 512);
> > - } else if (mul > max_timebase * 512) {
> > + } else {
> > dev_err(chip->dev,
> > "failed to configure timebase steps/divider value\n");
> > return -EINVAL;
>
> This can even be simplified further.
>
> From the probe function we have:
>
> pwm_chip->max_period_ns = NSEC_PER_SEC * 512 * max_timebase / input_clk_hz
I had trouble verifying `input_clk_hz` in the above. The divisor is
`clk_get_rate(pwm->pwm_clk)`, but is it guaranteed to always be
`input_clk_hz`? If so, where?
>
> Then in img_pwm_config there is:
>
> mul = ⎡ input_clk_hz / ⎡ NSEC_PER_SEC / period_ns⎤⎤
>
> (Not sure this term is the best we can come up with. The rounding
> strategy looks strange because the first DIV_ROUND_UP makes mul smaller
> while the second makes it bigger. This is similar to
>
> ⎡ input_clk_hz * period_ns / NSEC_PER_SEC ⎤
>
> which is probably more exact and cheaper to calculate.)
>
> If we now had
>
> mul > max_timebase * 512
>
> this results in (apart from rounding errors):
>
> input_clk_hz * period_ns / NSEC_PER_SEC > max_timebase * 512
> <=> period_ns > max_timebase * 512 * NSEC_PER_SEC / input_clk_hz
> <=> period_ns > pwm_chip->max_period_ns
>
> This however is already ruled out by the first check in
> img_pwm_config().
>
> So if the rounding would be fixed, the else is a dead branch and could
> be dropped completely.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config
2019-03-08 18:38 ` Nick Desaulniers
@ 2019-03-08 21:18 ` Uwe Kleine-König
2019-03-08 21:23 ` Nick Desaulniers
0 siblings, 1 reply; 10+ messages in thread
From: Uwe Kleine-König @ 2019-03-08 21:18 UTC (permalink / raw)
To: Nick Desaulniers; +Cc: Nathan Chancellor, Thierry Reding, linux-pwm, LKML
On Fri, Mar 08, 2019 at 10:38:11AM -0800, Nick Desaulniers wrote:
> On Fri, Mar 8, 2019 at 12:53 AM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> >
> > On Thu, Mar 07, 2019 at 03:36:28PM -0700, Nathan Chancellor wrote:
> > > When building with -Wsometimes-uninitialized, Clang warns:
> > >
> > > drivers/pwm/pwm-img.c:126:13: error: variable 'timebase' is used
> > > uninitialized whenever 'if' condition is false
> > > [-Werror,-Wsometimes-uninitialized]
> > >
> > > The final else if functions as an else; make that explicit so that Clang
> > > understands that timebase cannot be used uninitialized.
> > >
> > > Link: https://github.com/ClangBuiltLinux/linux/issues/400
> > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > ---
> > > drivers/pwm/pwm-img.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
> > > index 815f5333bb8f..1cc5fbe1e1d3 100644
> > > --- a/drivers/pwm/pwm-img.c
> > > +++ b/drivers/pwm/pwm-img.c
> > > @@ -123,7 +123,7 @@ static int img_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> > > } else if (mul <= max_timebase * 512) {
> > > div = PWM_CTRL_CFG_SUB_DIV0_DIV1;
> > > timebase = DIV_ROUND_UP(mul, 512);
> > > - } else if (mul > max_timebase * 512) {
> > > + } else {
> > > dev_err(chip->dev,
> > > "failed to configure timebase steps/divider value\n");
> > > return -EINVAL;
> >
> > This can even be simplified further.
> >
> > From the probe function we have:
> >
> > pwm_chip->max_period_ns = NSEC_PER_SEC * 512 * max_timebase / input_clk_hz
>
> I had trouble verifying `input_clk_hz` in the above. The divisor is
> `clk_get_rate(pwm->pwm_clk)`, but is it guaranteed to always be
> `input_clk_hz`? If so, where?
In the probe function it's called "clk_rate". We have:
clk_rate = clk_get_rate(pwm->pwm_clk);
...
val = (u64)NSEC_PER_SEC * 512 * pwm->data->max_timebase;
do_div(val, clk_rate);
pwm->max_period_ns = val;
and in img_pwm_config we have:
input_clk_hz = clk_get_rate(pwm_chip->pwm_clk);
I used the name used in img_pwm_config with the intention that my
reasoning is easier to understand, but obviously I failed.
This by the way highlights another patch opportunity: Unify the names
that the same thing gets the same name in the different functions. This
doesn't only affect "clk_rate" vs "input_clk_hz", but also "pwm_chip"
vs. "pwm".
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config
2019-03-08 21:18 ` Uwe Kleine-König
@ 2019-03-08 21:23 ` Nick Desaulniers
2019-03-08 21:49 ` Uwe Kleine-König
0 siblings, 1 reply; 10+ messages in thread
From: Nick Desaulniers @ 2019-03-08 21:23 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: Nathan Chancellor, Thierry Reding, linux-pwm, LKML
On Fri, Mar 8, 2019 at 1:18 PM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> On Fri, Mar 08, 2019 at 10:38:11AM -0800, Nick Desaulniers wrote:
> > On Fri, Mar 8, 2019 at 12:53 AM Uwe Kleine-König
> > <u.kleine-koenig@pengutronix.de> wrote:
> > >
> > > On Thu, Mar 07, 2019 at 03:36:28PM -0700, Nathan Chancellor wrote:
> > > > When building with -Wsometimes-uninitialized, Clang warns:
> > > >
> > > > drivers/pwm/pwm-img.c:126:13: error: variable 'timebase' is used
> > > > uninitialized whenever 'if' condition is false
> > > > [-Werror,-Wsometimes-uninitialized]
> > > >
> > > > The final else if functions as an else; make that explicit so that Clang
> > > > understands that timebase cannot be used uninitialized.
> > > >
> > > > Link: https://github.com/ClangBuiltLinux/linux/issues/400
> > > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > > ---
> > > > drivers/pwm/pwm-img.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
> > > > index 815f5333bb8f..1cc5fbe1e1d3 100644
> > > > --- a/drivers/pwm/pwm-img.c
> > > > +++ b/drivers/pwm/pwm-img.c
> > > > @@ -123,7 +123,7 @@ static int img_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> > > > } else if (mul <= max_timebase * 512) {
> > > > div = PWM_CTRL_CFG_SUB_DIV0_DIV1;
> > > > timebase = DIV_ROUND_UP(mul, 512);
> > > > - } else if (mul > max_timebase * 512) {
> > > > + } else {
> > > > dev_err(chip->dev,
> > > > "failed to configure timebase steps/divider value\n");
> > > > return -EINVAL;
> > >
> > > This can even be simplified further.
> > >
> > > From the probe function we have:
> > >
> > > pwm_chip->max_period_ns = NSEC_PER_SEC * 512 * max_timebase / input_clk_hz
> >
> > I had trouble verifying `input_clk_hz` in the above. The divisor is
> > `clk_get_rate(pwm->pwm_clk)`, but is it guaranteed to always be
> > `input_clk_hz`? If so, where?
>
> In the probe function it's called "clk_rate". We have:
>
> clk_rate = clk_get_rate(pwm->pwm_clk);
> ...
> val = (u64)NSEC_PER_SEC * 512 * pwm->data->max_timebase;
> do_div(val, clk_rate);
> pwm->max_period_ns = val;
>
> and in img_pwm_config we have:
>
> input_clk_hz = clk_get_rate(pwm_chip->pwm_clk);
>
> I used the name used in img_pwm_config with the intention that my
> reasoning is easier to understand, but obviously I failed.
>
> This by the way highlights another patch opportunity: Unify the names
> that the same thing gets the same name in the different functions. This
> doesn't only affect "clk_rate" vs "input_clk_hz", but also "pwm_chip"
> vs. "pwm".
Sure, those seem like nice little cleanups that will help with
maintainability. Would you mind sending a patch for those, and I'll
review? Otherwise Nathan's patch exists and is ready to go.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config
2019-03-08 21:23 ` Nick Desaulniers
@ 2019-03-08 21:49 ` Uwe Kleine-König
0 siblings, 0 replies; 10+ messages in thread
From: Uwe Kleine-König @ 2019-03-08 21:49 UTC (permalink / raw)
To: Nick Desaulniers; +Cc: Nathan Chancellor, Thierry Reding, linux-pwm, LKML
On Fri, Mar 08, 2019 at 01:23:41PM -0800, Nick Desaulniers wrote:
> On Fri, Mar 8, 2019 at 1:18 PM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> >
> > On Fri, Mar 08, 2019 at 10:38:11AM -0800, Nick Desaulniers wrote:
> > > On Fri, Mar 8, 2019 at 12:53 AM Uwe Kleine-König
> > > <u.kleine-koenig@pengutronix.de> wrote:
> > > >
> > > > On Thu, Mar 07, 2019 at 03:36:28PM -0700, Nathan Chancellor wrote:
> > > > > When building with -Wsometimes-uninitialized, Clang warns:
> > > > >
> > > > > drivers/pwm/pwm-img.c:126:13: error: variable 'timebase' is used
> > > > > uninitialized whenever 'if' condition is false
> > > > > [-Werror,-Wsometimes-uninitialized]
> > > > >
> > > > > The final else if functions as an else; make that explicit so that Clang
> > > > > understands that timebase cannot be used uninitialized.
> > > > >
> > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/400
> > > > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > > > ---
> > > > > drivers/pwm/pwm-img.c | 2 +-
> > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
> > > > > index 815f5333bb8f..1cc5fbe1e1d3 100644
> > > > > --- a/drivers/pwm/pwm-img.c
> > > > > +++ b/drivers/pwm/pwm-img.c
> > > > > @@ -123,7 +123,7 @@ static int img_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> > > > > } else if (mul <= max_timebase * 512) {
> > > > > div = PWM_CTRL_CFG_SUB_DIV0_DIV1;
> > > > > timebase = DIV_ROUND_UP(mul, 512);
> > > > > - } else if (mul > max_timebase * 512) {
> > > > > + } else {
> > > > > dev_err(chip->dev,
> > > > > "failed to configure timebase steps/divider value\n");
> > > > > return -EINVAL;
> > > >
> > > > This can even be simplified further.
> > > >
> > > > From the probe function we have:
> > > >
> > > > pwm_chip->max_period_ns = NSEC_PER_SEC * 512 * max_timebase / input_clk_hz
> > >
> > > I had trouble verifying `input_clk_hz` in the above. The divisor is
> > > `clk_get_rate(pwm->pwm_clk)`, but is it guaranteed to always be
> > > `input_clk_hz`? If so, where?
> >
> > In the probe function it's called "clk_rate". We have:
> >
> > clk_rate = clk_get_rate(pwm->pwm_clk);
> > ...
> > val = (u64)NSEC_PER_SEC * 512 * pwm->data->max_timebase;
> > do_div(val, clk_rate);
> > pwm->max_period_ns = val;
> >
> > and in img_pwm_config we have:
> >
> > input_clk_hz = clk_get_rate(pwm_chip->pwm_clk);
> >
> > I used the name used in img_pwm_config with the intention that my
> > reasoning is easier to understand, but obviously I failed.
> >
> > This by the way highlights another patch opportunity: Unify the names
> > that the same thing gets the same name in the different functions. This
> > doesn't only affect "clk_rate" vs "input_clk_hz", but also "pwm_chip"
> > vs. "pwm".
>
> Sure, those seem like nice little cleanups that will help with
> maintainability. Would you mind sending a patch for those, and I'll
> review? Otherwise Nathan's patch exists and is ready to go.
I don't mind. But I would prefer to get some input from Thierry about
how to round first. I also wonder if there is a publically available
manual for this piece of hardware.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config
2019-03-07 22:36 [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config Nathan Chancellor
` (2 preceding siblings ...)
2019-03-08 8:58 ` Uwe Kleine-König
@ 2019-03-20 11:30 ` Thierry Reding
3 siblings, 0 replies; 10+ messages in thread
From: Thierry Reding @ 2019-03-20 11:30 UTC (permalink / raw)
To: Nathan Chancellor
Cc: linux-pwm, linux-kernel, clang-built-linux, Nick Desaulniers
[-- Attachment #1: Type: text/plain, Size: 679 bytes --]
On Thu, Mar 07, 2019 at 03:36:28PM -0700, Nathan Chancellor wrote:
> When building with -Wsometimes-uninitialized, Clang warns:
>
> drivers/pwm/pwm-img.c:126:13: error: variable 'timebase' is used
> uninitialized whenever 'if' condition is false
> [-Werror,-Wsometimes-uninitialized]
>
> The final else if functions as an else; make that explicit so that Clang
> understands that timebase cannot be used uninitialized.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/400
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/pwm/pwm-img.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks!
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-03-20 11:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 22:36 [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config Nathan Chancellor
2019-03-08 0:23 ` Nick Desaulniers
2019-03-08 8:53 ` Uwe Kleine-König
2019-03-08 18:38 ` Nick Desaulniers
2019-03-08 21:18 ` Uwe Kleine-König
2019-03-08 21:23 ` Nick Desaulniers
2019-03-08 21:49 ` Uwe Kleine-König
2019-03-08 8:58 ` Uwe Kleine-König
2019-03-08 18:18 ` Nick Desaulniers
2019-03-20 11:30 ` Thierry Reding
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.