Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1526376 > unrolled thread
| Started by | Sanchayan Maity <maitysanchayan@gmail.com> |
|---|---|
| First post | 2016-11-21 07:10 +0100 |
| Last post | 2016-11-22 07:30 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 4/4] spi: spi-fsl-dspi: Minor code cleanup and error path fixes Sanchayan Maity <maitysanchayan@gmail.com> - 2016-11-21 07:10 +0100
Re: [PATCH v2 4/4] spi: spi-fsl-dspi: Minor code cleanup and error path fixes Stefan Agner <stefan@agner.ch> - 2016-11-22 00:30 +0100
Re: [PATCH v2 4/4] spi: spi-fsl-dspi: Minor code cleanup and error path fixes maitysanchayan@gmail.com - 2016-11-22 07:30 +0100
| From | Sanchayan Maity <maitysanchayan@gmail.com> |
|---|---|
| Date | 2016-11-21 07:10 +0100 |
| Subject | [PATCH v2 4/4] spi: spi-fsl-dspi: Minor code cleanup and error path fixes |
| Message-ID | <sFPXI-5Q1-1@gated-at.bofh.it> |
Code cleanup for improving code readability and error path fixes
and cleanup removing use of devm_kfree.
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
drivers/spi/spi-fsl-dspi.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 08882f7..2987a16 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -226,8 +226,10 @@ static void dspi_rx_dma_callback(void *arg)
if (!(dspi->dataflags & TRAN_STATE_RX_VOID)) {
for (i = 0; i < dma->curr_xfer_len; i++) {
d = dspi->dma->rx_dma_buf[i];
- rx_word ? (*(u16 *)dspi->rx = d) :
- (*(u8 *)dspi->rx = d);
+ if (rx_word)
+ *(u16 *)dspi->rx = d;
+ else
+ *(u8 *)dspi->rx = d;
dspi->rx += rx_word + 1;
}
}
@@ -247,14 +249,20 @@ static int dspi_next_xfer_dma_submit(struct fsl_dspi *dspi)
tx_word = is_double_byte_mode(dspi);
for (i = 0; i < dma->curr_xfer_len - 1; i++) {
- val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx;
+ if (tx_word)
+ val = *(u16 *) dspi->tx;
+ else
+ val = *(u8 *) dspi->tx;
dspi->dma->tx_dma_buf[i] =
SPI_PUSHR_TXDATA(val) | SPI_PUSHR_PCS(dspi->cs) |
SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
dspi->tx += tx_word + 1;
}
- val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx;
+ if (tx_word)
+ val = *(u16 *) dspi->tx;
+ else
+ val = *(u8 *) dspi->tx;
dspi->dma->tx_dma_buf[i] = SPI_PUSHR_TXDATA(val) |
SPI_PUSHR_PCS(dspi->cs) |
SPI_PUSHR_CTAS(0);
@@ -430,9 +438,11 @@ static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr)
return 0;
err_slave_config:
- devm_kfree(dev, dma->rx_dma_buf);
+ dma_free_coherent(dev, DSPI_DMA_BUFSIZE,
+ dma->rx_dma_buf, dma->rx_dma_phys);
err_rx_dma_buf:
- devm_kfree(dev, dma->tx_dma_buf);
+ dma_free_coherent(dev, DSPI_DMA_BUFSIZE,
+ dma->tx_dma_buf, dma->tx_dma_phys);
err_tx_dma_buf:
dma_release_channel(dma->chan_tx);
err_tx_channel:
--
2.10.2
[toc] | [next] | [standalone]
| From | Stefan Agner <stefan@agner.ch> |
|---|---|
| Date | 2016-11-22 00:30 +0100 |
| Subject | Re: [PATCH v2 4/4] spi: spi-fsl-dspi: Minor code cleanup and error path fixes |
| Message-ID | <sG6c9-7IX-3@gated-at.bofh.it> |
| In reply to | #1526376 |
On 2016-11-20 21:54, Sanchayan Maity wrote:
> Code cleanup for improving code readability and error path fixes
> and cleanup removing use of devm_kfree.
Two things in one, not very nice. Especially the dma_free_coherent is
really a bug and the other is a cleanup. Can you make a separate patch
for the bug?
As for the cleanup, I don't like the one line conditions too, but I
don't think it is worth a patch. At least the TX path should be solved
with my suggestion in patch 2.
--
Stefan
>
> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> ---
> drivers/spi/spi-fsl-dspi.c | 22 ++++++++++++++++------
> 1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
> index 08882f7..2987a16 100644
> --- a/drivers/spi/spi-fsl-dspi.c
> +++ b/drivers/spi/spi-fsl-dspi.c
> @@ -226,8 +226,10 @@ static void dspi_rx_dma_callback(void *arg)
> if (!(dspi->dataflags & TRAN_STATE_RX_VOID)) {
> for (i = 0; i < dma->curr_xfer_len; i++) {
> d = dspi->dma->rx_dma_buf[i];
> - rx_word ? (*(u16 *)dspi->rx = d) :
> - (*(u8 *)dspi->rx = d);
> + if (rx_word)
> + *(u16 *)dspi->rx = d;
> + else
> + *(u8 *)dspi->rx = d;
> dspi->rx += rx_word + 1;
> }
> }
> @@ -247,14 +249,20 @@ static int dspi_next_xfer_dma_submit(struct
> fsl_dspi *dspi)
> tx_word = is_double_byte_mode(dspi);
>
> for (i = 0; i < dma->curr_xfer_len - 1; i++) {
> - val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx;
> + if (tx_word)
> + val = *(u16 *) dspi->tx;
> + else
> + val = *(u8 *) dspi->tx;
> dspi->dma->tx_dma_buf[i] =
> SPI_PUSHR_TXDATA(val) | SPI_PUSHR_PCS(dspi->cs) |
> SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
> dspi->tx += tx_word + 1;
> }
>
> - val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx;
> + if (tx_word)
> + val = *(u16 *) dspi->tx;
> + else
> + val = *(u8 *) dspi->tx;
> dspi->dma->tx_dma_buf[i] = SPI_PUSHR_TXDATA(val) |
> SPI_PUSHR_PCS(dspi->cs) |
> SPI_PUSHR_CTAS(0);
> @@ -430,9 +438,11 @@ static int dspi_request_dma(struct fsl_dspi
> *dspi, phys_addr_t phy_addr)
> return 0;
>
> err_slave_config:
> - devm_kfree(dev, dma->rx_dma_buf);
> + dma_free_coherent(dev, DSPI_DMA_BUFSIZE,
> + dma->rx_dma_buf, dma->rx_dma_phys);
> err_rx_dma_buf:
> - devm_kfree(dev, dma->tx_dma_buf);
> + dma_free_coherent(dev, DSPI_DMA_BUFSIZE,
> + dma->tx_dma_buf, dma->tx_dma_phys);
> err_tx_dma_buf:
> dma_release_channel(dma->chan_tx);
> err_tx_channel:
[toc] | [prev] | [next] | [standalone]
| From | maitysanchayan@gmail.com |
|---|---|
| Date | 2016-11-22 07:30 +0100 |
| Subject | Re: [PATCH v2 4/4] spi: spi-fsl-dspi: Minor code cleanup and error path fixes |
| Message-ID | <sGcKC-3ym-7@gated-at.bofh.it> |
| In reply to | #1527126 |
On 16-11-21 15:22:09, Stefan Agner wrote:
> On 2016-11-20 21:54, Sanchayan Maity wrote:
> > Code cleanup for improving code readability and error path fixes
> > and cleanup removing use of devm_kfree.
>
> Two things in one, not very nice. Especially the dma_free_coherent is
> really a bug and the other is a cleanup. Can you make a separate patch
> for the bug?
>
> As for the cleanup, I don't like the one line conditions too, but I
> don't think it is worth a patch. At least the TX path should be solved
> with my suggestion in patch 2.
Agreed.
- Sanchayan.
>
> --
> Stefan
>
> >
> > Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> > ---
> > drivers/spi/spi-fsl-dspi.c | 22 ++++++++++++++++------
> > 1 file changed, 16 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
> > index 08882f7..2987a16 100644
> > --- a/drivers/spi/spi-fsl-dspi.c
> > +++ b/drivers/spi/spi-fsl-dspi.c
> > @@ -226,8 +226,10 @@ static void dspi_rx_dma_callback(void *arg)
> > if (!(dspi->dataflags & TRAN_STATE_RX_VOID)) {
> > for (i = 0; i < dma->curr_xfer_len; i++) {
> > d = dspi->dma->rx_dma_buf[i];
> > - rx_word ? (*(u16 *)dspi->rx = d) :
> > - (*(u8 *)dspi->rx = d);
> > + if (rx_word)
> > + *(u16 *)dspi->rx = d;
> > + else
> > + *(u8 *)dspi->rx = d;
> > dspi->rx += rx_word + 1;
> > }
> > }
> > @@ -247,14 +249,20 @@ static int dspi_next_xfer_dma_submit(struct
> > fsl_dspi *dspi)
> > tx_word = is_double_byte_mode(dspi);
> >
> > for (i = 0; i < dma->curr_xfer_len - 1; i++) {
> > - val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx;
> > + if (tx_word)
> > + val = *(u16 *) dspi->tx;
> > + else
> > + val = *(u8 *) dspi->tx;
> > dspi->dma->tx_dma_buf[i] =
> > SPI_PUSHR_TXDATA(val) | SPI_PUSHR_PCS(dspi->cs) |
> > SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
> > dspi->tx += tx_word + 1;
> > }
> >
> > - val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx;
> > + if (tx_word)
> > + val = *(u16 *) dspi->tx;
> > + else
> > + val = *(u8 *) dspi->tx;
> > dspi->dma->tx_dma_buf[i] = SPI_PUSHR_TXDATA(val) |
> > SPI_PUSHR_PCS(dspi->cs) |
> > SPI_PUSHR_CTAS(0);
> > @@ -430,9 +438,11 @@ static int dspi_request_dma(struct fsl_dspi
> > *dspi, phys_addr_t phy_addr)
> > return 0;
> >
> > err_slave_config:
> > - devm_kfree(dev, dma->rx_dma_buf);
> > + dma_free_coherent(dev, DSPI_DMA_BUFSIZE,
> > + dma->rx_dma_buf, dma->rx_dma_phys);
> > err_rx_dma_buf:
> > - devm_kfree(dev, dma->tx_dma_buf);
> > + dma_free_coherent(dev, DSPI_DMA_BUFSIZE,
> > + dma->tx_dma_buf, dma->tx_dma_phys);
> > err_tx_dma_buf:
> > dma_release_channel(dma->chan_tx);
> > err_tx_channel:
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web