clk: Allow clk_get_by_name() with NULL name
This allows devm_clock_get(dev, NULL) to work and get the first clock,
which is common in code ported from Linux.
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Link: https://lore.kernel.org/r/20230122000252.53642-1-samuel@sholland.org
diff --git a/test/dm/clk.c b/test/dm/clk.c
index 21997ed..f48de05 100644
--- a/test/dm/clk.c
+++ b/test/dm/clk.c
@@ -26,6 +26,11 @@
ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test", &dev));
/* Get the same clk port in 2 different ways and compare */
+ ut_assertok(clk_get_by_index(dev, 0, &clk_method1));
+ ut_assertok(clk_get_by_name(dev, NULL, &clk_method2));
+ ut_asserteq(clk_is_match(&clk_method1, &clk_method2), true);
+ ut_asserteq(clk_method1.id, clk_method2.id);
+
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);