[PATCH RESEND 2/5] clk: call log_debug() instead to avoid console log printing

Sean Anderson seanga2 at gmail.com
Wed Nov 1 18:55:59 CET 2023


On 8/17/23 13:04, Yang Xiwen via B4 Relay wrote:
> From: Yang Xiwen <forbidden405 at outlook.com>
> 
> it's a very common case to register a clock without a parent, such as
> clk_register_fixed_rate().

Actually, that seems like the only place this is done.

> Replace log_error() with log_debug() to avoid
> useless console log if not debugging.
> 
> Signed-off-by: Yang Xiwen <forbidden405 at outlook.com>
> ---
>   drivers/clk/clk.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index a5a3461b66..a38daaac0c 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -24,8 +24,8 @@ int clk_register(struct clk *clk, const char *drv_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);
> +		log_debug("%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);
> 

I think a correct fix would be

diff --git i/drivers/clk/clk.c w/drivers/clk/clk.c
index a5a3461b66c..cb333c83f66 100644
--- i/drivers/clk/clk.c
+++ w/drivers/clk/clk.c
@@ -18,17 +18,19 @@
  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);

--Sean


More information about the U-Boot mailing list