Re: [PATCH v2] mmc: dw_mmc: Fix coding style issues

2015-08-05 Thread Jaehoon Chung
Hi, Shawn.

Applied this patch at my dw-mmc tree.
I will request pull on this weekend.
Thanks a lot!

Best Regards,
Jaehoon Chung

On 08/03/2015 04:07 PM, Shawn Lin wrote:
> This patch fixes the following issues reported by checkpatch.pl:
> - use -EINVAL instead of -ENOSYS, to fix warning message:
>"ENOSYS means 'invalid syscall nr' and nothing else"
> - split lines whose length is greater than 80 characters
> - avoid quoted string split across lines
> - use min_t instead of min, to fix warning message:
>"min() should probably be min_t(int, cnt, host->part_buf_count)"
> - fix missing a blank line after declarations
> 
> Signed-off-by: Shawn Lin 
> 
> ---
> 
> Changes in v2:
> - Keep consistency of comments
> - Rebase on https://patchwork.kernel.org/patch/6672581
> 
>  drivers/mmc/host/dw_mmc.c | 90 
> +--
>  1 file changed, 56 insertions(+), 34 deletions(-)
> 
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index e41fb74..3f070d9 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -238,8 +238,8 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, 
> struct mmc_command *cmd)
>   struct dw_mci *host = slot->host;
>   const struct dw_mci_drv_data *drv_data = slot->host->drv_data;
>   u32 cmdr;
> - cmd->error = -EINPROGRESS;
>  
> + cmd->error = -EINPROGRESS;
>   cmdr = cmd->opcode;
>  
>   if (cmd->opcode == MMC_STOP_TRANSMISSION ||
> @@ -374,7 +374,7 @@ static void dw_mci_start_command(struct dw_mci *host,
>cmd->arg, cmd_flags);
>  
>   mci_writel(host, CMDARG, cmd->arg);
> - wmb();
> + wmb(); /* drain writebuffer */
>   dw_mci_wait_while_busy(host, cmd_flags);
>  
>   mci_writel(host, CMD, cmd_flags | SDMMC_CMD_START);
> @@ -383,6 +383,7 @@ static void dw_mci_start_command(struct dw_mci *host,
>  static inline void send_stop_abort(struct dw_mci *host, struct mmc_data 
> *data)
>  {
>   struct mmc_command *stop = data->stop ? data->stop : &host->stop_abort;
> +
>   dw_mci_start_command(host, stop, host->stop_cmdr);
>  }
>  
> @@ -467,6 +468,7 @@ static void dw_mci_translate_sglist(struct dw_mci *host, 
> struct mmc_data *data,
>  {
>   unsigned int desc_len;
>   int i;
> +
>   if (host->dma_64bit_address == 1) {
>   struct idmac_desc_64addr *desc_first, *desc_last, *desc;
>  
> @@ -474,6 +476,7 @@ static void dw_mci_translate_sglist(struct dw_mci *host, 
> struct mmc_data *data,
>  
>   for (i = 0; i < sg_len; i++) {
>   unsigned int length = sg_dma_len(&data->sg[i]);
> +
>   u64 mem_addr = sg_dma_address(&data->sg[i]);
>  
>   for ( ; length ; desc++) {
> @@ -518,6 +521,7 @@ static void dw_mci_translate_sglist(struct dw_mci *host, 
> struct mmc_data *data,
>  
>   for (i = 0; i < sg_len; i++) {
>   unsigned int length = sg_dma_len(&data->sg[i]);
> +
>   u32 mem_addr = sg_dma_address(&data->sg[i]);
>  
>   for ( ; length ; desc++) {
> @@ -557,7 +561,7 @@ static void dw_mci_translate_sglist(struct dw_mci *host, 
> struct mmc_data *data,
>   desc_last->des0 |= cpu_to_le32(IDMAC_DES0_LD);
>   }
>  
> - wmb();
> + wmb(); /* drain writebuffer */
>  }
>  
>  static void dw_mci_idmac_start_dma(struct dw_mci *host, unsigned int sg_len)
> @@ -575,6 +579,7 @@ static void dw_mci_idmac_start_dma(struct dw_mci *host, 
> unsigned int sg_len)
>   temp |= SDMMC_CTRL_USE_IDMAC;
>   mci_writel(host, CTRL, temp);
>  
> + /* drain writebuffer */
>   wmb();
>  
>   /* Enable the IDMAC */
> @@ -622,7 +627,9 @@ static int dw_mci_idmac_init(struct dw_mci *host)
>   host->ring_size = PAGE_SIZE / sizeof(struct idmac_desc);
>  
>   /* Forward link the descriptor list */
> - for (i = 0, p = host->sg_cpu; i < host->ring_size - 1; i++, 
> p++) {
> + for (i = 0, p = host->sg_cpu;
> +  i < host->ring_size - 1;
> +  i++, p++) {
>   p->des3 = cpu_to_le32(host->sg_dma +
>   (sizeof(struct idmac_desc) * (i + 1)));
>   p->des1 = 0;
> @@ -751,7 +758,7 @@ static void dw_mci_adjust_fifoth(struct dw_mci *host, 
> struct mmc_data *data)
>   u32 fifo_width = 1 << host->data_shift;
>   u32 blksz_depth = blksz / fifo_width, fifoth_val;
>   u32 msize = 0, rx_wmark = 1, tx_wmark, tx_wmark_invers;
> - int idx = (sizeof(mszs) / sizeof(mszs[0])) - 1;
> + int idx = ARRAY_SIZE(mszs) - 1;
>  
>   tx_wmark = (host->fifo_depth) / 2;
>   tx_wmark_invers = host->fifo_depth - tx_wmark;
> @@ -876,6 +883,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, 
> struct mmc_data *data)
>  static void dw_mci_submit_data(struct dw_mci *host, struct mmc_data *data)
>  {
>   unsigned long irqflags;

[PATCH v2] mmc: dw_mmc: Fix coding style issues

2015-08-03 Thread Shawn Lin
This patch fixes the following issues reported by checkpatch.pl:
- use -EINVAL instead of -ENOSYS, to fix warning message:
   "ENOSYS means 'invalid syscall nr' and nothing else"
- split lines whose length is greater than 80 characters
- avoid quoted string split across lines
- use min_t instead of min, to fix warning message:
   "min() should probably be min_t(int, cnt, host->part_buf_count)"
- fix missing a blank line after declarations

Signed-off-by: Shawn Lin 

---

Changes in v2:
- Keep consistency of comments
- Rebase on https://patchwork.kernel.org/patch/6672581

 drivers/mmc/host/dw_mmc.c | 90 +--
 1 file changed, 56 insertions(+), 34 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index e41fb74..3f070d9 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -238,8 +238,8 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, 
struct mmc_command *cmd)
struct dw_mci *host = slot->host;
const struct dw_mci_drv_data *drv_data = slot->host->drv_data;
u32 cmdr;
-   cmd->error = -EINPROGRESS;
 
+   cmd->error = -EINPROGRESS;
cmdr = cmd->opcode;
 
if (cmd->opcode == MMC_STOP_TRANSMISSION ||
@@ -374,7 +374,7 @@ static void dw_mci_start_command(struct dw_mci *host,
 cmd->arg, cmd_flags);
 
mci_writel(host, CMDARG, cmd->arg);
-   wmb();
+   wmb(); /* drain writebuffer */
dw_mci_wait_while_busy(host, cmd_flags);
 
mci_writel(host, CMD, cmd_flags | SDMMC_CMD_START);
@@ -383,6 +383,7 @@ static void dw_mci_start_command(struct dw_mci *host,
 static inline void send_stop_abort(struct dw_mci *host, struct mmc_data *data)
 {
struct mmc_command *stop = data->stop ? data->stop : &host->stop_abort;
+
dw_mci_start_command(host, stop, host->stop_cmdr);
 }
 
@@ -467,6 +468,7 @@ static void dw_mci_translate_sglist(struct dw_mci *host, 
struct mmc_data *data,
 {
unsigned int desc_len;
int i;
+
if (host->dma_64bit_address == 1) {
struct idmac_desc_64addr *desc_first, *desc_last, *desc;
 
@@ -474,6 +476,7 @@ static void dw_mci_translate_sglist(struct dw_mci *host, 
struct mmc_data *data,
 
for (i = 0; i < sg_len; i++) {
unsigned int length = sg_dma_len(&data->sg[i]);
+
u64 mem_addr = sg_dma_address(&data->sg[i]);
 
for ( ; length ; desc++) {
@@ -518,6 +521,7 @@ static void dw_mci_translate_sglist(struct dw_mci *host, 
struct mmc_data *data,
 
for (i = 0; i < sg_len; i++) {
unsigned int length = sg_dma_len(&data->sg[i]);
+
u32 mem_addr = sg_dma_address(&data->sg[i]);
 
for ( ; length ; desc++) {
@@ -557,7 +561,7 @@ static void dw_mci_translate_sglist(struct dw_mci *host, 
struct mmc_data *data,
desc_last->des0 |= cpu_to_le32(IDMAC_DES0_LD);
}
 
-   wmb();
+   wmb(); /* drain writebuffer */
 }
 
 static void dw_mci_idmac_start_dma(struct dw_mci *host, unsigned int sg_len)
@@ -575,6 +579,7 @@ static void dw_mci_idmac_start_dma(struct dw_mci *host, 
unsigned int sg_len)
temp |= SDMMC_CTRL_USE_IDMAC;
mci_writel(host, CTRL, temp);
 
+   /* drain writebuffer */
wmb();
 
/* Enable the IDMAC */
@@ -622,7 +627,9 @@ static int dw_mci_idmac_init(struct dw_mci *host)
host->ring_size = PAGE_SIZE / sizeof(struct idmac_desc);
 
/* Forward link the descriptor list */
-   for (i = 0, p = host->sg_cpu; i < host->ring_size - 1; i++, 
p++) {
+   for (i = 0, p = host->sg_cpu;
+i < host->ring_size - 1;
+i++, p++) {
p->des3 = cpu_to_le32(host->sg_dma +
(sizeof(struct idmac_desc) * (i + 1)));
p->des1 = 0;
@@ -751,7 +758,7 @@ static void dw_mci_adjust_fifoth(struct dw_mci *host, 
struct mmc_data *data)
u32 fifo_width = 1 << host->data_shift;
u32 blksz_depth = blksz / fifo_width, fifoth_val;
u32 msize = 0, rx_wmark = 1, tx_wmark, tx_wmark_invers;
-   int idx = (sizeof(mszs) / sizeof(mszs[0])) - 1;
+   int idx = ARRAY_SIZE(mszs) - 1;
 
tx_wmark = (host->fifo_depth) / 2;
tx_wmark_invers = host->fifo_depth - tx_wmark;
@@ -876,6 +883,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, 
struct mmc_data *data)
 static void dw_mci_submit_data(struct dw_mci *host, struct mmc_data *data)
 {
unsigned long irqflags;
+   int flags = SG_MITER_ATOMIC;
u32 temp;
 
data->error = -EINPROGRESS;
@@ -892,7 +900,6 @@ static void dw_mci_submit_data(struct dw_mci *host, struct 
mmc_data *data)
}
 
if (dw_mci_submit_data_dma(host, data)) {
-   int flags = SG_MITER_ATOMIC;
if (host-