]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
clk: Dont return error when assigned-clocks is empty or missing
authorAshok Reddy Soma <ashok.reddy.soma@amd.com>
Wed, 30 Aug 2023 08:31:42 +0000 (10:31 +0200)
committerMichal Simek <michal.simek@amd.com>
Thu, 21 Sep 2023 11:20:11 +0000 (13:20 +0200)
There is a chance that assigned-clock-rates is given and assigned-clocks
could be empty. Dont return error in that case, because the probe of the
corresponding driver will not be called at all if this fails.
Better to continue to look for it and return 0.

Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/a9a9d853e0ac396cd9b3577cce26279a75765711.1693384296.git.michal.simek@amd.com
arch/sandbox/dts/test.dts
drivers/clk/clk-uclass.c
test/dm/clk.c

index d4693e3c7a937b0593ea24956f3474daeb7bcc7e..e6a471e40d99723b433296c8a1f7f7001f499d02 100644 (file)
                clock-names = "fixed", "i2c", "spi", "uart2", "uart1";
        };
 
+       clk-test2 {
+               compatible = "sandbox,clk-test";
+               assigned-clock-rates = <321>;
+       };
+
+       clk-test3 {
+               compatible = "sandbox,clk-test";
+               assigned-clocks = <&clk_sandbox 1>;
+       };
+
+       clk-test4 {
+               compatible = "sandbox,clk-test";
+               assigned-clock-rates = <654>, <321>;
+               assigned-clocks = <&clk_sandbox 1>;
+       };
+
        ccf: clk-ccf {
                compatible = "sandbox,clk-ccf";
        };
index dc3e9d6a26151bc198f4349a7fcd51ebcd9daf08..f186fcbcdb868a5c9d6c17d64924649a1efad01a 100644 (file)
@@ -329,7 +329,13 @@ static int clk_set_default_rates(struct udevice *dev,
                        dev_dbg(dev,
                                "could not get assigned clock %d (err = %d)\n",
                                index, ret);
-                       continue;
+                       /* Skip if it is empty */
+                       if (ret == -ENOENT) {
+                               ret = 0;
+                               continue;
+                       }
+
+                       return ret;
                }
 
                /* This is clk provider device trying to program itself
index f48de05436bf2abcb6546b5dfce9a33276fc3784..01417fbd8257d5149aa637959c2a30b350633f2c 100644 (file)
@@ -36,6 +36,15 @@ static int dm_test_clk_base(struct unit_test_state *uts)
        ut_asserteq(clk_is_match(&clk_method1, &clk_method2), true);
        ut_asserteq(clk_method1.id, clk_method2.id);
 
+       ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test2", &dev));
+       ut_assertok(clk_set_defaults(dev, CLK_DEFAULTS_PRE));
+
+       ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test3", &dev));
+       ut_assertok(clk_set_defaults(dev, CLK_DEFAULTS_PRE));
+
+       ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test4", &dev));
+       ut_assertok(clk_set_defaults(dev, CLK_DEFAULTS_PRE));
+
        return 0;
 }