@@ -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)
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 <alcooperx@gmail.com> --- drivers/mmc/core/core.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)