Title: [5784] trunk/drivers/mmc/host/mmc_spi.c: bug [#3713] - Use SPI lock to share bus with other SPI devices.
Revision
5784
Author
adamliyi
Date
2008-12-02 03:48:07 -0600 (Tue, 02 Dec 2008)

Log Message

bug [#3713] - Use SPI lock to share bus with other SPI devices.

Modified Paths

Diff

Modified: trunk/drivers/mmc/host/mmc_spi.c (5783 => 5784)


--- trunk/drivers/mmc/host/mmc_spi.c	2008-12-02 09:43:03 UTC (rev 5783)
+++ trunk/drivers/mmc/host/mmc_spi.c	2008-12-02 09:48:07 UTC (rev 5784)
@@ -1004,6 +1004,7 @@
 #endif
 
 	/* issue command; then optionally data and stop */
+	spi_lock_bus(host->spi);
 	status = mmc_spi_command_send(host, mrq, mrq->cmd, mrq->data != NULL);
 	if (status == 0 && mrq->data) {
 		mmc_spi_data_do(host, mrq->cmd, mrq->data, mrq->data->blksz);
@@ -1012,7 +1013,7 @@
 		else
 			mmc_cs_off(host);
 	}
-
+	spi_unlock_bus(host->spi);
 	mmc_request_done(host->mmc, mrq);
 }
 
@@ -1256,32 +1257,6 @@
 		return status;
 	}
 
-	/* We can use the bus safely iff nobody else will interfere with us.
-	 * Most commands consist of one SPI message to issue a command, then
-	 * several more to collect its response, then possibly more for data
-	 * transfer.  Clocking access to other devices during that period will
-	 * corrupt the command execution.
-	 *
-	 * Until we have software primitives which guarantee non-interference,
-	 * we'll aim for a hardware-level guarantee.
-	 *
-	 * REVISIT we can't guarantee another device won't be added later...
-	 */
-	if (spi->master->num_chipselect > 1) {
-		struct count_children cc;
-
-		cc.n = 0;
-		cc.bus = spi->dev.bus;
-		status = device_for_each_child(spi->dev.parent, &cc,
-				maybe_count_child);
-		if (status < 0) {
-			dev_err(&spi->dev, "can't share SPI bus\n");
-			return status;
-		}
-
-		dev_warn(&spi->dev, "ASSUMING SPI bus stays unshared!\n");
-	}
-
 	/* We need a supply of ones to transmit.  This is the only time
 	 * the CPU touches these, so cache coherency isn't a concern.
 	 *
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
http://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to