From: Mark Brown <broonie@kernel.org>
To: "Lh Kuo 郭力豪" <lh.Kuo@sunplus.com>
Cc: "Tom Rix" <trix@redhat.com>, "Li-hao Kuo" <lhjeff911@gmail.com>,
"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Wells Lu 呂芳騰" <wells.lu@sunplus.com>
Subject: Re: [PATCH] spi: Fix warning for Clang build
Date: Fri, 11 Feb 2022 11:57:15 +0000 [thread overview]
Message-ID: <YgZPGyMjJ10eK/SG@sirena.org.uk> (raw)
In-Reply-To: <0b71842ec1b946729e74d73cbd354162@sphcmbx02.sunplus.com.tw>
[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]
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.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2022-02-11 11:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-10 2:36 Li-hao Kuo
2022-02-10 11:17 ` Mark Brown
2022-02-11 3:32 ` Lh Kuo 郭力豪
2022-02-11 4:49 ` Tom Rix
2022-02-11 4:59 ` Lh Kuo 郭力豪
2022-02-11 11:57 ` Mark Brown [this message]
2022-02-13 18:11 ` Nathan Chancellor
2022-02-14 2:23 ` Lh Kuo 郭力豪
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YgZPGyMjJ10eK/SG@sirena.org.uk \
--to=broonie@kernel.org \
--cc=lh.Kuo@sunplus.com \
--cc=lhjeff911@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=trix@redhat.com \
--cc=wells.lu@sunplus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®