]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
spi: Dont call prepare/unprepare transfer if not populated
authorShubhrajyoti D <shubhrajyoti@ti.com>
Thu, 10 May 2012 13:50:41 +0000 (19:20 +0530)
committerGrant Likely <grant.likely@secretlab.ca>
Fri, 11 May 2012 03:23:58 +0000 (21:23 -0600)
Currently the prepare/unprepare transfer are called unconditionally.
The assumption is that every driver using the spi core queue infrastructure
has to populate the prepare and unprepare functions. This encourages
drivers to populate empty functions to prevent crashing.
This patch prevents the call to prepare/unprepare if not populated.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
[grant.likely: fix whitespace defect]
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
drivers/spi/spi.c

index 37c555ec59ab74a6f7a25caa28e28dd51aaf8a35..2d65b1684cdc9c534dd5936d11c58a4690df0a66 100644 (file)
@@ -532,7 +532,7 @@ static void spi_pump_messages(struct kthread_work *work)
        /* Lock queue and check for queue work */
        spin_lock_irqsave(&master->queue_lock, flags);
        if (list_empty(&master->queue) || !master->running) {
-               if (master->busy) {
+               if (master->busy && master->unprepare_transfer_hardware) {
                        ret = master->unprepare_transfer_hardware(master);
                        if (ret) {
                                spin_unlock_irqrestore(&master->queue_lock, flags);
@@ -562,7 +562,7 @@ static void spi_pump_messages(struct kthread_work *work)
                master->busy = true;
        spin_unlock_irqrestore(&master->queue_lock, flags);
 
-       if (!was_busy) {
+       if (!was_busy && master->prepare_transfer_hardware) {
                ret = master->prepare_transfer_hardware(master);
                if (ret) {
                        dev_err(&master->dev,