From patchwork Mon Aug 18 10:00:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song X-Patchwork-Id: 4735401 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1167AC0338 for ; Mon, 18 Aug 2014 10:25:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 11CC720122 for ; Mon, 18 Aug 2014 10:25:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A212F2013A for ; Mon, 18 Aug 2014 10:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753036AbaHRKBI (ORCPT ); Mon, 18 Aug 2014 06:01:08 -0400 Received: from cluster-g.mailcontrol.com ([208.87.233.190]:35114 "EHLO cluster-g.mailcontrol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754479AbaHRKBG (ORCPT ); Mon, 18 Aug 2014 06:01:06 -0400 Received: from shaapppus01.asia.root.pri ([210.13.83.99]) by rly02g.srv.mailcontrol.com (MailControl) with ESMTP id s7IA0IKm028532 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Mon, 18 Aug 2014 11:00:20 +0100 Received: from shaasiexc01.ASIA.ROOT.PRI ([10.125.12.102]) by shaapppus01.asia.root.pri (PGP Universal service); Mon, 18 Aug 2014 18:00:21 +0800 X-PGP-Universal: processed; by shaapppus01.asia.root.pri on Mon, 18 Aug 2014 18:00:21 +0800 Received: from barry-laptop.ROOT.PRI (10.125.5.73) by asimail.csr.com (10.125.12.88) with Microsoft SMTP Server (TLS) id 14.3.158.1; Mon, 18 Aug 2014 18:00:17 +0800 From: Barry Song To: , CC: , , , Minda Chen , Barry Song Subject: [PATCH] mmc: core: sd: check card write-protect lock while resuming Date: Mon, 18 Aug 2014 18:00:12 +0800 Message-ID: <1408356012-18867-1-git-send-email-Barry.Song@csr.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-Originating-IP: [10.125.5.73] X-CFilter-Loop: Reflected X-Scanned-By: MailControl 33066.168 (www.mailcontrol.com) on 10.71.0.112 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Minda Chen 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 Signed-off-by: Barry Song --- 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 { /*