Commit 62a78432 authored by Russell King's avatar Russell King

[MMC] Use raw CID rather than decoded CID

Save the raw CID information, and use this to match cards
with their corresponding mmc_card structure.  Different
protocol revisions have different CID formats.
parent 4f0fdda0
...@@ -343,15 +343,14 @@ static void mmc_decode_csd(struct mmc_csd *csd, u32 *resp) ...@@ -343,15 +343,14 @@ static void mmc_decode_csd(struct mmc_csd *csd, u32 *resp)
} }
/* /*
* Locate a MMC card on this MMC host given a CID. * Locate a MMC card on this MMC host given a raw CID.
*/ */
static struct mmc_card * static struct mmc_card *mmc_find_card(struct mmc_host *host, u32 *raw_cid)
mmc_find_card(struct mmc_host *host, struct mmc_cid *cid)
{ {
struct mmc_card *card; struct mmc_card *card;
list_for_each_entry(card, &host->cards, node) { list_for_each_entry(card, &host->cards, node) {
if (memcmp(&card->cid, cid, sizeof(struct mmc_cid)) == 0) if (memcmp(card->raw_cid, raw_cid, sizeof(card->raw_cid)) == 0)
return card; return card;
} }
return NULL; return NULL;
...@@ -361,7 +360,7 @@ mmc_find_card(struct mmc_host *host, struct mmc_cid *cid) ...@@ -361,7 +360,7 @@ mmc_find_card(struct mmc_host *host, struct mmc_cid *cid)
* Allocate a new MMC card, and assign a unique RCA. * Allocate a new MMC card, and assign a unique RCA.
*/ */
static struct mmc_card * static struct mmc_card *
mmc_alloc_card(struct mmc_host *host, struct mmc_cid *cid, unsigned int *frca) mmc_alloc_card(struct mmc_host *host, u32 *raw_cid, unsigned int *frca)
{ {
struct mmc_card *card, *c; struct mmc_card *card, *c;
unsigned int rca = *frca; unsigned int rca = *frca;
...@@ -371,7 +370,7 @@ mmc_alloc_card(struct mmc_host *host, struct mmc_cid *cid, unsigned int *frca) ...@@ -371,7 +370,7 @@ mmc_alloc_card(struct mmc_host *host, struct mmc_cid *cid, unsigned int *frca)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
mmc_init_card(card, host); mmc_init_card(card, host);
memcpy(&card->cid, cid, sizeof(struct mmc_cid)); memcpy(card->raw_cid, raw_cid, sizeof(card->raw_cid));
again: again:
list_for_each_entry(c, &host->cards, node) list_for_each_entry(c, &host->cards, node)
...@@ -456,7 +455,7 @@ static int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) ...@@ -456,7 +455,7 @@ static int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
* to be discovered. Add new cards to the list. * to be discovered. Add new cards to the list.
* *
* Create a mmc_card entry for each discovered card, assigning * Create a mmc_card entry for each discovered card, assigning
* it an RCA, and save the CID. * it an RCA, and save the raw CID for decoding later.
*/ */
static void mmc_discover_cards(struct mmc_host *host) static void mmc_discover_cards(struct mmc_host *host)
{ {
...@@ -465,7 +464,6 @@ static void mmc_discover_cards(struct mmc_host *host) ...@@ -465,7 +464,6 @@ static void mmc_discover_cards(struct mmc_host *host)
while (1) { while (1) {
struct mmc_command cmd; struct mmc_command cmd;
struct mmc_cid cid;
cmd.opcode = MMC_ALL_SEND_CID; cmd.opcode = MMC_ALL_SEND_CID;
cmd.arg = 0; cmd.arg = 0;
...@@ -482,11 +480,9 @@ static void mmc_discover_cards(struct mmc_host *host) ...@@ -482,11 +480,9 @@ static void mmc_discover_cards(struct mmc_host *host)
break; break;
} }
mmc_decode_cid(&cid, cmd.resp); card = mmc_find_card(host, cmd.resp);
card = mmc_find_card(host, &cid);
if (!card) { if (!card) {
card = mmc_alloc_card(host, &cid, &first_rca); card = mmc_alloc_card(host, cmd.resp, &first_rca);
if (IS_ERR(card)) { if (IS_ERR(card)) {
err = PTR_ERR(card); err = PTR_ERR(card);
break; break;
...@@ -528,6 +524,7 @@ static void mmc_read_csds(struct mmc_host *host) ...@@ -528,6 +524,7 @@ static void mmc_read_csds(struct mmc_host *host)
} }
mmc_decode_csd(&card->csd, cmd.resp); mmc_decode_csd(&card->csd, cmd.resp);
mmc_decode_cid(&card->cid, card->raw_cid);
} }
} }
......
...@@ -45,6 +45,7 @@ struct mmc_card { ...@@ -45,6 +45,7 @@ struct mmc_card {
unsigned int state; /* (our) card state */ unsigned int state; /* (our) card state */
#define MMC_STATE_PRESENT (1<<0) #define MMC_STATE_PRESENT (1<<0)
#define MMC_STATE_DEAD (1<<1) #define MMC_STATE_DEAD (1<<1)
u32 raw_cid[4]; /* raw card CID */
struct mmc_cid cid; /* card identification */ struct mmc_cid cid; /* card identification */
struct mmc_csd csd; /* card specific */ struct mmc_csd csd; /* card specific */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment