[patch 1/5] Add MMC password protection (lock/unlock) support V3
When a card is locked, only commands from the "basic" and "lock card" classesare accepted. To be able to use the other commands, the card must be unlocked
first.
This patch prevents the block driver from trying to run privileged class
commands on locked MMC cards, which will fail anyway.
Signed-off-by: Anderson Briglia <anderson.briglia@xxxxxxxxxxx>
Signed-off-by: Anderson Lizardo <anderson.lizardo@xxxxxxxxxxx>
Signed-off-by: Carlos Eduardo Aguiar <carlos.aguiar@xxxxxxxxxxx>
Signed-off-by: David Brownell <david-b@xxxxxxxxxxx>
Index: linux-2.6.15-rc4/drivers/mmc/mmc.c
===================================================================
--- linux-2.6.15-rc4.orig/drivers/mmc/mmc.c 2005-12-15 14:06:52.000000000 -0400
+++ linux-2.6.15-rc4/drivers/mmc/mmc.c 2005-12-15 17:00:37.000000000 -0400
@@ -986,10 +986,15 @@ static void mmc_check_cards(struct mmc_h
cmd.flags = MMC_RSP_R1;
err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
- if (err == MMC_ERR_NONE)
+ if (err != MMC_ERR_NONE) {
+ mmc_card_set_dead(card);
continue;
+ }
- mmc_card_set_dead(card);
+ if (cmd.resp[0] & R1_CARD_IS_LOCKED)
+ mmc_card_set_locked(card);
+ else
+ card->state &= ~MMC_STATE_LOCKED;
}
}
Index: linux-2.6.15-rc4/drivers/mmc/mmc_sysfs.c
===================================================================
--- linux-2.6.15-rc4.orig/drivers/mmc/mmc_sysfs.c 2005-10-27 20:02:08.000000000 -0400
+++ linux-2.6.15-rc4/drivers/mmc/mmc_sysfs.c 2005-12-15 17:00:29.000000000 -0400
@@ -16,6 +16,7 @@
#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
+#include <linux/mmc/protocol.h>
#include "mmc.h"
@@ -69,13 +70,22 @@ static void mmc_release_card(struct devi
}
/*
- * This currently matches any MMC driver to any MMC card - drivers
- * themselves make the decision whether to drive this card in their
- * probe method. However, we force "bad" cards to fail.
+ * This currently matches any MMC driver to any MMC card - drivers themselves
+ * make the decision whether to drive this card in their probe method.
+ * However, we force "bad" cards to fail.
+ *
+ * We also fail for all locked cards; drivers expect to be able to do block
+ * I/O still on probe(), which is not possible while the card is locked.
+ * Device probing must be triggered sometime later to make the card available
+ * to the block driver.
*/
static int mmc_bus_match(struct device *dev, struct device_driver *drv)
{
struct mmc_card *card = dev_to_mmc_card(dev);
+ if (mmc_card_lockable(card) && mmc_card_locked(card)) {
+ dev_dbg(&card->dev, "card is locked; binding is deferred\n");
+ return 0;
+ }
return !mmc_card_bad(card);
}
Index: linux-2.6.15-rc4/include/linux/mmc/card.h
===================================================================
--- linux-2.6.15-rc4.orig/include/linux/mmc/card.h 2005-10-27 20:02:08.000000000 -0400
+++ linux-2.6.15-rc4/include/linux/mmc/card.h 2005-12-15 17:00:37.000000000 -0400
@@ -56,6 +56,7 @@ struct mmc_card {
#define MMC_STATE_BAD (1<<2) /* unrecognised device */
#define MMC_STATE_SDCARD (1<<3) /* is an SD card */
#define MMC_STATE_READONLY (1<<4) /* card is read-only */
+#define MMC_STATE_LOCKED (1<<5) /* card is currently locked */
u32 raw_cid[4]; /* raw card CID */
u32 raw_csd[4]; /* raw card CSD */
u32 raw_scr[2]; /* raw card SCR */
@@ -69,12 +70,16 @@ struct mmc_card {
#define mmc_card_bad(c) ((c)->state & MMC_STATE_BAD)
#define mmc_card_sd(c) ((c)->state & MMC_STATE_SDCARD)
#define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY)
+#define mmc_card_locked(c) ((c)->state & MMC_STATE_LOCKED)
+
+#define mmc_card_lockable(c) ((c)->csd.cmdclass & CCC_LOCK_CARD)
#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
#define mmc_card_set_dead(c) ((c)->state |= MMC_STATE_DEAD)
#define mmc_card_set_bad(c) ((c)->state |= MMC_STATE_BAD)
#define mmc_card_set_sd(c) ((c)->state |= MMC_STATE_SDCARD)
#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
+#define mmc_card_set_locked(c) ((c)->state |= MMC_STATE_LOCKED)
#define mmc_card_name(c) ((c)->cid.prod_name)
#define mmc_card_id(c) ((c)->dev.bus_id)
Relevant Pages
- RE: [UPDATED PATCH] EFI support for ia32 kernels
... >> reuse a single driver image for multiple architectures assuming there ... As one of the people responsible for the EFI Specification and our ... Perhaps the UNDI network card interface that Intel developed ... BIOS can't shadow that much ROM code. ... (Linux-Kernel) - Re: Linux, X, ld, gcc, linking, shared libraries and stuff
... >> because, originally, video cards / system RAM could NOT afford to have ... > GL actually "copies" everything, but it's done by the graphics card, so ... > anyway if it's not hardware accelerated. ... installed the proper driver, then it zooms around the screen... ... (alt.lang.asm) - Re: XXX_Init only being called once
... > My stream interface driver has been stripped right back to try to solve ... > I plug my card in the first time. ... > There are two new active keys in the registry PCMCIA and myDriver. ... > No entry points are called in my driver. ... (microsoft.public.windowsce.platbuilder) - Re: Network card disabled
... it is not unknown that laptop NIC cards can fail. ... I keep getting a problem with a network card in Windows XP ... Although the driver is installed on the system and saved locally, ... an automatic install fails to locate the driver files. ... (microsoft.public.windowsxp.hardware) - Re: VIA Envy24PT sound card driver loads at startup properly 9 of 10 times
... driver updates including the latest and correct driver for the sound card. ... Onboard sound chip is disabled in BIOS and the driver for it is not installed. ... The sound card, Chaintech, Envy24 Family Audio Controller WDM, is installed/seated properly and uses the IRQ 16 exclusively. ... (microsoft.public.windowsxp.hardware) |
|