All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 2.6.28-rc9] spi: spi_write_then_read() regression fix
@ 2008-12-21  7:32 ` David Brownell
  0 siblings, 0 replies; 19+ messages in thread
From: David Brownell @ 2008-12-21  7:32 UTC (permalink / raw)
  To: Andrew Morton, spi-devel-general; +Cc: lkml, Linus Torvalds, Vernon Sauder

From: David Brownell <dbrownell@users.sourceforge.net>

The recent "simplify spi_write_then_read()" patch included a small
regression from the 2.6.27 behavior with its performance win.

All SPI transfers are full duplex, and are packaged as half duplex
by either discarding the data that's read ("write only"), or else
by writing zeroes ("read only").  That patch wasn't ensuring that
zeroes were getting written out during the "half duplex read" part
of the transaction; instead, old RX bits were getting sent.

The fix is trivial:  zero the buffer before using it.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Vernon Sauder <vernoninhand@gmail.com>

--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -677,11 +677,13 @@ int spi_write_then_read(struct spi_device *spi,
 
 	/* ... unless someone else is using the pre-allocated buffer */
 	if (!mutex_trylock(&lock)) {
-		local_buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL);
+		local_buf = kzalloc(SPI_BUFSIZ, GFP_KERNEL);
 		if (!local_buf)
 			return -ENOMEM;
-	} else
+	} else {
 		local_buf = buf;
+		memset(local_buf, 0, x.len);
+	}
 
 	memcpy(local_buf, txbuf, n_tx);
 	x.tx_buf = local_buf;

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2008-12-25  7:03 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-21  7:32 [patch 2.6.28-rc9] spi: spi_write_then_read() regression fix David Brownell
2008-12-21  7:32 ` David Brownell
2008-12-21 23:46 ` Linus Torvalds
2008-12-21 23:46   ` Linus Torvalds
2008-12-22  0:48   ` David Brownell
2008-12-23  1:53     ` Ingo Oeser
2008-12-23 18:37       ` David Brownell
2008-12-23 18:37         ` David Brownell
2008-12-23 18:45     ` Linus Torvalds
2008-12-23 18:45       ` Linus Torvalds
2008-12-23 20:54       ` David Brownell
2008-12-23 20:54         ` David Brownell
     [not found]         ` <200812231254.55284.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-12-24  3:26           ` Tang, Feng
     [not found]             ` <EADF0A36011179459010BDF5142A45750458C7DD-Uz4Je35TzWuiAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2008-12-24  3:53               ` David Brownell
     [not found]                 ` <200812231953.26407.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-12-24  4:20                   ` Tang, Feng
     [not found]                     ` <EADF0A36011179459010BDF5142A45750458C815-Uz4Je35TzWuiAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2008-12-24  8:39                       ` David Brownell
     [not found]                         ` <200812240039.32008.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-12-24  8:58                           ` Baruch Siach
     [not found]                             ` <20081224085844.GA11197-l+PWtdWbHAs2zBO71LVbc/qBs+8SCbDb@public.gmane.org>
2008-12-24 19:43                               ` David Brownell
2008-12-25  7:03                           ` Tang, Feng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.