* [PATCH] clk: renesas: r8a7778: remove checker warnings: x | !y
@ 2023-06-13 2:54 GONG, Ruiqi
2023-06-13 7:39 ` Geert Uytterhoeven
2023-06-14 10:17 ` David Laight
0 siblings, 2 replies; 3+ messages in thread
From: GONG, Ruiqi @ 2023-06-13 2:54 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Michael Turquette, Stephen Boyd, linux-renesas-soc, linux-clk,
linux-kernel, gongruiqi1
Eliminate the following Sparse reports when building with C=1:
drivers/clk/renesas/clk-r8a7778.c:85:52: warning: dubious: x | !y
drivers/clk/renesas/clk-r8a7778.c:87:50: warning: dubious: x | !y
Signed-off-by: GONG, Ruiqi <gongruiqi@huaweicloud.com>
---
drivers/clk/renesas/clk-r8a7778.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/clk/renesas/clk-r8a7778.c b/drivers/clk/renesas/clk-r8a7778.c
index 797556259370..ad1a50f3b0cd 100644
--- a/drivers/clk/renesas/clk-r8a7778.c
+++ b/drivers/clk/renesas/clk-r8a7778.c
@@ -81,11 +81,11 @@ static void __init r8a7778_cpg_clocks_init(struct device_node *np)
BUG_ON(!(mode & BIT(19)));
- cpg_mode_rates = (!!(mode & BIT(18)) << 2) |
- (!!(mode & BIT(12)) << 1) |
- (!!(mode & BIT(11)));
- cpg_mode_divs = (!!(mode & BIT(2)) << 1) |
- (!!(mode & BIT(1)));
+ cpg_mode_rates = (mode & BIT(18) ? BIT(2) : 0) |
+ (mode & BIT(12) ? BIT(1) : 0) |
+ (mode & BIT(11) ? BIT(0) : 0);
+ cpg_mode_divs = (mode & BIT(2) ? BIT(1) : 0) |
+ (mode & BIT(1) ? BIT(0) : 0);
num_clks = of_property_count_strings(np, "clock-output-names");
if (num_clks < 0) {
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: renesas: r8a7778: remove checker warnings: x | !y
2023-06-13 2:54 [PATCH] clk: renesas: r8a7778: remove checker warnings: x | !y GONG, Ruiqi
@ 2023-06-13 7:39 ` Geert Uytterhoeven
2023-06-14 10:17 ` David Laight
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2023-06-13 7:39 UTC (permalink / raw)
To: GONG, Ruiqi
Cc: Michael Turquette, Stephen Boyd, linux-renesas-soc, linux-clk,
linux-kernel, gongruiqi1, linux-sparse
Hi Gong,
On Tue, Jun 13, 2023 at 4:50 AM GONG, Ruiqi <gongruiqi@huaweicloud.com> wrote:
> Eliminate the following Sparse reports when building with C=1:
>
> drivers/clk/renesas/clk-r8a7778.c:85:52: warning: dubious: x | !y
> drivers/clk/renesas/clk-r8a7778.c:87:50: warning: dubious: x | !y
>
> Signed-off-by: GONG, Ruiqi <gongruiqi@huaweicloud.com>
Thanks for your patch!
Looks like sparse needs to be taught the "|" is not used in a boolean
context here?
See also
https://lore.kernel.org/r/CAMuHMdXGG2xu+nXJt6CSTfV6aM=U=hMW+DiDgP3RhOw8+O8y=A@mail.gmail.com
> --- a/drivers/clk/renesas/clk-r8a7778.c
> +++ b/drivers/clk/renesas/clk-r8a7778.c
> @@ -81,11 +81,11 @@ static void __init r8a7778_cpg_clocks_init(struct device_node *np)
>
> BUG_ON(!(mode & BIT(19)));
>
> - cpg_mode_rates = (!!(mode & BIT(18)) << 2) |
> - (!!(mode & BIT(12)) << 1) |
> - (!!(mode & BIT(11)));
> - cpg_mode_divs = (!!(mode & BIT(2)) << 1) |
> - (!!(mode & BIT(1)));
> + cpg_mode_rates = (mode & BIT(18) ? BIT(2) : 0) |
> + (mode & BIT(12) ? BIT(1) : 0) |
> + (mode & BIT(11) ? BIT(0) : 0);
> + cpg_mode_divs = (mode & BIT(2) ? BIT(1) : 0) |
> + (mode & BIT(1) ? BIT(0) : 0);
>
> num_clks = of_property_count_strings(np, "clock-output-names");
> if (num_clks < 0) {
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] clk: renesas: r8a7778: remove checker warnings: x | !y
2023-06-13 2:54 [PATCH] clk: renesas: r8a7778: remove checker warnings: x | !y GONG, Ruiqi
2023-06-13 7:39 ` Geert Uytterhoeven
@ 2023-06-14 10:17 ` David Laight
1 sibling, 0 replies; 3+ messages in thread
From: David Laight @ 2023-06-14 10:17 UTC (permalink / raw)
To: 'GONG, Ruiqi', Geert Uytterhoeven
Cc: Michael Turquette, Stephen Boyd, linux-renesas-soc, linux-clk,
linux-kernel, gongruiqi1
From: GONG, Ruiqi
> Sent: 13 June 2023 03:54
>
> Eliminate the following Sparse reports when building with C=1:
>
> drivers/clk/renesas/clk-r8a7778.c:85:52: warning: dubious: x | !y
> drivers/clk/renesas/clk-r8a7778.c:87:50: warning: dubious: x | !y
>
> Signed-off-by: GONG, Ruiqi <gongruiqi@huaweicloud.com>
> ---
> drivers/clk/renesas/clk-r8a7778.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/clk/renesas/clk-r8a7778.c b/drivers/clk/renesas/clk-r8a7778.c
> index 797556259370..ad1a50f3b0cd 100644
> --- a/drivers/clk/renesas/clk-r8a7778.c
> +++ b/drivers/clk/renesas/clk-r8a7778.c
> @@ -81,11 +81,11 @@ static void __init r8a7778_cpg_clocks_init(struct device_node *np)
>
> BUG_ON(!(mode & BIT(19)));
>
> - cpg_mode_rates = (!!(mode & BIT(18)) << 2) |
> - (!!(mode & BIT(12)) << 1) |
> - (!!(mode & BIT(11)));
Try just adding a << 0 on the last line.
Recent gcc and clang optimise the code to 'shift + and'.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-14 10:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 2:54 [PATCH] clk: renesas: r8a7778: remove checker warnings: x | !y GONG, Ruiqi
2023-06-13 7:39 ` Geert Uytterhoeven
2023-06-14 10:17 ` David Laight
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).