* [PATCH 2/7] spi: atmel: Let spi core validate Tx/Rx buffers for non-zero length transfer
2014-03-19 3:53 [PATCH 1/7] spi: core: Validate Tx/Rx buffers for non-zero length transfer Axel Lin
@ 2014-03-19 3:55 ` Axel Lin
2014-03-19 4:01 ` Yang, Wenyou
2014-03-19 3:56 ` [PATCH 3/7] spi: omap-100k: " Axel Lin
` (5 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Axel Lin @ 2014-03-19 3:55 UTC (permalink / raw)
To: Mark Brown; +Cc: Wenyou Yang, linux-spi-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org>
---
drivers/spi/spi-atmel.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index bda961e..c54492b 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1065,11 +1065,6 @@ static int atmel_spi_one_transfer(struct spi_master *master,
as = spi_master_get_devdata(master);
- if (!(xfer->tx_buf || xfer->rx_buf) && xfer->len) {
- dev_dbg(&spi->dev, "missing rx or tx buf\n");
- return -EINVAL;
- }
-
if (xfer->bits_per_word) {
asd = spi->controller_state;
bits = (asd->csr >> 4) & 0xf;
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 13+ messages in thread
* RE: [PATCH 2/7] spi: atmel: Let spi core validate Tx/Rx buffers for non-zero length transfer
2014-03-19 3:55 ` [PATCH 2/7] spi: atmel: Let spi core validate " Axel Lin
@ 2014-03-19 4:01 ` Yang, Wenyou
0 siblings, 0 replies; 13+ messages in thread
From: Yang, Wenyou @ 2014-03-19 4:01 UTC (permalink / raw)
To: Axel Lin, Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1188 bytes --]
> -----Original Message-----
> From: Axel Lin [mailto:axel.lin@ingics.com]
> Sent: Wednesday, March 19, 2014 11:55 AM
> To: Mark Brown
> Cc: Yang, Wenyou; linux-spi@vger.kernel.org
> Subject: [PATCH 2/7] spi: atmel: Let spi core validate Tx/Rx buffers for
> non-zero length transfer
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Wenyou.Yang <wenyou.yang@atmel.com>
> ---
> drivers/spi/spi-atmel.c | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index
> bda961e..c54492b 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -1065,11 +1065,6 @@ static int atmel_spi_one_transfer(struct
> spi_master *master,
>
> as = spi_master_get_devdata(master);
>
> - if (!(xfer->tx_buf || xfer->rx_buf) && xfer->len) {
> - dev_dbg(&spi->dev, "missing rx or tx buf\n");
> - return -EINVAL;
> - }
> -
> if (xfer->bits_per_word) {
> asd = spi->controller_state;
> bits = (asd->csr >> 4) & 0xf;
> --
> 1.8.3.2
>
>
N§²æìr¸yúèØb²X¬¶Ç§vØ^)Þº{.nÇ+·¥{±²¢Ø^nr¡ö¦zË\x1aëh¨èÚ&¢îý»\x05ËÛÔØï¦v¬Îf\x1dp)¹¹br ê+Ê+zf£¢·h§~Ûiÿûàz¹\x1e®w¥¢¸?¨èÚ&¢)ߢ^[f
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/7] spi: omap-100k: Let spi core validate Tx/Rx buffers for non-zero length transfer
2014-03-19 3:53 [PATCH 1/7] spi: core: Validate Tx/Rx buffers for non-zero length transfer Axel Lin
2014-03-19 3:55 ` [PATCH 2/7] spi: atmel: Let spi core validate " Axel Lin
@ 2014-03-19 3:56 ` Axel Lin
2014-03-19 3:57 ` [PATCH 4/7] spi: omap2-mcspi: " Axel Lin
` (4 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Axel Lin @ 2014-03-19 3:56 UTC (permalink / raw)
To: Mark Brown; +Cc: Fabrice Crohas, linux-spi-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org>
---
drivers/spi/spi-omap-100k.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c
index c9e2282..05069ee 100644
--- a/drivers/spi/spi-omap-100k.c
+++ b/drivers/spi/spi-omap-100k.c
@@ -324,10 +324,6 @@ static int omap1_spi100k_transfer_one_message(struct spi_master *master,
int status = 0;
list_for_each_entry(t, &m->transfers, transfer_list) {
- if (t->tx_buf == NULL && t->rx_buf == NULL && t->len) {
- status = -EINVAL;
- break;
- }
if (par_override || t->speed_hz || t->bits_per_word) {
par_override = 1;
status = omap1_spi100k_setup_transfer(spi, t);
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/7] spi: omap2-mcspi: Let spi core validate Tx/Rx buffers for non-zero length transfer
2014-03-19 3:53 [PATCH 1/7] spi: core: Validate Tx/Rx buffers for non-zero length transfer Axel Lin
2014-03-19 3:55 ` [PATCH 2/7] spi: atmel: Let spi core validate " Axel Lin
2014-03-19 3:56 ` [PATCH 3/7] spi: omap-100k: " Axel Lin
@ 2014-03-19 3:57 ` Axel Lin
2014-03-19 3:58 ` [PATCH 5/7] spi: txx9: " Axel Lin
` (3 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Axel Lin @ 2014-03-19 3:57 UTC (permalink / raw)
To: Mark Brown; +Cc: Illia Smyrnov, linux-spi-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org>
---
drivers/spi/spi-omap2-mcspi.c | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 2941c5b..a0746a7 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1081,10 +1081,6 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m)
omap2_mcspi_set_enable(spi, 0);
list_for_each_entry(t, &m->transfers, transfer_list) {
- if (t->tx_buf == NULL && t->rx_buf == NULL && t->len) {
- status = -EINVAL;
- break;
- }
if (par_override ||
(t->speed_hz != spi->max_speed_hz) ||
(t->bits_per_word != spi->bits_per_word)) {
@@ -1212,16 +1208,6 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master,
void *rx_buf = t->rx_buf;
unsigned len = t->len;
- if ((len && !(rx_buf || tx_buf))) {
- dev_dbg(mcspi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n",
- t->speed_hz,
- len,
- tx_buf ? "tx" : "",
- rx_buf ? "rx" : "",
- t->bits_per_word);
- return -EINVAL;
- }
-
if (m->is_dma_mapped || len < DMA_MIN_BYTES)
continue;
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/7] spi: txx9: Let spi core validate Tx/Rx buffers for non-zero length transfer
2014-03-19 3:53 [PATCH 1/7] spi: core: Validate Tx/Rx buffers for non-zero length transfer Axel Lin
` (2 preceding siblings ...)
2014-03-19 3:57 ` [PATCH 4/7] spi: omap2-mcspi: " Axel Lin
@ 2014-03-19 3:58 ` Axel Lin
2014-03-19 3:59 ` [PATCH 6/7] spi: xcomm: " Axel Lin
` (2 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Axel Lin @ 2014-03-19 3:58 UTC (permalink / raw)
To: Mark Brown; +Cc: Atsushi Nemoto, linux-spi-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org>
---
drivers/spi/spi-txx9.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/drivers/spi/spi-txx9.c b/drivers/spi/spi-txx9.c
index 820b499..10ffbc0 100644
--- a/drivers/spi/spi-txx9.c
+++ b/drivers/spi/spi-txx9.c
@@ -299,17 +299,10 @@ static int txx9spi_transfer(struct spi_device *spi, struct spi_message *m)
{
struct spi_master *master = spi->master;
struct txx9spi *c = spi_master_get_devdata(master);
- struct spi_transfer *t;
unsigned long flags;
m->actual_length = 0;
- /* check each transfer's parameters */
- list_for_each_entry(t, &m->transfers, transfer_list) {
- if (!t->tx_buf && !t->rx_buf && t->len)
- return -EINVAL;
- }
-
spin_lock_irqsave(&c->lock, flags);
list_add_tail(&m->queue, &c->queue);
queue_work(c->workqueue, &c->work);
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/7] spi: xcomm: Let spi core validate Tx/Rx buffers for non-zero length transfer
2014-03-19 3:53 [PATCH 1/7] spi: core: Validate Tx/Rx buffers for non-zero length transfer Axel Lin
` (3 preceding siblings ...)
2014-03-19 3:58 ` [PATCH 5/7] spi: txx9: " Axel Lin
@ 2014-03-19 3:59 ` Axel Lin
2014-03-19 7:39 ` Lars-Peter Clausen
2014-03-19 4:00 ` [PATCH 7/7] spi: bitbang: " Axel Lin
2014-03-19 8:06 ` [PATCH 1/7] spi: core: Validate " Geert Uytterhoeven
6 siblings, 1 reply; 13+ messages in thread
From: Axel Lin @ 2014-03-19 3:59 UTC (permalink / raw)
To: Mark Brown; +Cc: Lars-Peter Clausen, linux-spi-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org>
---
drivers/spi/spi-xcomm.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c
index bb478dc..736a488 100644
--- a/drivers/spi/spi-xcomm.c
+++ b/drivers/spi/spi-xcomm.c
@@ -149,11 +149,6 @@ static int spi_xcomm_transfer_one(struct spi_master *master,
list_for_each_entry(t, &msg->transfers, transfer_list) {
- if (!t->tx_buf && !t->rx_buf && t->len) {
- status = -EINVAL;
- break;
- }
-
status = spi_xcomm_setup_transfer(spi_xcomm, spi, t, &settings);
if (status < 0)
break;
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 7/7] spi: bitbang: Let spi core validate Tx/Rx buffers for non-zero length transfer
2014-03-19 3:53 [PATCH 1/7] spi: core: Validate Tx/Rx buffers for non-zero length transfer Axel Lin
` (4 preceding siblings ...)
2014-03-19 3:59 ` [PATCH 6/7] spi: xcomm: " Axel Lin
@ 2014-03-19 4:00 ` Axel Lin
2014-03-19 8:06 ` [PATCH 1/7] spi: core: Validate " Geert Uytterhoeven
6 siblings, 0 replies; 13+ messages in thread
From: Axel Lin @ 2014-03-19 4:00 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org>
---
drivers/spi/spi-bitbang.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c
index 3bfdb85..4beabea 100644
--- a/drivers/spi/spi-bitbang.c
+++ b/drivers/spi/spi-bitbang.c
@@ -317,10 +317,6 @@ static int spi_bitbang_transfer_one(struct spi_master *master,
ndelay(nsecs);
}
cs_change = t->cs_change;
- if (!t->tx_buf && !t->rx_buf && t->len) {
- status = -EINVAL;
- break;
- }
/* transfer data. the lower level code handles any
* new dma mappings it needs. our caller always gave
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/7] spi: core: Validate Tx/Rx buffers for non-zero length transfer
2014-03-19 3:53 [PATCH 1/7] spi: core: Validate Tx/Rx buffers for non-zero length transfer Axel Lin
` (5 preceding siblings ...)
2014-03-19 4:00 ` [PATCH 7/7] spi: bitbang: " Axel Lin
@ 2014-03-19 8:06 ` Geert Uytterhoeven
[not found] ` <CAMuHMdWCdp_SW5CNt50cSfG700JRU3tr=Pbyhv8nv-1Ve=XUNw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
6 siblings, 1 reply; 13+ messages in thread
From: Geert Uytterhoeven @ 2014-03-19 8:06 UTC (permalink / raw)
To: Axel Lin
Cc: Mark Brown, Wenyou Yang, Fabrice Crohas, Illia Smyrnov,
Atsushi Nemoto, Lars-Peter Clausen, linux-spi
On Wed, Mar 19, 2014 at 4:53 AM, Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org> wrote:
> Reject transfer if both tx_buf and rx_buf are NULL for non-zero length transfer.
> Add the checking in spi core so we can remove the same checking in various
> drivers.
Just wondering: are there any SPI slave drivers that implement dummy cycles
this way?
> Signed-off-by: Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org>
> ---
> drivers/spi/spi.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 26b331d..0a29d2a 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -1876,6 +1876,10 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
> if (xfer->len % w_size)
> return -EINVAL;
>
> + /* non-zero length transfer must has tx_buf or rx_buf */
have
> + if (xfer->len && !xfer->tx_buf && !xfer->rx_buf)
> + return -EINVAL;
> +
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 13+ messages in thread