clk: add support for clk_is_match()

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>
This commit is contained in:
Sekhar Nori
2019-08-01 19:12:55 +05:30
committed by Tom Rini
parent 71cd80af86
commit acbb7cd4d3
3 changed files with 26 additions and 0 deletions

View File

@@ -518,6 +518,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",