public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC] spi: Dont call prepare/unprepare transfer if not populated
@ 2012-05-10 13:50 Shubhrajyoti D
  2012-05-10 14:01 ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: Shubhrajyoti D @ 2012-05-10 13:50 UTC (permalink / raw)
  To: spi-devel-general; +Cc: linux-kernel, andrew, Shubhrajyoti D, Linus Walleij

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.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---

 drivers/spi/spi.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 37c555e..30e114c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -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,
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-20  5:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-10 13:50 [PATCH RFC] spi: Dont call prepare/unprepare transfer if not populated Shubhrajyoti D
2012-05-10 14:01 ` Linus Walleij
2012-05-11  3:24   ` Grant Likely
2012-05-15 19:58     ` Andrew Lunn
2012-05-20  5:00       ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox