From 000e617c0f2ed18b4323a89a72a60f51f9a4ac43 Mon Sep 17 00:00:00 2001 From: Shubhrajyoti D Date: Thu, 10 May 2012 19:20:41 +0530 Subject: [PATCH 007/123] spi: Dont call prepare/unprepare transfer if not populated 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 Acked-by: Linus Walleij [grant.likely: fix whitespace defect] Signed-off-by: Grant Likely Signed-off-by: Paul Gortmaker --- drivers/spi/spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 3d8f662..11e4d7f 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -530,7 +530,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); @@ -560,7 +560,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, -- 1.7.9.7