spi: Correct SPI clock frequency setting in spi_mpc8xxx
diff mbox

Message ID 20100215172304.66663326.eschwab@online.de
State Accepted
Headers show

Commit Message

Ernst Schwab Feb. 15, 2010, 4:23 p.m. UTC
None

Patch
diff mbox

diff -up linux-2.6.33-rc8.orig/drivers/spi/spi_mpc8xxx.c linux-2.6.33-rc8/drivers/spi/spi_mpc8xxx.c
--- linux-2.6.33-rc8.orig/drivers/spi/spi_mpc8xxx.c	2010-02-12 20:07:45.000000000 +0100
+++ linux-2.6.33-rc8/drivers/spi/spi_mpc8xxx.c	2010-02-15 14:08:33.000000000 +0100
@@ -365,7 +365,7 @@  int mpc8xxx_spi_setup_transfer(struct sp
 
 	if ((mpc8xxx_spi->spibrg / hz) > 64) {
 		cs->hw_mode |= SPMODE_DIV16;
-		pm = mpc8xxx_spi->spibrg / (hz * 64);
+		pm = (mpc8xxx_spi->spibrg - 1) / (hz * 64) + 1;
 
 		WARN_ONCE(pm > 16, "%s: Requested speed is too low: %d Hz. "
 			  "Will use %d Hz instead.\n", dev_name(&spi->dev),
@@ -373,7 +373,7 @@  int mpc8xxx_spi_setup_transfer(struct sp
 		if (pm > 16)
 			pm = 16;
 	} else
-		pm = mpc8xxx_spi->spibrg / (hz * 4);
+		pm = (mpc8xxx_spi->spibrg - 1) / (hz * 4) + 1;
 	if (pm)
 		pm--;