LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] atmel_spi: support zero length transfer (resend)
@ 2008-03-29 15:11 Atsushi Nemoto
2008-03-29 16:56 ` Haavard Skinnemoen
0 siblings, 1 reply; 3+ messages in thread
From: Atsushi Nemoto @ 2008-03-29 15:11 UTC (permalink / raw)
To: Haavard Skinnemoen
Cc: David Brownell, spi-devel-general, linux-kernel, akpm,
marc.pignat, nforrester
A spi transfer with zero length is not invalid. For example, such
transfer (len == 0 && delay_usecs != 0) can be used to achieve delay
before first CLK edge after chipselect assertion.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
Though some discussion about zero length transfer were raised by this
patch last time, I think there were no explicit objection to this
patch itself.
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 293b7ca..5dff5e0 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -606,7 +606,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *msg)
return -ESHUTDOWN;
list_for_each_entry(xfer, &msg->transfers, transfer_list) {
- if (!(xfer->tx_buf || xfer->rx_buf)) {
+ if (!(xfer->tx_buf || xfer->rx_buf) && xfer->len) {
dev_dbg(&spi->dev, "missing rx or tx buf\n");
return -EINVAL;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] atmel_spi: support zero length transfer (resend)
2008-03-29 15:11 [PATCH] atmel_spi: support zero length transfer (resend) Atsushi Nemoto
@ 2008-03-29 16:56 ` Haavard Skinnemoen
2008-03-30 12:29 ` Atsushi Nemoto
0 siblings, 1 reply; 3+ messages in thread
From: Haavard Skinnemoen @ 2008-03-29 16:56 UTC (permalink / raw)
To: Atsushi Nemoto
Cc: David Brownell, spi-devel-general, linux-kernel, akpm,
marc.pignat, nforrester
Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> A spi transfer with zero length is not invalid. For example, such
> transfer (len == 0 && delay_usecs != 0) can be used to achieve delay
> before first CLK edge after chipselect assertion.
>
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> ---
> Though some discussion about zero length transfer were raised by this
> patch last time, I think there were no explicit objection to this
> patch itself.
Well, the patch doesn't seem to do any harm, but I can't see much of a
point to it either if zero-length transfers aren't going to be
allowed...
Also, if the length is zero, the driver will end up doing a memset with
length zero at some point. Is that allowed?
Haavard
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] atmel_spi: support zero length transfer (resend)
2008-03-29 16:56 ` Haavard Skinnemoen
@ 2008-03-30 12:29 ` Atsushi Nemoto
0 siblings, 0 replies; 3+ messages in thread
From: Atsushi Nemoto @ 2008-03-30 12:29 UTC (permalink / raw)
To: haavard.skinnemoen
Cc: david-b, spi-devel-general, linux-kernel, akpm, marc.pignat, nforrester
On Sat, 29 Mar 2008 17:56:51 +0100, Haavard Skinnemoen <haavard.skinnemoen@atmel.com> wrote:
> > Though some discussion about zero length transfer were raised by this
> > patch last time, I think there were no explicit objection to this
> > patch itself.
>
> Well, the patch doesn't seem to do any harm, but I can't see much of a
> point to it either if zero-length transfers aren't going to be
> allowed...
Well, some wired device might want long delay before first CLK edge.
I think most device do not have such constraint, but ...
Anyway, SPI framework does not reject it. So I think the controller
driver should accept it unless it is hard to support on that hardware.
> Also, if the length is zero, the driver will end up doing a memset with
> length zero at some point. Is that allowed?
I believe memset() with zero length should be allowed. It seems
ambiguous that dma_sync_single_for_device() with zero length is legal
or not. Actually, it seems OK on ARM and AVR32.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-03-30 12:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-29 15:11 [PATCH] atmel_spi: support zero length transfer (resend) Atsushi Nemoto
2008-03-29 16:56 ` Haavard Skinnemoen
2008-03-30 12:29 ` Atsushi Nemoto
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).