Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spi: documentation: emphasise spi_master.setup() semantics

This is a doc-only patch which I hope will reduce the number of
spi_master controller driver patches starting out with a common
implementation bug.

(As in: almost every spi_master driver I see starts out with its
version of this bug. Sigh.)

It just re-emphasizes that the setup() method may be called for one
device while a transfer is active on another ... which means that most
driver implementations shouldn't touch any registers.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

David Brownell and committed by
Linus Torvalds
6e538aaf 14fadca7

+12 -1
+6
Documentation/spi/spi-summary
··· 511 511 This sets up the device clock rate, SPI mode, and word sizes. 512 512 Drivers may change the defaults provided by board_info, and then 513 513 call spi_setup(spi) to invoke this routine. It may sleep. 514 + 514 515 Unless each SPI slave has its own configuration registers, don't 515 516 change them right away ... otherwise drivers could corrupt I/O 516 517 that's in progress for other SPI devices. 518 + 519 + ** BUG ALERT: for some reason the first version of 520 + ** many spi_master drivers seems to get this wrong. 521 + ** When you code setup(), ASSUME that the controller 522 + ** is actively processing transfers for another device. 517 523 518 524 master->transfer(struct spi_device *spi, struct spi_message *message) 519 525 This must not sleep. Its responsibility is arrange that the
+6 -1
include/linux/spi/spi.h
··· 245 245 */ 246 246 u16 dma_alignment; 247 247 248 - /* setup mode and clock, etc (spi driver may call many times) */ 248 + /* Setup mode and clock, etc (spi driver may call many times). 249 + * 250 + * IMPORTANT: this may be called when transfers to another 251 + * device are active. DO NOT UPDATE SHARED REGISTERS in ways 252 + * which could break those transfers. 253 + */ 249 254 int (*setup)(struct spi_device *spi); 250 255 251 256 /* bidirectional bulk transfers