Re: [PATCH 17/33] clk: stm32mp1: migrate trace to dev and log macro

2020-10-21 Thread Patrice CHOTARD
Hi Patrick

On 10/14/20 11:16 AM, Patrick Delaunay wrote:
> Change debug and pr_ macro to dev macro and define LOG_CATEGORY.
>
> Remove the "%s:" __func__  header as it is managed by dev macro
> (dev->name is displayed) or log macro (CONFIG_LOGF_FUNC).
>
> Signed-off-by: Patrick Delaunay 
> ---
>
>  drivers/clk/clk_stm32mp1.c | 147 ++---
>  1 file changed, 71 insertions(+), 76 deletions(-)
>
> diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c
> index c8840b9e5f..aca4db9946 100644
> --- a/drivers/clk/clk_stm32mp1.c
> +++ b/drivers/clk/clk_stm32mp1.c
> @@ -3,6 +3,8 @@
>   * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
>   */
>  
> +#define LOG_CATEGORY UCLASS_CLK
> +
>  #include 
>  #include 
>  #include 
> @@ -14,12 +16,13 @@
>  #include 
>  #include 
>  #include 
> -#include 
> -#include 
> -#include 
>  #include 
> +#include 
>  #include 
>  #include 
> +#include 
> +#include 
> +#include 
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -781,7 +784,7 @@ static const struct stm32mp1_clk_data stm32mp1_data = {
>  static ulong stm32mp1_clk_get_fixed(struct stm32mp1_clk_priv *priv, int idx)
>  {
>   if (idx >= NB_OSC) {
> - debug("%s: clk id %d not found\n", __func__, idx);
> + log_debug("clk id %d not found\n", idx);
>   return 0;
>   }
>  
> @@ -799,7 +802,7 @@ static int stm32mp1_clk_get_id(struct stm32mp1_clk_priv 
> *priv, unsigned long id)
>   }
>  
>   if (i == nb_clks) {
> - printf("%s: clk id %d not found\n", __func__, (u32)id);
> + log_err("clk id %d not found\n", (u32)id);
>   return -EINVAL;
>   }
>  
> @@ -812,8 +815,7 @@ static int stm32mp1_clk_get_sel(struct stm32mp1_clk_priv 
> *priv,
>   const struct stm32mp1_clk_gate *gate = priv->data->gate;
>  
>   if (gate[i].sel > _PARENT_SEL_NB) {
> - printf("%s: parents for clk id %d not found\n",
> -__func__, i);
> + log_err("parents for clk id %d not found\n", i);
>   return -EINVAL;
>   }
>  
> @@ -858,17 +860,14 @@ static int stm32mp1_clk_get_parent(struct 
> stm32mp1_clk_priv *priv,
>   p = (readl(priv->base + sel[s].offset) >> sel[s].src) & sel[s].msk;
>  
>   if (p < sel[s].nb_parent) {
> -#ifdef DEBUG
> - debug("%s: %s clock is the parent %s of clk id %d\n", __func__,
> -   stm32mp1_clk_parent_name[sel[s].parent[p]],
> -   stm32mp1_clk_parent_sel_name[s],
> -   (u32)id);
> -#endif
> + log_content("%s clock is the parent %s of clk id %d\n",
> + stm32mp1_clk_parent_name[sel[s].parent[p]],
> + stm32mp1_clk_parent_sel_name[s],
> + (u32)id);
>   return sel[s].parent[p];
>   }
>  
> - pr_err("%s: no parents defined for clk id %d\n",
> -__func__, (u32)id);
> + log_err("no parents defined for clk id %d\n", (u32)id);
>  
>   return -EINVAL;
>  }
> @@ -1124,7 +1123,7 @@ static ulong stm32mp1_clk_get(struct stm32mp1_clk_priv 
> *priv, int p)
>   if (!uclass_get_device_by_name(UCLASS_CLK, "ck_dsi_phy",
>  )) {
>   if (clk_request(dev, )) {
> - pr_err("ck_dsi_phy request");
> + log_err("ck_dsi_phy request");
>   } else {
>   clk.id = 0;
>   clock = clk_get_rate();
> @@ -1136,8 +1135,7 @@ static ulong stm32mp1_clk_get(struct stm32mp1_clk_priv 
> *priv, int p)
>   break;
>   }
>  
> - debug("%s(%d) clock = %lx : %ld kHz\n",
> -   __func__, p, clock, clock / 1000);
> + log_debug("id=%d clock = %lx : %ld kHz\n", p, clock, clock / 1000);
>  
>   return clock;
>  }
> @@ -1156,7 +1154,7 @@ static int stm32mp1_clk_enable(struct clk *clk)
>   else
>   setbits_le32(priv->base + gate[i].offset, BIT(gate[i].bit));
>  
> - debug("%s: id clock %d has been enabled\n", __func__, (u32)clk->id);
> + dev_dbg(clk->dev, "%s: id clock %d has been enabled\n", __func__, 
> (u32)clk->id);
>  
>   return 0;
>  }
> @@ -1177,7 +1175,7 @@ static int stm32mp1_clk_disable(struct clk *clk)
>   else
>   clrbits_le32(priv->base + gate[i].offset, BIT(gate[i].bit));
>  
> - debug("%s: id clock %d has been disabled\n", __func__, (u32)clk->id);
> + dev_dbg(clk->dev, "%s: id clock %d has been disabled\n", __func__, 
> (u32)clk->id);
>  
>   return 0;
>  }
> @@ -1193,10 +1191,9 @@ static ulong stm32mp1_clk_get_rate(struct clk *clk)
>  
>   rate = stm32mp1_clk_get(priv, p);
>  
> -#ifdef DEBUG
> - debug("%s: computed rate for id clock %d is %d (parent is %s)\n",
> -   __func__, (u32)clk->id, (u32)rate, stm32mp1_clk_parent_name[p]);
> -#endif
> + dev_vdbg(clk->dev, "computed rate 

[PATCH 17/33] clk: stm32mp1: migrate trace to dev and log macro

2020-10-14 Thread Patrick Delaunay
Change debug and pr_ macro to dev macro and define LOG_CATEGORY.

Remove the "%s:" __func__  header as it is managed by dev macro
(dev->name is displayed) or log macro (CONFIG_LOGF_FUNC).

Signed-off-by: Patrick Delaunay 
---

 drivers/clk/clk_stm32mp1.c | 147 ++---
 1 file changed, 71 insertions(+), 76 deletions(-)

diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c
index c8840b9e5f..aca4db9946 100644
--- a/drivers/clk/clk_stm32mp1.c
+++ b/drivers/clk/clk_stm32mp1.c
@@ -3,6 +3,8 @@
  * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
  */
 
+#define LOG_CATEGORY UCLASS_CLK
+
 #include 
 #include 
 #include 
@@ -14,12 +16,13 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
 #include 
+#include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -781,7 +784,7 @@ static const struct stm32mp1_clk_data stm32mp1_data = {
 static ulong stm32mp1_clk_get_fixed(struct stm32mp1_clk_priv *priv, int idx)
 {
if (idx >= NB_OSC) {
-   debug("%s: clk id %d not found\n", __func__, idx);
+   log_debug("clk id %d not found\n", idx);
return 0;
}
 
@@ -799,7 +802,7 @@ static int stm32mp1_clk_get_id(struct stm32mp1_clk_priv 
*priv, unsigned long id)
}
 
if (i == nb_clks) {
-   printf("%s: clk id %d not found\n", __func__, (u32)id);
+   log_err("clk id %d not found\n", (u32)id);
return -EINVAL;
}
 
@@ -812,8 +815,7 @@ static int stm32mp1_clk_get_sel(struct stm32mp1_clk_priv 
*priv,
const struct stm32mp1_clk_gate *gate = priv->data->gate;
 
if (gate[i].sel > _PARENT_SEL_NB) {
-   printf("%s: parents for clk id %d not found\n",
-  __func__, i);
+   log_err("parents for clk id %d not found\n", i);
return -EINVAL;
}
 
@@ -858,17 +860,14 @@ static int stm32mp1_clk_get_parent(struct 
stm32mp1_clk_priv *priv,
p = (readl(priv->base + sel[s].offset) >> sel[s].src) & sel[s].msk;
 
if (p < sel[s].nb_parent) {
-#ifdef DEBUG
-   debug("%s: %s clock is the parent %s of clk id %d\n", __func__,
- stm32mp1_clk_parent_name[sel[s].parent[p]],
- stm32mp1_clk_parent_sel_name[s],
- (u32)id);
-#endif
+   log_content("%s clock is the parent %s of clk id %d\n",
+   stm32mp1_clk_parent_name[sel[s].parent[p]],
+   stm32mp1_clk_parent_sel_name[s],
+   (u32)id);
return sel[s].parent[p];
}
 
-   pr_err("%s: no parents defined for clk id %d\n",
-  __func__, (u32)id);
+   log_err("no parents defined for clk id %d\n", (u32)id);
 
return -EINVAL;
 }
@@ -1124,7 +1123,7 @@ static ulong stm32mp1_clk_get(struct stm32mp1_clk_priv 
*priv, int p)
if (!uclass_get_device_by_name(UCLASS_CLK, "ck_dsi_phy",
   )) {
if (clk_request(dev, )) {
-   pr_err("ck_dsi_phy request");
+   log_err("ck_dsi_phy request");
} else {
clk.id = 0;
clock = clk_get_rate();
@@ -1136,8 +1135,7 @@ static ulong stm32mp1_clk_get(struct stm32mp1_clk_priv 
*priv, int p)
break;
}
 
-   debug("%s(%d) clock = %lx : %ld kHz\n",
- __func__, p, clock, clock / 1000);
+   log_debug("id=%d clock = %lx : %ld kHz\n", p, clock, clock / 1000);
 
return clock;
 }
@@ -1156,7 +1154,7 @@ static int stm32mp1_clk_enable(struct clk *clk)
else
setbits_le32(priv->base + gate[i].offset, BIT(gate[i].bit));
 
-   debug("%s: id clock %d has been enabled\n", __func__, (u32)clk->id);
+   dev_dbg(clk->dev, "%s: id clock %d has been enabled\n", __func__, 
(u32)clk->id);
 
return 0;
 }
@@ -1177,7 +1175,7 @@ static int stm32mp1_clk_disable(struct clk *clk)
else
clrbits_le32(priv->base + gate[i].offset, BIT(gate[i].bit));
 
-   debug("%s: id clock %d has been disabled\n", __func__, (u32)clk->id);
+   dev_dbg(clk->dev, "%s: id clock %d has been disabled\n", __func__, 
(u32)clk->id);
 
return 0;
 }
@@ -1193,10 +1191,9 @@ static ulong stm32mp1_clk_get_rate(struct clk *clk)
 
rate = stm32mp1_clk_get(priv, p);
 
-#ifdef DEBUG
-   debug("%s: computed rate for id clock %d is %d (parent is %s)\n",
- __func__, (u32)clk->id, (u32)rate, stm32mp1_clk_parent_name[p]);
-#endif
+   dev_vdbg(clk->dev, "computed rate for id clock %d is %d (parent is 
%s)\n",
+(u32)clk->id, (u32)rate, stm32mp1_clk_parent_name[p]);
+
return rate;
 }
 
@@ -1335,7 +1332,7 @@ static int stm32mp1_pll1_opp(struct stm32mp1_clk_priv