public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: Simplify clk_is_match()
@ 2026-03-05 10:12 Geert Uytterhoeven
  2026-03-09 15:13 ` Brian Masney
  2026-03-24  0:19 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2026-03-05 10:12 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-clk, linux-kernel, Geert Uytterhoeven

Linux style is to handle early-on failure.  Inverting the first
condition lets us simplify the second, and improves readability.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/clk/clk.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 47093cda9df32223..1a73e9c4e752a85c 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3259,11 +3259,10 @@ bool clk_is_match(const struct clk *p, const struct clk *q)
 		return true;
 
 	/* true if clk->core pointers match. Avoid dereferencing garbage */
-	if (!IS_ERR_OR_NULL(p) && !IS_ERR_OR_NULL(q))
-		if (p->core == q->core)
-			return true;
+	if (IS_ERR_OR_NULL(p) || IS_ERR_OR_NULL(q))
+		return false;
 
-	return false;
+	return p->core == q->core;
 }
 EXPORT_SYMBOL_GPL(clk_is_match);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: Simplify clk_is_match()
  2026-03-05 10:12 [PATCH] clk: Simplify clk_is_match() Geert Uytterhoeven
@ 2026-03-09 15:13 ` Brian Masney
  2026-03-24  0:19 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Brian Masney @ 2026-03-09 15:13 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Michael Turquette, Stephen Boyd, linux-clk, linux-kernel

On Thu, Mar 05, 2026 at 11:12:33AM +0100, Geert Uytterhoeven wrote:
> Linux style is to handle early-on failure.  Inverting the first
> condition lets us simplify the second, and improves readability.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Brian Masney <bmasney@redhat.com>

Stephen: There are 8 places in clk_test.c where clk_is_match() is
called, so I feel we should be good testing coverage wise.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: Simplify clk_is_match()
  2026-03-05 10:12 [PATCH] clk: Simplify clk_is_match() Geert Uytterhoeven
  2026-03-09 15:13 ` Brian Masney
@ 2026-03-24  0:19 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2026-03-24  0:19 UTC (permalink / raw)
  To: Geert Uytterhoeven, Michael Turquette
  Cc: linux-clk, linux-kernel, Geert Uytterhoeven

Quoting Geert Uytterhoeven (2026-03-05 02:12:33)
> Linux style is to handle early-on failure.  Inverting the first
> condition lets us simplify the second, and improves readability.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-24  0:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 10:12 [PATCH] clk: Simplify clk_is_match() Geert Uytterhoeven
2026-03-09 15:13 ` Brian Masney
2026-03-24  0:19 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox