]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
spi: dw: Fix dynamic speed change.
authorThor Thayer <tthayer@opensource.altera.com>
Thu, 6 Nov 2014 19:54:27 +0000 (13:54 -0600)
committerJiri Slaby <jslaby@suse.cz>
Sat, 6 Dec 2014 14:18:23 +0000 (15:18 +0100)
commit982b1001490f09f2a8810775a6c237d6b8e626f2
tree5caebd03f1b10224641a9b979a568b97f6baaf09
parent0a915349e2da9a0d2a9467934234c97ce855f733
spi: dw: Fix dynamic speed change.

commit 0a8727e69778683495058852f783eeda141a754e upstream.

An IOCTL call that calls spi_setup() and then dw_spi_setup() will
overwrite the persisted last transfer speed. On each transfer, the
SPI speed is compared to the last transfer speed to determine if the
clock divider registers need to be updated (did the speed change?).
This bug was observed with the spidev driver using spi-config to
update the max transfer speed.

This fix: Don't overwrite the persisted last transaction clock speed
when updating the SPI parameters in dw_spi_setup(). On the next
transaction, the new speed won't match the persisted last speed
and the hardware registers will be updated.
On initialization, the persisted last transaction clock
speed will be 0 but will be updated after the first SPI
transaction.

Move zeroed clock divider check into clock change test because
chip->clk_div is zero on startup and would cause a divide-by-zero
error. The calculation was wrong as well (can't support odd #).

Reported-by: Vlastimil Setka <setka@vsis.cz>
Signed-off-by: Vlastimil Setka <setka@vsis.cz>
Signed-off-by: Thor Thayer <tthayer@opensource.altera.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/spi/spi-dw.c