aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-bfin5xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-bfin5xx.c')
-rw-r--r--drivers/spi/spi-bfin5xx.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/spi/spi-bfin5xx.c b/drivers/spi/spi-bfin5xx.c
index 3b83ff8b1e2b..9bb4d4af8547 100644
--- a/drivers/spi/spi-bfin5xx.c
+++ b/drivers/spi/spi-bfin5xx.c
@@ -396,7 +396,7 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
396 /* last read */ 396 /* last read */
397 if (drv_data->rx) { 397 if (drv_data->rx) {
398 dev_dbg(&drv_data->pdev->dev, "last read\n"); 398 dev_dbg(&drv_data->pdev->dev, "last read\n");
399 if (n_bytes % 2) { 399 if (!(n_bytes % 2)) {
400 u16 *buf = (u16 *)drv_data->rx; 400 u16 *buf = (u16 *)drv_data->rx;
401 for (loop = 0; loop < n_bytes / 2; loop++) 401 for (loop = 0; loop < n_bytes / 2; loop++)
402 *buf++ = bfin_read(&drv_data->regs->rdbr); 402 *buf++ = bfin_read(&drv_data->regs->rdbr);
@@ -424,7 +424,7 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
424 if (drv_data->rx && drv_data->tx) { 424 if (drv_data->rx && drv_data->tx) {
425 /* duplex */ 425 /* duplex */
426 dev_dbg(&drv_data->pdev->dev, "duplex: write_TDBR\n"); 426 dev_dbg(&drv_data->pdev->dev, "duplex: write_TDBR\n");
427 if (n_bytes % 2) { 427 if (!(n_bytes % 2)) {
428 u16 *buf = (u16 *)drv_data->rx; 428 u16 *buf = (u16 *)drv_data->rx;
429 u16 *buf2 = (u16 *)drv_data->tx; 429 u16 *buf2 = (u16 *)drv_data->tx;
430 for (loop = 0; loop < n_bytes / 2; loop++) { 430 for (loop = 0; loop < n_bytes / 2; loop++) {
@@ -442,7 +442,7 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
442 } else if (drv_data->rx) { 442 } else if (drv_data->rx) {
443 /* read */ 443 /* read */
444 dev_dbg(&drv_data->pdev->dev, "read: write_TDBR\n"); 444 dev_dbg(&drv_data->pdev->dev, "read: write_TDBR\n");
445 if (n_bytes % 2) { 445 if (!(n_bytes % 2)) {
446 u16 *buf = (u16 *)drv_data->rx; 446 u16 *buf = (u16 *)drv_data->rx;
447 for (loop = 0; loop < n_bytes / 2; loop++) { 447 for (loop = 0; loop < n_bytes / 2; loop++) {
448 *buf++ = bfin_read(&drv_data->regs->rdbr); 448 *buf++ = bfin_read(&drv_data->regs->rdbr);
@@ -458,7 +458,7 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
458 } else if (drv_data->tx) { 458 } else if (drv_data->tx) {
459 /* write */ 459 /* write */
460 dev_dbg(&drv_data->pdev->dev, "write: write_TDBR\n"); 460 dev_dbg(&drv_data->pdev->dev, "write: write_TDBR\n");
461 if (n_bytes % 2) { 461 if (!(n_bytes % 2)) {
462 u16 *buf = (u16 *)drv_data->tx; 462 u16 *buf = (u16 *)drv_data->tx;
463 for (loop = 0; loop < n_bytes / 2; loop++) { 463 for (loop = 0; loop < n_bytes / 2; loop++) {
464 bfin_read(&drv_data->regs->rdbr); 464 bfin_read(&drv_data->regs->rdbr);
@@ -587,6 +587,7 @@ static void bfin_spi_pump_transfers(unsigned long data)
587 if (message->state == DONE_STATE) { 587 if (message->state == DONE_STATE) {
588 dev_dbg(&drv_data->pdev->dev, "transfer: all done!\n"); 588 dev_dbg(&drv_data->pdev->dev, "transfer: all done!\n");
589 message->status = 0; 589 message->status = 0;
590 bfin_spi_flush(drv_data);
590 bfin_spi_giveback(drv_data); 591 bfin_spi_giveback(drv_data);
591 return; 592 return;
592 } 593 }
@@ -870,8 +871,10 @@ static void bfin_spi_pump_transfers(unsigned long data)
870 message->actual_length += drv_data->len_in_bytes; 871 message->actual_length += drv_data->len_in_bytes;
871 /* Move to next transfer of this msg */ 872 /* Move to next transfer of this msg */
872 message->state = bfin_spi_next_transfer(drv_data); 873 message->state = bfin_spi_next_transfer(drv_data);
873 if (drv_data->cs_change) 874 if (drv_data->cs_change && message->state != DONE_STATE) {
875 bfin_spi_flush(drv_data);
874 bfin_spi_cs_deactive(drv_data, chip); 876 bfin_spi_cs_deactive(drv_data, chip);
877 }
875 } 878 }
876 879
877 /* Schedule next transfer tasklet */ 880 /* Schedule next transfer tasklet */
@@ -1026,7 +1029,6 @@ static int bfin_spi_setup(struct spi_device *spi)
1026 chip->cs_chg_udelay = chip_info->cs_chg_udelay; 1029 chip->cs_chg_udelay = chip_info->cs_chg_udelay;
1027 chip->idle_tx_val = chip_info->idle_tx_val; 1030 chip->idle_tx_val = chip_info->idle_tx_val;
1028 chip->pio_interrupt = chip_info->pio_interrupt; 1031 chip->pio_interrupt = chip_info->pio_interrupt;
1029 spi->bits_per_word = chip_info->bits_per_word;
1030 } else { 1032 } else {
1031 /* force a default base state */ 1033 /* force a default base state */
1032 chip->ctl_reg &= bfin_ctl_reg; 1034 chip->ctl_reg &= bfin_ctl_reg;