From patchwork Wed Sep 29 20:08:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 218142 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8TK8N3V026738 for ; Wed, 29 Sep 2010 20:08:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755482Ab0I2UIY (ORCPT ); Wed, 29 Sep 2010 16:08:24 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:34112 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755571Ab0I2UIW (ORCPT ); Wed, 29 Sep 2010 16:08:22 -0400 Received: from katana.hi.pengutronix.de ([2001:6f8:1178:2:221:70ff:fe71:1890] helo=pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.71) (envelope-from ) id 1P12wv-0004Ui-Vw; Wed, 29 Sep 2010 22:08:21 +0200 From: Wolfram Sang To: linux-mmc@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Anton Vorontsov , Zhu Richard-R65037 , zhangfei gao , Philip Rakity , Wolfram Sang Subject: [PATCH 3/6] mmc: sdhci: introduce private get_ro Date: Wed, 29 Sep 2010 22:08:01 +0200 Message-Id: <1285790884-3516-4-git-send-email-w.sang@pengutronix.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1285790884-3516-1-git-send-email-w.sang@pengutronix.de> References: <1285790884-3516-1-git-send-email-w.sang@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:221:70ff:fe71:1890 X-SA-Exim-Mail-From: w.sang@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mmc@vger.kernel.org Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 29 Sep 2010 20:08:25 +0000 (UTC) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 96c7f60..129958e 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1229,14 +1229,17 @@ static int sdhci_get_ro(struct mmc_host *mmc) if (host->flags & SDHCI_DEVICE_DEAD) present = 0; + else if (host->ops->get_ro) + present = host->ops->get_ro(host); else - present = sdhci_readl(host, SDHCI_PRESENT_STATE); + present = !(sdhci_readl(host, SDHCI_PRESENT_STATE) + & SDHCI_WRITE_PROTECT); spin_unlock_irqrestore(&host->lock, flags); - if (host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT) - return !!(present & SDHCI_WRITE_PROTECT); - return !(present & SDHCI_WRITE_PROTECT); + /* This quirk needs to be replaced by a callback-function later */ + return host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT ? + !present : present; } static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 112543a..66f83f4 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -336,6 +336,7 @@ struct sdhci_ops { unsigned int (*get_max_clock)(struct sdhci_host *host); unsigned int (*get_min_clock)(struct sdhci_host *host); unsigned int (*get_timeout_clock)(struct sdhci_host *host); + unsigned int (*get_ro)(struct sdhci_host *host); }; #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS