From patchwork Tue Feb 16 19:57:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ernst Schwab X-Patchwork-Id: 79769 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1GJvp3x014092 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 16 Feb 2010 19:58:28 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NhTYJ-0002Z2-Ik; Tue, 16 Feb 2010 19:57:47 +0000 Received: from sfi-mx-4.v28.ch3.sourceforge.com ([172.29.28.124] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NhTYH-0002Yk-Tw for spi-devel-general@lists.sourceforge.net; Tue, 16 Feb 2010 19:57:45 +0000 X-ACL-Warn: Received: from moutng.kundenserver.de ([212.227.126.186]) by sfi-mx-4.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1NhTYF-0001Ka-FZ; Tue, 16 Feb 2010 19:57:45 +0000 Received: from ip065 (koln-5d8135c9.pool.mediaWays.net [93.129.53.201]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0MC7YO-1NYdqS0mYa-009WKk; Tue, 16 Feb 2010 20:57:36 +0100 Date: Tue, 16 Feb 2010 20:57:38 +0100 From: Ernst Schwab To: Grant Likely , Kumar Gala , David Brownell , spi-devel-general@lists.sourceforge.net Message-Id: <20100216205738.535a7081.eschwab@online.de> X-Mailer: Sylpheed 3.0.0beta8 (GTK+ 2.10.14; i686-pc-mingw32) Mime-Version: 1.0 X-Provags-ID: V01U2FsdGVkX19NEF7dgbmy1ujJctrWbkhEXpRF3dLY/T87OTi uEUjmwekFAZNfkOWlEDvhn9vzscdjLyUi79K1WPE43UWAJz7lK Q9F5QmrahmeFryD3GWL55vdqxFM1QaE X-Spam-Score: -0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-Headers-End: 1NhTYF-0001Ka-FZ Cc: yi.li@analog.com, vapier@gentoo.org Subject: [spi-devel-general] [PATCH 4/5] mmc_spi: added spi_register_lock_bus X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 16 Feb 2010 19:58:28 +0000 (UTC) diff -upr a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c @@ -1083,8 +1083,10 @@ static void mmc_spi_request(struct mmc_h } #endif - /* issue command; then optionally data and stop */ + /* request exclusive bus access */ spi_lock_bus(host->spi); + + /* issue command; then optionally data and stop */ 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); @@ -1093,7 +1095,10 @@ static void mmc_spi_request(struct mmc_h else mmc_cs_off(host); } + + /* release the bus */ spi_unlock_bus(host->spi); + mmc_request_done(host->mmc, mrq); } @@ -1290,23 +1295,6 @@ mmc_spi_detect_irq(int irq, void *mmc) return IRQ_HANDLED; } -struct count_children { - unsigned n; - struct bus_type *bus; -}; - -static int maybe_count_child(struct device *dev, void *c) -{ - struct count_children *ccp = c; - - if (dev->bus == ccp->bus) { - if (ccp->n) - return -EBUSY; - ccp->n++; - } - return 0; -} - static int mmc_spi_probe(struct spi_device *spi) { void *ones; @@ -1338,6 +1326,13 @@ static int mmc_spi_probe(struct spi_devi return status; } + /* Ensure that the driver can get exclusive access. */ + status = spi_register_lock_bus(spi); + if (status < 0) { + dev_err(&spi->dev, "can't share SPI bus\n"); + return -EBUSY; + } + /* We need a supply of ones to transmit. This is the only time * the CPU touches these, so cache coherency isn't a concern. * @@ -1471,6 +1466,7 @@ fail_nobuf1: nomem: kfree(ones); + spi_unregister_lock_bus(spi); return status; } @@ -1503,6 +1499,7 @@ static int __devexit mmc_spi_remove(stru mmc_free_host(mmc); mmc_spi_put_pdata(spi); dev_set_drvdata(&spi->dev, NULL); + spi_unregister_lock_bus(spi); } return 0; }