All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sekhar Nori <nsekhar@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/7] clk: add support for clk_is_match()
Date: Thu, 1 Aug 2019 19:12:55 +0530	[thread overview]
Message-ID: <20190801134301.2870-2-nsekhar@ti.com> (raw)
In-Reply-To: <20190801134301.2870-1-nsekhar@ti.com>

Add support for clk_is_match() which is required to
know if two clock pointers point to the same exact
physical clock.

Also add a unit test for the new API.

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
---
 drivers/clk/clk-uclass.c | 13 +++++++++++++
 include/clk.h            | 12 ++++++++++++
 test/dm/clk.c            |  1 +
 3 files changed, 26 insertions(+)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 85dfe712f5ac..1409c03ea174 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -515,6 +515,19 @@ int clk_get_by_id(ulong id, struct clk **clkp)
 	return -ENOENT;
 }
 
+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 f8f56d9cf01d..f50e5caa2206 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -333,6 +333,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);
 
 /**
diff --git a/test/dm/clk.c b/test/dm/clk.c
index f301ecbb459d..676ef217f093 100644
--- a/test/dm/clk.c
+++ b/test/dm/clk.c
@@ -24,6 +24,7 @@ static int dm_test_clk_base(struct unit_test_state *uts)
 	/* Get the same clk port in 2 different ways and compare */
 	ut_assertok(clk_get_by_index(dev, 1, &clk_method1));
 	ut_assertok(clk_get_by_index_nodev(dev_ofnode(dev), 1, &clk_method2));
+	ut_asserteq(clk_is_match(&clk_method1, &clk_method2), true);
 	ut_asserteq(clk_method1.id, clk_method2.id);
 
 	return 0;
-- 
2.16.2

  reply	other threads:[~2019-08-01 13:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-01 13:42 [U-Boot] [PATCH v3 0/7] Add PCIe root complex support for AM654x SoC Sekhar Nori
2019-08-01 13:42 ` Sekhar Nori [this message]
2019-08-01 13:47   ` [U-Boot] [PATCH v3 1/7] clk: add support for clk_is_match() Fabio Estevam
2019-08-01 13:54     ` Sekhar Nori
2019-08-01 13:55       ` Fabio Estevam
2019-08-01 15:50       ` Tom Rini
2019-08-13 16:51   ` Tom Rini
2019-08-01 13:42 ` [U-Boot] [PATCH v3 2/7] dm: core: add support for getting register address and size Sekhar Nori
2019-08-01 16:21   ` Daniel Schwierzeck
2019-08-02  6:09     ` Sekhar Nori
2019-08-13 16:51   ` Tom Rini
2019-08-01 13:42 ` [U-Boot] [PATCH v3 3/7] pcie: ti: add driver for AM65x PCIe RC Sekhar Nori
2019-08-13 16:51   ` Tom Rini
2019-08-01 13:42 ` [U-Boot] [PATCH v3 4/7] phy: add support for AM654x SERDES Sekhar Nori
2019-08-13 16:51   ` Tom Rini
2019-08-01 13:42 ` [U-Boot] [PATCH v3 5/7] configs: am65x_evm_a53: enable PCIe support Sekhar Nori
2019-08-13 16:51   ` Tom Rini
2019-08-01 13:43 ` [U-Boot] [PATCH v3 6/7] arm: dts: k3-am65: add support for PCIe and SERDES Sekhar Nori
2019-08-13 16:51   ` Tom Rini
2019-08-01 13:43 ` [U-Boot] [PATCH v3 7/7] configs: am65x_evm_a53: enable support for PCIe ethernet cards Sekhar Nori
2019-08-13 16:51   ` Tom Rini

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=20190801134301.2870-2-nsekhar@ti.com \
    --to=nsekhar@ti.com \
    --cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.