[PATCH v2 4/5] clk: renesas: rzv2h: Simplify polling condition in __rzv2h_cpg_assert()

Tommaso Merciai posted 5 patches 1 month ago
[PATCH v2 4/5] clk: renesas: rzv2h: Simplify polling condition in __rzv2h_cpg_assert()
Posted by Tommaso Merciai 1 month ago
Replace the ternary operator with a direct boolean comparison to improve
code readability and maintainability. The logic remains unchanged.

Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v1->v2:
 - New patch

 drivers/clk/renesas/rzv2h-cpg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/renesas/rzv2h-cpg.c b/drivers/clk/renesas/rzv2h-cpg.c
index 35c5ff38e231e..0e8800906b89e 100644
--- a/drivers/clk/renesas/rzv2h-cpg.c
+++ b/drivers/clk/renesas/rzv2h-cpg.c
@@ -867,7 +867,7 @@ static int __rzv2h_cpg_assert(struct reset_controller_dev *rcdev,
 	mask = BIT(monbit);
 
 	ret = readl_poll_timeout_atomic(priv->base + reg, value,
-					assert ? (value & mask) : !(value & mask),
+					assert == !!(value & mask),
 					10, 200);
 	if (ret && !assert) {
 		value = mask << 16;
-- 
2.43.0
Re: [PATCH v2 4/5] clk: renesas: rzv2h: Simplify polling condition in __rzv2h_cpg_assert()
Posted by Geert Uytterhoeven 4 weeks, 1 day ago
Hi Tommaso,

On Wed, 3 Sept 2025 at 10:28, Tommaso Merciai
<tommaso.merciai.xr@bp.renesas.com> wrote:
> Replace the ternary operator with a direct boolean comparison to improve
> code readability and maintainability. The logic remains unchanged.
>
> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>

Thanks for your patch!

> --- a/drivers/clk/renesas/rzv2h-cpg.c
> +++ b/drivers/clk/renesas/rzv2h-cpg.c
> @@ -867,7 +867,7 @@ static int __rzv2h_cpg_assert(struct reset_controller_dev *rcdev,
>         mask = BIT(monbit);
>
>         ret = readl_poll_timeout_atomic(priv->base + reg, value,
> -                                       assert ? (value & mask) : !(value & mask),
> +                                       assert == !!(value & mask),
>                                         10, 200);

These two lines now fit on a single line.

>         if (ret && !assert) {
>                 value = mask << 16;

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in renesas-clk for v6.18 with the above fixed.
No need to resend.

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
Re: [PATCH v2 4/5] clk: renesas: rzv2h: Simplify polling condition in __rzv2h_cpg_assert()
Posted by Tommaso Merciai 4 weeks, 1 day ago
Hi Geert,

On Wed, Sep 03, 2025 at 01:58:26PM +0200, Geert Uytterhoeven wrote:
> Hi Tommaso,
> 
> On Wed, 3 Sept 2025 at 10:28, Tommaso Merciai
> <tommaso.merciai.xr@bp.renesas.com> wrote:
> > Replace the ternary operator with a direct boolean comparison to improve
> > code readability and maintainability. The logic remains unchanged.
> >
> > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> 
> Thanks for your patch!
> 
> > --- a/drivers/clk/renesas/rzv2h-cpg.c
> > +++ b/drivers/clk/renesas/rzv2h-cpg.c
> > @@ -867,7 +867,7 @@ static int __rzv2h_cpg_assert(struct reset_controller_dev *rcdev,
> >         mask = BIT(monbit);
> >
> >         ret = readl_poll_timeout_atomic(priv->base + reg, value,
> > -                                       assert ? (value & mask) : !(value & mask),
> > +                                       assert == !!(value & mask),
> >                                         10, 200);
> 
> These two lines now fit on a single line.
> 
> >         if (ret && !assert) {
> >                 value = mask << 16;
> 
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> i.e. will queue in renesas-clk for v6.18 with the above fixed.
> No need to resend.

Thank you for taking care of this!
Same for PATCH 1/5.

Kind Regards,
Tommaso


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