public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: core: sd: check card write-protect lock while resuming
@ 2014-08-18 10:00 Barry Song
  2014-08-18 11:57 ` Ulf Hansson
  0 siblings, 1 reply; 6+ messages in thread
From: Barry Song @ 2014-08-18 10:00 UTC (permalink / raw)
  To: chris, ulf.hansson
  Cc: Barry Song, linux-mmc, workgroup.linux, linux-arm-kernel,
	Minda Chen

From: Minda Chen <Minda.Chen@csr.com>

After suspending, unplug the sdcard, and set sd WP lock,
insert it again, then resume the system. resume codes do
not check the the sdcard write-proctect lock. now check
it.

Signed-off-by: Minda Chen <Minda.Chen@csr.com>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
---
 drivers/mmc/core/sd.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 0c44510..890557a 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -910,6 +910,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
 	int err;
 	u32 cid[4];
 	u32 rocr = 0;
+	bool oldro, ro;
 
 	BUG_ON(!host);
 	WARN_ON(!host->claimed);
@@ -922,6 +923,12 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
 		if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0)
 			return -ENOENT;
 
+		if (host->ops->get_ro) {
+			ro = host->ops->get_ro(host) ? true : false;
+			oldro = mmc_card_readonly(oldcard) ? true : false;
+			if (oldro ^ ro)
+				return -ENOENT;
+		}
 		card = oldcard;
 	} else {
 		/*
-- 
2.0.4



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Keep up to date with CSR on our technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people, YouTube, www.youtube.com/user/CSRplc, Facebook, www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at www.twitter.com/CSR_plc.
New for 2014, you can now access the wide range of products powered by aptX at www.aptx.com.

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-08-28  6:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-18 10:00 [PATCH] mmc: core: sd: check card write-protect lock while resuming Barry Song
2014-08-18 11:57 ` Ulf Hansson
2014-08-22  6:55   ` Barry Song
2014-08-22 10:00     ` Ulf Hansson
     [not found]       ` <7960C73727803F45B9F4D2B2441DA8AC0CE80220@SHAASIEXM01.ASIA.ROOT.PRI>
2014-08-28  2:02         ` FW: " minda chen
2014-08-28  6:25           ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox