[PATCH 1/8] clk: add helper function clk_is_match()
From: geert@linux-m68k.org (Geert Uytterhoeven)
Date: 2015-03-04 08:55:37
Also in:
alsa-devel, dri-devel, linux-pwm, linux-serial
On Wed, Feb 25, 2015 at 6:27 PM, Mike Turquette [off-list ref] wrote:
quoted hunk ↗ jump to hunk
From: Michael Turquette <redacted> Date: Wed, 25 Feb 2015 09:11:01 -0800 Subject: [PATCH] clk: introduce clk_is_match Some drivers compare struct clk pointers as a means of knowing if the two pointers reference the same clock hardware. This behavior is dubious (drivers must not dereference struct clk), but did not cause any regressions until the per-user struct clk patch was merged. Now the test for matching clk's will always fail with per-user struct clk's. clk_is_match is introduced to fix the regression and prevent drivers from comparing the pointers manually. Fixes: 035a61c314eb ("clk: Make clk API return per-user struct clk instances") Cc: Russell King <redacted> Cc: Stephen Boyd <redacted> Cc: Shawn Guo <redacted> Cc: Tomeu Vizoso <redacted> Signed-off-by: Michael Turquette <redacted> --- drivers/clk/clk.c | 26 ++++++++++++++++++++++++++ include/linux/clk.h | 18 ++++++++++++++++++ 2 files changed, 44 insertions(+)diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index eb01529..09670de 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c@@ -2171,6 +2171,32 @@ int clk_get_phase(struct clk *clk) } /** + * clk_is_match - check if two clk's point to the same hardware clock + * @p: clk compared against q + * @q: clk compared against p + * + * Returns true if the two struct clk pointers both point to the same hardware + * clock node. Put differently, returns true if struct clk *p and struct clk *q + * share the same struct clk_core object. + * + * Returns false otherwise. Note that two NULL clks are treated as matching. + */ +bool clk_is_match(struct clk *p, struct clk *q)
const struct clk *p, const struct clk *q
quoted hunk ↗ jump to hunk
--- a/include/linux/clk.h +++ b/include/linux/clk.h@@ -376,6 +376,19 @@ struct clk *clk_get_parent(struct clk *clk); */ struct clk *clk_get_sys(const char *dev_id, const char *con_id); +/** + * clk_is_match - check if two clk's point to the same hardware clock + * @p: clk compared against q + * @q: clk compared against p + * + * Returns true if the two struct clk pointers both point to the same hardware + * clock node. Put differently, returns true if struct clk *p and struct clk *q + * share the same struct clk_core object. + * + * Returns false otherwise. Note that two NULL clks are treated as matching. + */ +bool clk_is_match(struct clk *p, struct clk *q);
const struct clk *p, const struct clk *q
quoted hunk ↗ jump to hunk
+ #else /* !CONFIG_HAVE_CLK */ static inline struct clk *clk_get(struct device *dev, const char *id)@@ -429,6 +442,11 @@ static inline struct clk *clk_get_parent(struct clk *clk) return NULL; } +static inline bool clk_is_match(struct clk *p, struct clk *q)
const struct clk *p, const struct clk *q
+{
+ return p == q ? true : false;
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 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