[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YgZPGyMjJ10eK/SG@sirena.org.uk>
Date: Fri, 11 Feb 2022 11:57:15 +0000
From: Mark Brown <broonie@...nel.org>
To: Lh Kuo 郭力豪 <lh.Kuo@...plus.com>
Cc: Tom Rix <trix@...hat.com>, Li-hao Kuo <lhjeff911@...il.com>,
"linux-spi@...r.kernel.org" <linux-spi@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Wells Lu 呂芳騰 <wells.lu@...plus.com>
Subject: Re: [PATCH] spi: Fix warning for Clang build
On Fri, Feb 11, 2022 at 04:59:00AM +0000, Lh Kuo 郭力豪 wrote:
> Yes. I think the function can be simplified as follows
> static int sp7021_spi_slave_transfer_one(struct spi_controller *ctlr, struct spi_device *spi,
> struct spi_transfer *xfer)
> {
> struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr);
> struct device *dev = pspim->dev;
> int ret;
>
> mode = SP7021_SPI_IDLE;
> if (xfer->tx_buf && xfer->rx_buf) {
> dev_dbg(&ctlr->dev, "%s() wrong command\n", __func__);
> return -EINVAL;
Since only unidirectional transfers are supported...
> } else if (xfer->tx_buf) {
> xfer->tx_dma = dma_map_single(dev, (void *)xfer->tx_buf,
> xfer->len, DMA_TO_DEVICE);
> if (dma_mapping_error(dev, xfer->tx_dma))
> return -ENOMEM;
> ret = sp7021_spi_slave_tx(spi, xfer);
> } else if (xfer->rx_buf) {
> xfer->rx_dma = dma_map_single(dev, xfer->rx_buf, xfer->len,
> DMA_FROM_DEVICE);
> if (dma_mapping_error(dev, xfer->rx_dma))
> return -ENOMEM;
> ret = sp7021_spi_slave_rx(spi, xfer);
> }
>
> if (xfer->tx_buf)
> dma_unmap_single(dev, xfer->tx_dma, xfer->len, DMA_TO_DEVICE);
> if (xfer->rx_buf)
> dma_unmap_single(dev, xfer->rx_dma, xfer->len, DMA_FROM_DEVICE);
...you could even fold the unmapping into the if/else tree above.
Otherwise this looks good to me, please send a patch.
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists