mpc52xx_psc_spi: fix block transfer

The block transfer routine in the mpc52xx psc spi driver misinterpret
the datasheet. According to the processor datasheet the chipselect is
held as long as the EOF is not written.

Theoretically blocks of any sizes can be transferred in this way. The
old routine however writes an EOF after every word, which has the size
of size_of_word. This makes the transfer slow.

Also fixed some duplicate code.

Signed-off-by: Luotao Fu <l.fu@pengutronix.de>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: <stable@kernel.org> [2.6.25.x, 2.6.26.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Luotao Fu and committed by
Linus Torvalds
9a7867e1 78a34ae2

+7 -15
+7 -15
drivers/spi/mpc52xx_psc_spi.c
··· 148 unsigned rfalarm; 149 unsigned send_at_once = MPC52xx_PSC_BUFSIZE; 150 unsigned recv_at_once; 151 - unsigned bpw = mps->bits_per_word / 8; 152 153 if (!t->tx_buf && !t->rx_buf && t->len) 154 return -EINVAL; ··· 163 } 164 165 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once); 166 - if (tx_buf) { 167 - for (; send_at_once; sb++, send_at_once--) { 168 - /* set EOF flag */ 169 - if (mps->bits_per_word 170 - && (sb + 1) % bpw == 0) 171 - out_8(&psc->ircr2, 0x01); 172 out_8(&psc->mpc52xx_psc_buffer_8, tx_buf[sb]); 173 - } 174 - } else { 175 - for (; send_at_once; sb++, send_at_once--) { 176 - /* set EOF flag */ 177 - if (mps->bits_per_word 178 - && ((sb + 1) % bpw) == 0) 179 - out_8(&psc->ircr2, 0x01); 180 out_8(&psc->mpc52xx_psc_buffer_8, 0); 181 - } 182 } 183 184
··· 148 unsigned rfalarm; 149 unsigned send_at_once = MPC52xx_PSC_BUFSIZE; 150 unsigned recv_at_once; 151 152 if (!t->tx_buf && !t->rx_buf && t->len) 153 return -EINVAL; ··· 164 } 165 166 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once); 167 + for (; send_at_once; sb++, send_at_once--) { 168 + /* set EOF flag before the last word is sent */ 169 + if (send_at_once == 1) 170 + out_8(&psc->ircr2, 0x01); 171 + 172 + if (tx_buf) 173 out_8(&psc->mpc52xx_psc_buffer_8, tx_buf[sb]); 174 + else 175 out_8(&psc->mpc52xx_psc_buffer_8, 0); 176 } 177 178