Re: [PATCH 09/33] mmc: stm32_sdmmc2: 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:
> Define LOG_CATEGORY, use dev_ macro when it is possible.
> 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/mmc/stm32_sdmmc2.c | 85 --
>  1 file changed, 44 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c
> index 6d50356217..483660c9d3 100644
> --- a/drivers/mmc/stm32_sdmmc2.c
> +++ b/drivers/mmc/stm32_sdmmc2.c
> @@ -4,6 +4,8 @@
>   * Author(s): Patrice Chotard,  for 
> STMicroelectronics.
>   */
>  
> +#define LOG_CATEGORY UCLASS_MMC
> +
>  #include 
>  #include 
>  #include 
> @@ -200,10 +202,11 @@ struct stm32_sdmmc2_ctx {
>  #define SDMMC_CMD_TIMEOUT0x
>  #define SDMMC_BUSYD0END_TIMEOUT_US   200
>  
> -static void stm32_sdmmc2_start_data(struct stm32_sdmmc2_priv *priv,
> +static void stm32_sdmmc2_start_data(struct udevice *dev,
>   struct mmc_data *data,
>   struct stm32_sdmmc2_ctx *ctx)
>  {
> + struct stm32_sdmmc2_priv *priv = dev_get_priv(dev);
>   u32 data_ctrl, idmabase0;
>  
>   /* Configure the SDMMC DPSM (Data Path State Machine) */
> @@ -241,10 +244,11 @@ static void stm32_sdmmc2_start_data(struct 
> stm32_sdmmc2_priv *priv,
>   writel(SDMMC_IDMACTRL_IDMAEN, priv->base + SDMMC_IDMACTRL);
>  }
>  
> -static void stm32_sdmmc2_start_cmd(struct stm32_sdmmc2_priv *priv,
> +static void stm32_sdmmc2_start_cmd(struct udevice *dev,
>  struct mmc_cmd *cmd, u32 cmd_param,
>  struct stm32_sdmmc2_ctx *ctx)
>  {
> + struct stm32_sdmmc2_priv *priv = dev_get_priv(dev);
>   u32 timeout = 0;
>  
>   if (readl(priv->base + SDMMC_CMD) & SDMMC_CMD_CPSMEN)
> @@ -290,10 +294,11 @@ static void stm32_sdmmc2_start_cmd(struct 
> stm32_sdmmc2_priv *priv,
>   writel(cmd_param, priv->base + SDMMC_CMD);
>  }
>  
> -static int stm32_sdmmc2_end_cmd(struct stm32_sdmmc2_priv *priv,
> +static int stm32_sdmmc2_end_cmd(struct udevice *dev,
>   struct mmc_cmd *cmd,
>   struct stm32_sdmmc2_ctx *ctx)
>  {
> + struct stm32_sdmmc2_priv *priv = dev_get_priv(dev);
>   u32 mask = SDMMC_STA_CTIMEOUT;
>   u32 status;
>   int ret;
> @@ -311,22 +316,22 @@ static int stm32_sdmmc2_end_cmd(struct 
> stm32_sdmmc2_priv *priv,
>1);
>  
>   if (ret < 0) {
> - debug("%s: timeout reading SDMMC_STA register\n", __func__);
> + dev_dbg(dev, "timeout reading SDMMC_STA register\n");
>   ctx->dpsm_abort = true;
>   return ret;
>   }
>  
>   /* Check status */
>   if (status & SDMMC_STA_CTIMEOUT) {
> - debug("%s: error SDMMC_STA_CTIMEOUT (0x%x) for cmd %d\n",
> -   __func__, status, cmd->cmdidx);
> + dev_dbg(dev, "error SDMMC_STA_CTIMEOUT (0x%x) for cmd %d\n",
> + status, cmd->cmdidx);
>   ctx->dpsm_abort = true;
>   return -ETIMEDOUT;
>   }
>  
>   if (status & SDMMC_STA_CCRCFAIL && cmd->resp_type & MMC_RSP_CRC) {
> - debug("%s: error SDMMC_STA_CCRCFAIL (0x%x) for cmd %d\n",
> -   __func__, status, cmd->cmdidx);
> + dev_dbg(dev, "error SDMMC_STA_CCRCFAIL (0x%x) for cmd %d\n",
> + status, cmd->cmdidx);
>   ctx->dpsm_abort = true;
>   return -EILSEQ;
>   }
> @@ -350,15 +355,15 @@ static int stm32_sdmmc2_end_cmd(struct 
> stm32_sdmmc2_priv *priv,
>SDMMC_BUSYD0END_TIMEOUT_US);
>  
>   if (ret < 0) {
> - debug("%s: timeout reading SDMMC_STA\n",
> -   __func__);
> + dev_dbg(dev, "timeout reading SDMMC_STA\n");
>   ctx->dpsm_abort = true;
>   return ret;
>   }
>  
>   if (status & SDMMC_STA_DTIMEOUT) {
> - debug("%s: error SDMMC_STA_DTIMEOUT (0x%x)\n",
> -   __func__, status);
> + dev_dbg(dev,
> + "error SDMMC_STA_DTIMEOUT (0x%x)\n",
> + status);
>   ctx->dpsm_abort = true;
>   return -ETIMEDOUT;
>   }
> @@ -368,11 +373,12 @@ static int stm32_sdmmc2_end_cmd(struct 
> stm32_sdmmc2_priv *priv,
>   return 0;
>  }
>  
> -static int stm32_sdmmc2_end_data(struct stm32_sdmmc2_priv *priv,
> +static int stm32_sdmmc2_end_data(struct udevice *dev,
>struct 

RE: [PATCH 09/33] mmc: stm32_sdmmc2: migrate trace to dev and log macro

2020-10-15 Thread Peng Fan
> Subject: [PATCH 09/33] mmc: stm32_sdmmc2: migrate trace to dev and log
> macro
> 
> Define LOG_CATEGORY, use dev_ macro when it is possible.
> 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/mmc/stm32_sdmmc2.c | 85
> --
>  1 file changed, 44 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c
> index 6d50356217..483660c9d3 100644
> --- a/drivers/mmc/stm32_sdmmc2.c
> +++ b/drivers/mmc/stm32_sdmmc2.c
> @@ -4,6 +4,8 @@
>   * Author(s): Patrice Chotard,  for
> STMicroelectronics.
>   */
> 
> +#define LOG_CATEGORY UCLASS_MMC
> +
>  #include 
>  #include 
>  #include 
> @@ -200,10 +202,11 @@ struct stm32_sdmmc2_ctx {
>  #define SDMMC_CMD_TIMEOUT0x
>  #define SDMMC_BUSYD0END_TIMEOUT_US   200
> 
> -static void stm32_sdmmc2_start_data(struct stm32_sdmmc2_priv *priv,
> +static void stm32_sdmmc2_start_data(struct udevice *dev,
>   struct mmc_data *data,
>   struct stm32_sdmmc2_ctx *ctx)
>  {
> + struct stm32_sdmmc2_priv *priv = dev_get_priv(dev);
>   u32 data_ctrl, idmabase0;
> 
>   /* Configure the SDMMC DPSM (Data Path State Machine) */ @@
> -241,10 +244,11 @@ static void stm32_sdmmc2_start_data(struct
> stm32_sdmmc2_priv *priv,
>   writel(SDMMC_IDMACTRL_IDMAEN, priv->base +
> SDMMC_IDMACTRL);  }
> 
> -static void stm32_sdmmc2_start_cmd(struct stm32_sdmmc2_priv *priv,
> +static void stm32_sdmmc2_start_cmd(struct udevice *dev,
>  struct mmc_cmd *cmd, u32 cmd_param,
>  struct stm32_sdmmc2_ctx *ctx)
>  {
> + struct stm32_sdmmc2_priv *priv = dev_get_priv(dev);
>   u32 timeout = 0;
> 
>   if (readl(priv->base + SDMMC_CMD) & SDMMC_CMD_CPSMEN) @@
> -290,10 +294,11 @@ static void stm32_sdmmc2_start_cmd(struct
> stm32_sdmmc2_priv *priv,
>   writel(cmd_param, priv->base + SDMMC_CMD);  }
> 
> -static int stm32_sdmmc2_end_cmd(struct stm32_sdmmc2_priv *priv,
> +static int stm32_sdmmc2_end_cmd(struct udevice *dev,
>   struct mmc_cmd *cmd,
>   struct stm32_sdmmc2_ctx *ctx)
>  {
> + struct stm32_sdmmc2_priv *priv = dev_get_priv(dev);
>   u32 mask = SDMMC_STA_CTIMEOUT;
>   u32 status;
>   int ret;
> @@ -311,22 +316,22 @@ static int stm32_sdmmc2_end_cmd(struct
> stm32_sdmmc2_priv *priv,
>1);
> 
>   if (ret < 0) {
> - debug("%s: timeout reading SDMMC_STA register\n", __func__);
> + dev_dbg(dev, "timeout reading SDMMC_STA register\n");
>   ctx->dpsm_abort = true;
>   return ret;
>   }
> 
>   /* Check status */
>   if (status & SDMMC_STA_CTIMEOUT) {
> - debug("%s: error SDMMC_STA_CTIMEOUT (0x%x) for cmd %d\n",
> -   __func__, status, cmd->cmdidx);
> + dev_dbg(dev, "error SDMMC_STA_CTIMEOUT (0x%x) for
> cmd %d\n",
> + status, cmd->cmdidx);
>   ctx->dpsm_abort = true;
>   return -ETIMEDOUT;
>   }
> 
>   if (status & SDMMC_STA_CCRCFAIL && cmd->resp_type &
> MMC_RSP_CRC) {
> - debug("%s: error SDMMC_STA_CCRCFAIL (0x%x) for cmd %d\n",
> -   __func__, status, cmd->cmdidx);
> + dev_dbg(dev, "error SDMMC_STA_CCRCFAIL (0x%x) for cmd %d\n",
> + status, cmd->cmdidx);
>   ctx->dpsm_abort = true;
>   return -EILSEQ;
>   }
> @@ -350,15 +355,15 @@ static int stm32_sdmmc2_end_cmd(struct
> stm32_sdmmc2_priv *priv,
>SDMMC_BUSYD0END_TIMEOUT_US);
> 
>   if (ret < 0) {
> - debug("%s: timeout reading SDMMC_STA\n",
> -   __func__);
> + dev_dbg(dev, "timeout reading SDMMC_STA\n");
>   ctx->dpsm_abort = true;
>   return ret;
>   }
> 
>   if (status & SDMMC_STA_DTIMEOUT) {
> - debug("%s: error SDMMC_STA_DTIMEOUT (0x%x)\n",
> -   __func__, status);
> +  

[PATCH 09/33] mmc: stm32_sdmmc2: migrate trace to dev and log macro

2020-10-14 Thread Patrick Delaunay
Define LOG_CATEGORY, use dev_ macro when it is possible.
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/mmc/stm32_sdmmc2.c | 85 --
 1 file changed, 44 insertions(+), 41 deletions(-)

diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c
index 6d50356217..483660c9d3 100644
--- a/drivers/mmc/stm32_sdmmc2.c
+++ b/drivers/mmc/stm32_sdmmc2.c
@@ -4,6 +4,8 @@
  * Author(s): Patrice Chotard,  for STMicroelectronics.
  */
 
+#define LOG_CATEGORY UCLASS_MMC
+
 #include 
 #include 
 #include 
@@ -200,10 +202,11 @@ struct stm32_sdmmc2_ctx {
 #define SDMMC_CMD_TIMEOUT  0x
 #define SDMMC_BUSYD0END_TIMEOUT_US 200
 
-static void stm32_sdmmc2_start_data(struct stm32_sdmmc2_priv *priv,
+static void stm32_sdmmc2_start_data(struct udevice *dev,
struct mmc_data *data,
struct stm32_sdmmc2_ctx *ctx)
 {
+   struct stm32_sdmmc2_priv *priv = dev_get_priv(dev);
u32 data_ctrl, idmabase0;
 
/* Configure the SDMMC DPSM (Data Path State Machine) */
@@ -241,10 +244,11 @@ static void stm32_sdmmc2_start_data(struct 
stm32_sdmmc2_priv *priv,
writel(SDMMC_IDMACTRL_IDMAEN, priv->base + SDMMC_IDMACTRL);
 }
 
-static void stm32_sdmmc2_start_cmd(struct stm32_sdmmc2_priv *priv,
+static void stm32_sdmmc2_start_cmd(struct udevice *dev,
   struct mmc_cmd *cmd, u32 cmd_param,
   struct stm32_sdmmc2_ctx *ctx)
 {
+   struct stm32_sdmmc2_priv *priv = dev_get_priv(dev);
u32 timeout = 0;
 
if (readl(priv->base + SDMMC_CMD) & SDMMC_CMD_CPSMEN)
@@ -290,10 +294,11 @@ static void stm32_sdmmc2_start_cmd(struct 
stm32_sdmmc2_priv *priv,
writel(cmd_param, priv->base + SDMMC_CMD);
 }
 
-static int stm32_sdmmc2_end_cmd(struct stm32_sdmmc2_priv *priv,
+static int stm32_sdmmc2_end_cmd(struct udevice *dev,
struct mmc_cmd *cmd,
struct stm32_sdmmc2_ctx *ctx)
 {
+   struct stm32_sdmmc2_priv *priv = dev_get_priv(dev);
u32 mask = SDMMC_STA_CTIMEOUT;
u32 status;
int ret;
@@ -311,22 +316,22 @@ static int stm32_sdmmc2_end_cmd(struct stm32_sdmmc2_priv 
*priv,
 1);
 
if (ret < 0) {
-   debug("%s: timeout reading SDMMC_STA register\n", __func__);
+   dev_dbg(dev, "timeout reading SDMMC_STA register\n");
ctx->dpsm_abort = true;
return ret;
}
 
/* Check status */
if (status & SDMMC_STA_CTIMEOUT) {
-   debug("%s: error SDMMC_STA_CTIMEOUT (0x%x) for cmd %d\n",
- __func__, status, cmd->cmdidx);
+   dev_dbg(dev, "error SDMMC_STA_CTIMEOUT (0x%x) for cmd %d\n",
+   status, cmd->cmdidx);
ctx->dpsm_abort = true;
return -ETIMEDOUT;
}
 
if (status & SDMMC_STA_CCRCFAIL && cmd->resp_type & MMC_RSP_CRC) {
-   debug("%s: error SDMMC_STA_CCRCFAIL (0x%x) for cmd %d\n",
- __func__, status, cmd->cmdidx);
+   dev_dbg(dev, "error SDMMC_STA_CCRCFAIL (0x%x) for cmd %d\n",
+   status, cmd->cmdidx);
ctx->dpsm_abort = true;
return -EILSEQ;
}
@@ -350,15 +355,15 @@ static int stm32_sdmmc2_end_cmd(struct stm32_sdmmc2_priv 
*priv,
 SDMMC_BUSYD0END_TIMEOUT_US);
 
if (ret < 0) {
-   debug("%s: timeout reading SDMMC_STA\n",
- __func__);
+   dev_dbg(dev, "timeout reading SDMMC_STA\n");
ctx->dpsm_abort = true;
return ret;
}
 
if (status & SDMMC_STA_DTIMEOUT) {
-   debug("%s: error SDMMC_STA_DTIMEOUT (0x%x)\n",
- __func__, status);
+   dev_dbg(dev,
+   "error SDMMC_STA_DTIMEOUT (0x%x)\n",
+   status);
ctx->dpsm_abort = true;
return -ETIMEDOUT;
}
@@ -368,11 +373,12 @@ static int stm32_sdmmc2_end_cmd(struct stm32_sdmmc2_priv 
*priv,
return 0;
 }
 
-static int stm32_sdmmc2_end_data(struct stm32_sdmmc2_priv *priv,
+static int stm32_sdmmc2_end_data(struct udevice *dev,
 struct mmc_cmd *cmd,
 struct mmc_data *data,
 struct stm32_sdmmc2_ctx *ctx)
 {
+   struct stm32_sdmmc2_priv *priv =