spi: tegra: check tx queue before start transfer
Ashwini Ghuge [Wed, 20 Jun 2012 08:34:49 +0000 (13:34 +0530)]
Check for valid entry on the message queue before
reading the transfer list from queue. If queue is
empty then do not start transfer.

Change-Id: If51a816780ab76700a7a1d7d8a025a3544590ad1
Signed-off-by: Ashwini Ghuge <aghuge@nvidia.com>
Reviewed-on: http://git-master/r/109469
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

drivers/spi/spi-tegra.c

index 7b3382e..c0de42b 100644 (file)
@@ -967,6 +967,11 @@ static void spi_tegra_curr_transfer_complete(struct spi_tegra_data *tspi,
                udelay(tspi->cur->delay_usecs);
        }
 
+       if (list_empty(&tspi->queue)) {
+               dev_err(&tspi->pdev->dev, "Handling empty list\n");
+               return;
+       }
+
        m = list_first_entry(&tspi->queue, struct spi_message, queue);
        if (err)
                m->status = -EIO;