From: Vignesh R <vigneshr@ti.com>
To: Mark Brown <broonie@kernel.org>
Cc: <linux-spi@vger.kernel.org>, <linux-omap@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Vignesh R <vigneshr@ti.com>
Subject: [PATCH v2 1/3] spi: return error if kmap'd buffers passed to spi_map_buf()
Date: Mon, 25 Apr 2016 15:14:00 +0530 [thread overview]
Message-ID: <1461577442-8853-2-git-send-email-vigneshr@ti.com> (raw)
In-Reply-To: <1461577442-8853-1-git-send-email-vigneshr@ti.com>
Current spi_map_buf() implementation supports creates sg_table for
vmalloc'd and kmalloc'd buffers. Therefore return error if kmap'd buffer
(or any other buffer) is passed to spi_map_buf().
Signed-off-by: Vignesh R <vigneshr@ti.com>
---
v2: New patch
drivers/spi/spi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index a7ab330d0640..82126bbe69cf 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -717,9 +717,11 @@ static int spi_map_buf(struct spi_master *master, struct device *dev,
if (vmalloced_buf) {
desc_len = min_t(int, max_seg_size, PAGE_SIZE);
sgs = DIV_ROUND_UP(len + offset_in_page(buf), desc_len);
- } else {
+ } else if (virt_addr_valid(buf)) {
desc_len = min_t(int, max_seg_size, master->max_dma_len);
sgs = DIV_ROUND_UP(len, desc_len);
+ } else {
+ return -EINVAL;
}
ret = sg_alloc_table(sgt, sgs, GFP_KERNEL);
--
2.8.1
next prev parent reply other threads:[~2016-04-25 9:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-25 9:43 [PATCH v2 0/3] spi: Add DMA support for ti-qspi Vignesh R
2016-04-25 9:44 ` Vignesh R [this message]
2016-04-25 17:57 ` Applied "spi: return error if kmap'd buffers passed to spi_map_buf()" to the spi tree Mark Brown
2016-04-25 9:44 ` [PATCH v2 2/3] spi: Add DMA support for spi_flash_read() Vignesh R
2016-06-08 9:25 ` Applied "spi: Add DMA support for spi_flash_read()" to the spi tree Mark Brown
2016-06-08 9:27 ` Vignesh R
2016-04-25 9:44 ` [PATCH v2 3/3] spi: spi-ti-qspi: Add DMA support for QSPI mmap read Vignesh R
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=1461577442-8853-2-git-send-email-vigneshr@ti.com \
--to=vigneshr@ti.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).