aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorMartin Sperl <kernel@martin.sperl.org>2015-04-16 03:51:26 -0400
committerMark Brown <broonie@kernel.org>2015-04-16 13:57:07 -0400
commit145367baa492246cc19d7e859db642e6fed6908e (patch)
tree713217fda7f25e2cb4dfb91f4929e5ebe8663095 /drivers/spi
parent56afdb70ca9140cdcbdcf01870f3e4e2e8be17f5 (diff)
spi: bcm2835: change timeout of polling driver to 1s
The way that the timeout code is written in the polling function the timeout does also trigger when interrupted or rescheduled while in the polling loop. This patch changes the timeout from effectively 20ms (=2 jiffies) to 1 second and removes the time that the transfer really takes out of the computation, as - per design - this is <30us and the jiffie resolution is 10ms so that does not make any difference what so ever. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-bcm2835.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index f63864a893c5..37875cf942f7 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -164,13 +164,12 @@ static int bcm2835_spi_transfer_one_poll(struct spi_master *master,
164 unsigned long xfer_time_us) 164 unsigned long xfer_time_us)
165{ 165{
166 struct bcm2835_spi *bs = spi_master_get_devdata(master); 166 struct bcm2835_spi *bs = spi_master_get_devdata(master);
167 unsigned long timeout = jiffies + 167 /* set timeout to 1 second of maximum polling */
168 max(4 * xfer_time_us * HZ / 1000000, 2uL); 168 unsigned long timeout = jiffies + HZ;
169 169
170 /* enable HW block without interrupts */ 170 /* enable HW block without interrupts */
171 bcm2835_wr(bs, BCM2835_SPI_CS, cs | BCM2835_SPI_CS_TA); 171 bcm2835_wr(bs, BCM2835_SPI_CS, cs | BCM2835_SPI_CS_TA);
172 172
173 /* set timeout to 4x the expected time, or 2 jiffies */
174 /* loop until finished the transfer */ 173 /* loop until finished the transfer */
175 while (bs->rx_len) { 174 while (bs->rx_len) {
176 /* read from fifo as much as possible */ 175 /* read from fifo as much as possible */