]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
clk: check parent_name in clk_register to avoid confusing log_error() output
authorYang Xiwen <forbidden405@outlook.com>
Fri, 10 Nov 2023 19:19:52 +0000 (03:19 +0800)
committerSean Anderson <seanga2@gmail.com>
Fri, 15 Dec 2023 17:31:15 +0000 (12:31 -0500)
For some gate clocks and fixed clocks without a parent, calling
clk_register will print an useless error message indicating that parent
is missing. Fix that by gaurding log_xxx() with an if-statement.

Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
Suggested-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
Link: https://lore.kernel.org/r/20230807-clk-fix-v2-1-0b688e21fb4e@outlook.com
drivers/clk/clk.c

index a5a3461b66c551976c7667f202ee0f24d7199215..6ede1b4d4dcc4ac16e3d547d825d5bf8088239ff 100644 (file)
 int clk_register(struct clk *clk, const char *drv_name,
                 const char *name, const char *parent_name)
 {
-       struct udevice *parent;
+       struct udevice *parent = NULL;
        struct driver *drv;
        int ret;
 
-       ret = uclass_get_device_by_name(UCLASS_CLK, parent_name, &parent);
-       if (ret) {
-               log_err("%s: failed to get %s device (parent of %s)\n",
-                       __func__, parent_name, name);
-       } else {
-               log_debug("%s: name: %s parent: %s [0x%p]\n", __func__, name,
-                         parent->name, parent);
+       if (parent_name) {
+               ret = uclass_get_device_by_name(UCLASS_CLK, parent_name, &parent);
+               if (ret) {
+                       log_err("%s: failed to get %s device (parent of %s)\n",
+                               __func__, parent_name, name);
+               } else {
+                       log_debug("%s: name: %s parent: %s [0x%p]\n", __func__, name,
+                                 parent->name, parent);
+               }
        }
 
        drv = lists_driver_lookup_name(drv_name);