From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anton Vorontsov Subject: [PATCH 2/3] mmc_spi: add support for card-detection polling Date: Thu, 22 May 2008 22:18:23 +0400 Message-ID: <20080522181823.GB6104@polina.dev.rtsoft.ru> References: <20080522181713.GA26918@polina.dev.rtsoft.ru> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A@public.gmane.org, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, Jochen Friedrich , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Timur Tabi To: Kumar Gala , David Brownell , Pierre Ossman Return-path: Content-Disposition: inline In-Reply-To: <20080522181713.GA26918-PHTr8nzUCjejyJ0x5qLZdcN33GVbZNy3@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: spi-devel-general-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: spi-devel-general-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: linux-spi.vger.kernel.org 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. Signed-off-by: Anton Vorontsov --- drivers/mmc/host/mmc_spi.c | 18 ++++++++++++++++-- include/linux/spi/mmc_spi.h | 6 ++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index 3550858..f0f86b1 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c @@ -1131,11 +1131,20 @@ 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); + + if (host->pdata && host->pdata->get_cd) + return host->pdata->get_cd(mmc->parent); + return -ENOSYS; +} 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, + .get_cd = mmc_spi_get_cd, }; @@ -1323,13 +1332,18 @@ 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; + + 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..23c6923 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 optimize polling + * using this function. + */ + int (*get_cd)(struct device *); + /* how long to debounce card detect, in msecs */ u16 detect_delay; -- 1.5.5.1 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/