From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Kumar Gala <galak@kernel.crashing.org>,
David Brownell <dbrownell@users.sourceforge.net>,
Pierre Ossman <drzeus-mmc@drzeus.cx>
Cc: linuxppc-dev@ozlabs.org, spi-devel-general@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Timur Tabi <timur@freescale.com>
Subject: [PATCH 2/2] mmc_spi: add support for card-detection polling
Date: Wed, 21 May 2008 22:47:52 +0400 [thread overview]
Message-ID: <20080521184752.GB32052@polina.dev.rtsoft.ru> (raw)
In-Reply-To: <20080521184713.GA30284@polina.dev.rtsoft.ru>
If platform_data lacks init() callback (solely used to request
card-detect interrupt), we mark the host as MMC_CAP_NEEDS_POLL.
get_cd() host operation provided to optimize polling.
p.s. Since mmc_host_ops no longer the same for every instance of
mmc_spi, struct mmc_host_ops can't be const and should be allocated
dynamically.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
drivers/mmc/host/mmc_spi.c | 31 +++++++++++++++++++++----------
include/linux/spi/mmc_spi.h | 6 ++++++
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 3550858..667855a 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -115,6 +115,7 @@ struct scratch {
struct mmc_spi_host {
struct mmc_host *mmc;
+ struct mmc_host_ops mmc_spi_ops;
struct spi_device *spi;
unsigned char power_mode;
@@ -1131,13 +1132,12 @@ static int mmc_spi_get_ro(struct mmc_host *mmc)
return 0;
}
+static int mmc_spi_get_cd(struct mmc_host *mmc)
+{
+ struct mmc_spi_host *host = mmc_priv(mmc);
-static const struct mmc_host_ops mmc_spi_ops = {
- .request = mmc_spi_request,
- .set_ios = mmc_spi_set_ios,
- .get_ro = mmc_spi_get_ro,
-};
-
+ return host->pdata->get_cd(mmc->parent);
+}
/****************************************************************************/
@@ -1236,8 +1236,12 @@ static int mmc_spi_probe(struct spi_device *spi)
mmc = mmc_alloc_host(sizeof(*host), &spi->dev);
if (!mmc)
goto nomem;
+ host = mmc_priv(mmc);
- mmc->ops = &mmc_spi_ops;
+ host->mmc_spi_ops.request = mmc_spi_request,
+ host->mmc_spi_ops.set_ios = mmc_spi_set_ios,
+ host->mmc_spi_ops.get_ro = mmc_spi_get_ro,
+ mmc->ops = &host->mmc_spi_ops;
mmc->max_blk_size = MMC_SPI_BLOCKSIZE;
/* As long as we keep track of the number of successfully
@@ -1256,7 +1260,6 @@ static int mmc_spi_probe(struct spi_device *spi)
mmc->f_min = 400000;
mmc->f_max = spi->max_speed_hz;
- host = mmc_priv(mmc);
host->mmc = mmc;
host->spi = spi;
@@ -1323,13 +1326,21 @@ static int mmc_spi_probe(struct spi_device *spi)
if (status != 0)
goto fail_add_host;
- dev_info(&spi->dev, "SD/MMC host %s%s%s%s\n",
+ if (host->pdata && !host->pdata->init)
+ mmc->caps |= MMC_CAP_NEEDS_POLL;
+
+ if (host->pdata && host->pdata->get_cd)
+ host->mmc_spi_ops.get_cd = mmc_spi_get_cd;
+
+ dev_info(&spi->dev, "SD/MMC host %s%s%s%s%s\n",
mmc->class_dev.bus_id,
host->dma_dev ? "" : ", no DMA",
(host->pdata && host->pdata->get_ro)
? "" : ", no WP",
(host->pdata && host->pdata->setpower)
- ? "" : ", no poweroff");
+ ? "" : ", no poweroff",
+ (mmc->caps & MMC_CAP_NEEDS_POLL)
+ ? ", cd polling" : "");
return 0;
fail_add_host:
diff --git a/include/linux/spi/mmc_spi.h b/include/linux/spi/mmc_spi.h
index d5ca78b..915faf3 100644
--- a/include/linux/spi/mmc_spi.h
+++ b/include/linux/spi/mmc_spi.h
@@ -23,6 +23,12 @@ struct mmc_spi_platform_data {
/* sense switch on sd cards */
int (*get_ro)(struct device *);
+ /*
+ * if board does not use CD interrupts, driver can poll the CD
+ * line using this function.
+ */
+ int (*get_cd)(struct device *);
+
/* how long to debounce card detect, in msecs */
u16 detect_delay;
--
1.5.5.1
next prev parent reply other threads:[~2008-05-21 18:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-16 16:50 [PATCH 3/4] [MMC] mmc_spi: add polling support for the card detect line Anton Vorontsov
2008-05-17 11:36 ` Pierre Ossman
2008-05-21 18:47 ` Anton Vorontsov
2008-05-21 18:47 ` [PATCH 1/2] mmc: add support for card-detection polling Anton Vorontsov
2008-05-21 18:47 ` Anton Vorontsov [this message]
[not found] ` <20080521212831.523f344b@mjolnir.drzeus.cx>
2008-05-22 18:17 ` [PATCH 3/4] [MMC] mmc_spi: add polling support for the card detect line Anton Vorontsov
2008-05-22 18:18 ` [PATCH 1/3] mmc: add support for card-detection polling Anton Vorontsov
2008-05-22 18:18 ` [PATCH 2/3] mmc_spi: " Anton Vorontsov
2008-05-22 18:18 ` [PATCH 3/3] mmc: change .get_ro() callback semantics Anton Vorontsov
[not found] ` <20080522213432.4a50629b@mjolnir.drzeus.cx>
2008-05-23 15:42 ` [PATCH 3/4] [MMC] mmc_spi: add polling support for the card detect line Anton Vorontsov
2008-05-23 15:43 ` [PATCH 1/3] mmc: add support for card-detection polling Anton Vorontsov
2008-05-23 15:43 ` [PATCH 2/3] mmc_spi: " Anton Vorontsov
2008-05-23 15:43 ` [PATCH 3/3] mmc: change .get_ro() callback semantics Anton Vorontsov
2008-06-03 10:07 ` Marc Pignat
2008-06-05 14:43 ` Anton Vorontsov
2008-06-05 15:58 ` Marc Pignat
2008-06-05 17:10 ` [PATCH] mmc: toughen get_ro() and get_cd() return values Anton Vorontsov
2008-05-19 3:02 ` [PATCH 3/4] [MMC] mmc_spi: add polling support for the card detectline Chen Gong
2008-05-22 12:38 ` Anton Vorontsov
2008-05-22 13:44 ` [PATCH 3/4] [MMC] mmc_spi: add polling support for the carddetectline Chen Gong
2008-05-26 15:37 ` Anton Vorontsov
2008-05-27 2:11 ` [PATCH 3/4] [MMC] mmc_spi: add polling support for thecarddetectline Chen Gong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080521184752.GB32052@polina.dev.rtsoft.ru \
--to=avorontsov@ru.mvista.com \
--cc=dbrownell@users.sourceforge.net \
--cc=drzeus-mmc@drzeus.cx \
--cc=galak@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=spi-devel-general@lists.sourceforge.net \
--cc=timur@freescale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).