From patchwork Fri Aug 30 20:14:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 2852215 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BEAFB9F664 for ; Fri, 30 Aug 2013 20:15:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A2FE2030E for ; Fri, 30 Aug 2013 20:15:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F28D8202BE for ; Fri, 30 Aug 2013 20:15:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753967Ab3H3UPn (ORCPT ); Fri, 30 Aug 2013 16:15:43 -0400 Received: from mms3.broadcom.com ([216.31.210.19]:3727 "EHLO mms3.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755173Ab3H3UPm (ORCPT ); Fri, 30 Aug 2013 16:15:42 -0400 Received: from [10.9.208.57] by mms3.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Fri, 30 Aug 2013 13:05:14 -0700 X-Server-Uuid: B86B6450-0931-4310-942E-F00ED04CA7AF Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.1.438.0; Fri, 30 Aug 2013 13:15:31 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.1.438.0; Fri, 30 Aug 2013 13:15:31 -0700 Received: from stbsrv-and-2.and.broadcom.com ( stbsrv-and-2.and.broadcom.com [10.32.128.96]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 5BA641A46; Fri, 30 Aug 2013 13:15:31 -0700 (PDT) From: "Al Cooper" To: cjb@laptop.org, linux-mmc@vger.kernel.org, ulf.hansson@linaro.org cc: "Al Cooper" Subject: [PATCH V2 3/7] mmc: lock: Add function to unlock a password locked card Date: Fri, 30 Aug 2013 16:14:21 -0400 Message-ID: <1377893665-26754-4-git-send-email-alcooperx@gmail.com> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1377893665-26754-1-git-send-email-alcooperx@gmail.com> References: <1377893665-26754-1-git-send-email-alcooperx@gmail.com> MIME-Version: 1.0 X-WSS-ID: 7E3E25702L880011640-01-01 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable 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 This function will try to get a password for the card and use the password to unlock it. It will leave the card state flag set appropriately. Signed-off-by: Al Cooper --- drivers/mmc/core/core.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 4954d04..5a7fb9f 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2786,6 +2786,27 @@ static inline void mmc_unregister_key_type(void) unregister_key_type(&key_type_mmc); } +int mmc_unlock_card(struct mmc_card *card) +{ + int stat; + struct mmc_password password; + + mmc_card_set_locked(card); + stat = mmc_get_password(card, &password); + if (stat) { + pr_warn("%s: Cannot find matching key\n", + mmc_hostname(card->host)); + return stat; + } + stat = mmc_lock_unlock(card, &password, MMC_LOCK_MODE_UNLOCK); + if (stat) + pr_warn("%s: Password failed to unlock card\n", + mmc_hostname(card->host)); + else + mmc_card_clear_locked(card); + return stat; +} + #else /* CONFIG_MMC_LOCK */ int mmc_get_password(struct mmc_card *card, struct mmc_password *password) @@ -2802,6 +2823,11 @@ static inline void mmc_unregister_key_type(void) { } +int mmc_unlock_card(struct mmc_card *card) +{ + return -ENOKEY; +} + #endif /* CONFIG_MMC_LOCK */ static int __init mmc_init(void)