diff options
-rw-r--r-- | drivers/spi/spi-clps711x.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c index 374ba4a48a9e..89e5ea843fd0 100644 --- a/drivers/spi/spi-clps711x.c +++ b/drivers/spi/spi-clps711x.c | |||
@@ -32,7 +32,6 @@ struct spi_clps711x_data { | |||
32 | 32 | ||
33 | u8 *tx_buf; | 33 | u8 *tx_buf; |
34 | u8 *rx_buf; | 34 | u8 *rx_buf; |
35 | int count; | ||
36 | int len; | 35 | int len; |
37 | 36 | ||
38 | int chipselect[0]; | 37 | int chipselect[0]; |
@@ -93,11 +92,12 @@ static int spi_clps711x_transfer_one_message(struct spi_master *master, | |||
93 | struct spi_clps711x_data *hw = spi_master_get_devdata(master); | 92 | struct spi_clps711x_data *hw = spi_master_get_devdata(master); |
94 | struct spi_transfer *xfer; | 93 | struct spi_transfer *xfer; |
95 | int status = 0, cs = hw->chipselect[msg->spi->chip_select]; | 94 | int status = 0, cs = hw->chipselect[msg->spi->chip_select]; |
96 | u32 data; | ||
97 | 95 | ||
98 | spi_clps711x_setup_mode(msg->spi); | 96 | spi_clps711x_setup_mode(msg->spi); |
99 | 97 | ||
100 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { | 98 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { |
99 | u8 data; | ||
100 | |||
101 | if (spi_clps711x_setup_xfer(msg->spi, xfer)) { | 101 | if (spi_clps711x_setup_xfer(msg->spi, xfer)) { |
102 | status = -EINVAL; | 102 | status = -EINVAL; |
103 | goto out_xfr; | 103 | goto out_xfr; |
@@ -107,13 +107,12 @@ static int spi_clps711x_transfer_one_message(struct spi_master *master, | |||
107 | 107 | ||
108 | reinit_completion(&hw->done); | 108 | reinit_completion(&hw->done); |
109 | 109 | ||
110 | hw->count = 0; | ||
111 | hw->len = xfer->len; | 110 | hw->len = xfer->len; |
112 | hw->tx_buf = (u8 *)xfer->tx_buf; | 111 | hw->tx_buf = (u8 *)xfer->tx_buf; |
113 | hw->rx_buf = (u8 *)xfer->rx_buf; | 112 | hw->rx_buf = (u8 *)xfer->rx_buf; |
114 | 113 | ||
115 | /* Initiate transfer */ | 114 | /* Initiate transfer */ |
116 | data = hw->tx_buf ? hw->tx_buf[hw->count] : 0; | 115 | data = hw->tx_buf ? *hw->tx_buf++ : 0; |
117 | clps_writel(data | SYNCIO_FRMLEN(8) | SYNCIO_TXFRMEN, SYNCIO); | 116 | clps_writel(data | SYNCIO_FRMLEN(8) | SYNCIO_TXFRMEN, SYNCIO); |
118 | 117 | ||
119 | wait_for_completion(&hw->done); | 118 | wait_for_completion(&hw->done); |
@@ -138,18 +137,16 @@ out_xfr: | |||
138 | static irqreturn_t spi_clps711x_isr(int irq, void *dev_id) | 137 | static irqreturn_t spi_clps711x_isr(int irq, void *dev_id) |
139 | { | 138 | { |
140 | struct spi_clps711x_data *hw = (struct spi_clps711x_data *)dev_id; | 139 | struct spi_clps711x_data *hw = (struct spi_clps711x_data *)dev_id; |
141 | u32 data; | 140 | u8 data; |
142 | 141 | ||
143 | /* Handle RX */ | 142 | /* Handle RX */ |
144 | data = clps_readb(SYNCIO); | 143 | data = clps_readb(SYNCIO); |
145 | if (hw->rx_buf) | 144 | if (hw->rx_buf) |
146 | hw->rx_buf[hw->count] = (u8)data; | 145 | *hw->rx_buf++ = data; |
147 | |||
148 | hw->count++; | ||
149 | 146 | ||
150 | /* Handle TX */ | 147 | /* Handle TX */ |
151 | if (hw->count < hw->len) { | 148 | if (--hw->len > 0) { |
152 | data = hw->tx_buf ? hw->tx_buf[hw->count] : 0; | 149 | data = hw->tx_buf ? *hw->tx_buf++ : 0; |
153 | clps_writel(data | SYNCIO_FRMLEN(8) | SYNCIO_TXFRMEN, SYNCIO); | 150 | clps_writel(data | SYNCIO_FRMLEN(8) | SYNCIO_TXFRMEN, SYNCIO); |
154 | } else | 151 | } else |
155 | complete(&hw->done); | 152 | complete(&hw->done); |