aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/spi/spi-altera.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c
index 81b9adb6e766..453fa5ac04ad 100644
--- a/drivers/spi/spi-altera.c
+++ b/drivers/spi/spi-altera.c
@@ -150,12 +150,12 @@ static int altera_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
150 hw->imr &= ~ALTERA_SPI_CONTROL_IRRDY_MSK; 150 hw->imr &= ~ALTERA_SPI_CONTROL_IRRDY_MSK;
151 writel(hw->imr, hw->base + ALTERA_SPI_CONTROL); 151 writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
152 } else { 152 } else {
153 /* send the first byte */ 153 while (hw->count < hw->len) {
154 writel(hw_txbyte(hw, 0), hw->base + ALTERA_SPI_TXDATA);
155
156 while (1) {
157 unsigned int rxd; 154 unsigned int rxd;
158 155
156 writel(hw_txbyte(hw, hw->count),
157 hw->base + ALTERA_SPI_TXDATA);
158
159 while (!(readl(hw->base + ALTERA_SPI_STATUS) & 159 while (!(readl(hw->base + ALTERA_SPI_STATUS) &
160 ALTERA_SPI_STATUS_RRDY_MSK)) 160 ALTERA_SPI_STATUS_RRDY_MSK))
161 cpu_relax(); 161 cpu_relax();
@@ -174,14 +174,7 @@ static int altera_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
174 } 174 }
175 175
176 hw->count++; 176 hw->count++;
177
178 if (hw->count < hw->len)
179 writel(hw_txbyte(hw, hw->count),
180 hw->base + ALTERA_SPI_TXDATA);
181 else
182 break;
183 } 177 }
184
185 } 178 }
186 179
187 return hw->count * hw->bytes_per_word; 180 return hw->count * hw->bytes_per_word;