diff mbox series

[U-Boot,1/7] clk: add support for clk_is_match()

Message ID 20190515141505.16945-2-nsekhar@ti.com
State Superseded
Delegated to: Tom Rini
Headers show
Series Add PCIe root complex support for AM654x SoC | expand

Commit Message

Sekhar Nori May 15, 2019, 2:14 p.m. UTC
Add support for clk_is_match() which is required to
know if two clock pointers point to the same exact
physical clock.

Signed-off-by: Sekhar Nori <nsekhar@ti.com>
---
 drivers/clk/clk-uclass.c | 13 +++++++++++++
 include/clk.h            | 13 +++++++++++++
 2 files changed, 26 insertions(+)

Comments

Lokesh Vutla June 3, 2019, 5:54 a.m. UTC | #1
On 15/05/19 7:44 PM, Sekhar Nori wrote:
> Add support for clk_is_match() which is required to
> know if two clock pointers point to the same exact
> physical clock.
> 
> Signed-off-by: Sekhar Nori <nsekhar@ti.com>

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh
diff mbox series

Patch

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 79b3b0494c65..823be2bcb624 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -453,6 +453,19 @@  int clk_disable_bulk(struct clk_bulk *bulk)
 	return 0;
 }
 
+bool clk_is_match(const struct clk *p, const struct clk *q)
+{
+	/* trivial case: identical struct clk's or both NULL */
+	if (p == q)
+		return true;
+
+	/* same device, id and data */
+	if (p->dev == q->dev && p->id == q->id && p->data == q->data)
+		return true;
+
+	return false;
+}
+
 UCLASS_DRIVER(clk) = {
 	.id		= UCLASS_CLK,
 	.name		= "clk",
diff --git a/include/clk.h b/include/clk.h
index d24e99713a35..e657da038398 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -309,6 +309,18 @@  int clk_disable(struct clk *clk);
  */
 int clk_disable_bulk(struct clk_bulk *bulk);
 
+/**
+ * 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.
+ *
+ * Returns false otherwise. Note that two NULL clks are treated as matching.
+ */
+bool clk_is_match(const struct clk *p, const struct clk *q);
+
 int soc_clk_dump(void);
 
 /**
@@ -321,4 +333,5 @@  static inline bool clk_valid(struct clk *clk)
 {
 	return !!clk->dev;
 }
+
 #endif