public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
	patches@lists.linux.dev,
	"Andrey Skvortsov" <andrej.skvortzov@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: [PATCH] clk: Cleanup devm_clk_match() wreckage
Date: Tue, 22 Aug 2023 15:52:42 -0700	[thread overview]
Message-ID: <20230822225245.3624370-1-sboyd@kernel.org> (raw)

The 'res' pointer passed to devm_clk_match() is a pointer to struct
devm_clk_state after commit abae8e57e49a ("clk: generalize
devm_clk_get() a bit"). Update the logic here to convert the void
pointer to the right type so that this is cleaner. Note that this
doesn't actually change anything due to how struct devm_clk_state is
defined to have a struct clk pointer as the first member.

Given we're cleaning things up, split the WARN_ON() into two different
conditions to provide clarity about which condition is false. Also move
the WARN_ON to the conditional so that the compiler is hinted that all
this code is unlikely().

Cc: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
---
 drivers/clk/clk-devres.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
index 737aa70e2cb3..979562ee79ba 100644
--- a/drivers/clk/clk-devres.c
+++ b/drivers/clk/clk-devres.c
@@ -184,12 +184,14 @@ EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all);
 
 static int devm_clk_match(struct device *dev, void *res, void *data)
 {
-	struct clk **c = res;
-	if (!c || !*c) {
-		WARN_ON(!c || !*c);
+	struct devm_clk_state *state = res;
+
+	if (WARN_ON(!state))
 		return 0;
-	}
-	return *c == data;
+	if (WARN_ON(!state->clk))
+		return 0;
+
+	return state->clk == data;
 }
 
 void devm_clk_put(struct device *dev, struct clk *clk)

base-commit: 66fbfb35da47f391bdadf9fa7ceb88af4faa9022
-- 
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git


                 reply	other threads:[~2023-08-22 22:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230822225245.3624370-1-sboyd@kernel.org \
    --to=sboyd@kernel.org \
    --cc=andrej.skvortzov@gmail.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=patches@lists.linux.dev \
    --cc=u.kleine-koenig@pengutronix.de \
    /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