diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-12-06 17:00:33 +0000 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-12-06 17:00:33 +0000 |
commit | 3d14b5beba35250c548d3851a2b84fce742d8311 (patch) | |
tree | 065e3d93c3fcbc5ee4c44fa78662393cddbdf6de /drivers/spi | |
parent | 0719dc341389882cc834ed18fc9b7fc6006b2b85 (diff) | |
parent | 1bf8e6219552d5dd27012d567ec8c4bb9c2d86b4 (diff) | |
download | linux-stable-3d14b5beba35250c548d3851a2b84fce742d8311.tar.gz linux-stable-3d14b5beba35250c548d3851a2b84fce742d8311.tar.bz2 linux-stable-3d14b5beba35250c548d3851a2b84fce742d8311.zip |
Merge branch 'sa1100' into devel
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi_txx9.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/spi/spi_txx9.c b/drivers/spi/spi_txx9.c index 96057de133ad..19f75627c3de 100644 --- a/drivers/spi/spi_txx9.c +++ b/drivers/spi/spi_txx9.c @@ -29,6 +29,8 @@ #define SPI_FIFO_SIZE 4 +#define SPI_MAX_DIVIDER 0xff /* Max. value for SPCR1.SER */ +#define SPI_MIN_DIVIDER 1 /* Min. value for SPCR1.SER */ #define TXx9_SPMCR 0x00 #define TXx9_SPCR0 0x04 @@ -193,11 +195,8 @@ static void txx9spi_work_one(struct txx9spi *c, struct spi_message *m) if (prev_speed_hz != speed_hz || prev_bits_per_word != bits_per_word) { - u32 n = (c->baseclk + speed_hz - 1) / speed_hz; - if (n < 1) - n = 1; - else if (n > 0xff) - n = 0xff; + int n = DIV_ROUND_UP(c->baseclk, speed_hz) - 1; + n = clamp(n, SPI_MIN_DIVIDER, SPI_MAX_DIVIDER); /* enter config mode */ txx9spi_wr(c, mcr | TXx9_SPMCR_CONFIG | TXx9_SPMCR_BCLR, TXx9_SPMCR); @@ -370,8 +369,8 @@ static int __init txx9spi_probe(struct platform_device *dev) goto exit; } c->baseclk = clk_get_rate(c->clk); - c->min_speed_hz = (c->baseclk + 0xff - 1) / 0xff; - c->max_speed_hz = c->baseclk; + c->min_speed_hz = DIV_ROUND_UP(c->baseclk, SPI_MAX_DIVIDER + 1); + c->max_speed_hz = c->baseclk / (SPI_MIN_DIVIDER + 1); res = platform_get_resource(dev, IORESOURCE_MEM, 0); if (!res) |