diff mbox

[1/1] spi: Re-do correctly function name and 'ret' return value

Message ID 1429857656-8348-2-git-send-email-cm-hiep@jinso.co.jp (mailing list archive)
State New, archived
Headers show

Commit Message

Cao Minh Hiep April 24, 2015, 6:40 a.m. UTC
From: Hiep Cao Minh <cm-hiep@jinso.co.jp>

qspi_trigger_transfer_out_int function should be qspi_trigger_transfer_out_in
without "t". "ret" value in rspi_dma_check_then_transfer should be returned
insteeds of returning zero. It just returns qspi_trigger_transfer_out_in() value
in qspi_transfer_out_in().

Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp>
---
 drivers/spi/spi-rspi.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Comments

Geert Uytterhoeven April 24, 2015, 7:25 a.m. UTC | #1
Hi Hiep-san,

On Fri, Apr 24, 2015 at 8:40 AM, Cao Minh Hiep <cm-hiep@jinso.co.jp> wrote:
> From: Hiep Cao Minh <cm-hiep@jinso.co.jp>
>
> qspi_trigger_transfer_out_int function should be qspi_trigger_transfer_out_in
> without "t". "ret" value in rspi_dma_check_then_transfer should be returned
> insteeds of returning zero. It just returns qspi_trigger_transfer_out_in() value
> in qspi_transfer_out_in().

Thanks for your patch!

I guess Mark will want you to split this in 3 separate patches, as it does 3
different things...

> Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp>
> ---
>  drivers/spi/spi-rspi.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
> index 186924a..9304a6d 100644
> --- a/drivers/spi/spi-rspi.c
> +++ b/drivers/spi/spi-rspi.c
> @@ -670,7 +670,7 @@ static int rspi_dma_check_then_transfer(struct rspi_data *rspi,
>                 int ret = rspi_dma_transfer(rspi, &xfer->tx_sg,
>                                         xfer->rx_buf ? &xfer->rx_sg : NULL);
>                 if (ret != -EAGAIN)
> -                       return 0;
> +                       return ret;
>         }
>
>         return -EAGAIN;

Upon closer look, you can just drop the "if" check, and return "ret"
unconditionally. Or better, drop "ret", and just use

        return rspi_dma_transfer(...);

To reduce indentation, the function can be rewritten like:

static int rspi_dma_check_then_transfer(struct rspi_data *rspi,
                                         struct spi_transfer *xfer)
{
        if (!rspi->master->can_dma || !__rspi_can_dma(rspi, xfer))
                return -EAGAIN;

        /* rx_buf can be NULL on RSPI on SH in TX-only Mode */
        return rspi_dma_transfer(rspi, &xfer->tx_sg,
                                        xfer->rx_buf ? &xfer->rx_sg : NULL);
}

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Cao Minh Hiep April 24, 2015, 7:34 a.m. UTC | #2
Hi Geert-san

Thanks for your comments,

On 2015?04?24? 16:25, Geert Uytterhoeven wrote:
> Hi Hiep-san,
>
> On Fri, Apr 24, 2015 at 8:40 AM, Cao Minh Hiep <cm-hiep@jinso.co.jp> wrote:
>> From: Hiep Cao Minh <cm-hiep@jinso.co.jp>
>>
>> qspi_trigger_transfer_out_int function should be qspi_trigger_transfer_out_in
>> without "t". "ret" value in rspi_dma_check_then_transfer should be returned
>> insteeds of returning zero. It just returns qspi_trigger_transfer_out_in() value
>> in qspi_transfer_out_in().
> Thanks for your patch!
>
> I guess Mark will want you to split this in 3 separate patches, as it does 3
> different things...
Thanks, I will split this patch in 3 separate patches.
>> Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp>
>> ---
>>   drivers/spi/spi-rspi.c | 10 +++-------
>>   1 file changed, 3 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
>> index 186924a..9304a6d 100644
>> --- a/drivers/spi/spi-rspi.c
>> +++ b/drivers/spi/spi-rspi.c
>> @@ -670,7 +670,7 @@ static int rspi_dma_check_then_transfer(struct rspi_data *rspi,
>>                  int ret = rspi_dma_transfer(rspi, &xfer->tx_sg,
>>                                          xfer->rx_buf ? &xfer->rx_sg : NULL);
>>                  if (ret != -EAGAIN)
>> -                       return 0;
>> +                       return ret;
>>          }
>>
>>          return -EAGAIN;
> Upon closer look, you can just drop the "if" check, and return "ret"
> unconditionally. Or better, drop "ret", and just use
>
>          return rspi_dma_transfer(...);
Thanks, I will do it as you pointed out.


Hiep.

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 186924a..9304a6d 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -670,7 +670,7 @@  static int rspi_dma_check_then_transfer(struct rspi_data *rspi,
 		int ret = rspi_dma_transfer(rspi, &xfer->tx_sg,
 					xfer->rx_buf ? &xfer->rx_sg : NULL);
 		if (ret != -EAGAIN)
-			return 0;
+			return ret;
 	}
 
 	return -EAGAIN;
@@ -724,7 +724,7 @@  static int rspi_rz_transfer_one(struct spi_master *master,
 	return rspi_common_transfer(rspi, xfer);
 }
 
-static int qspi_trigger_transfer_out_int(struct rspi_data *rspi, const u8 *tx,
+static int qspi_trigger_transfer_out_in(struct rspi_data *rspi, const u8 *tx,
 					u8 *rx, unsigned int len)
 {
 	int i, n, ret;
@@ -771,12 +771,8 @@  static int qspi_transfer_out_in(struct rspi_data *rspi,
 	if (ret != -EAGAIN)
 		return ret;
 
-	ret = qspi_trigger_transfer_out_int(rspi, xfer->tx_buf,
+	return qspi_trigger_transfer_out_in(rspi, xfer->tx_buf,
 					    xfer->rx_buf, xfer->len);
-	if (ret < 0)
-		return ret;
-
-	return 0;
 }
 
 static int qspi_transfer_out(struct rspi_data *rspi, struct spi_transfer *xfer)