From 62a7843229a51912698d48c4d3c502c1c9d7820d Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 18 Sep 2004 12:50:57 +0100 Subject: [PATCH] [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. --- drivers/mmc/mmc.c | 21 +++++++++------------ include/linux/mmc/card.h | 1 + 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 01c8d9959b423..077d320892d25 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -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 * -mmc_find_card(struct mmc_host *host, struct mmc_cid *cid) +static struct mmc_card *mmc_find_card(struct mmc_host *host, u32 *raw_cid) { struct mmc_card *card; 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 NULL; @@ -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. */ 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; unsigned int rca = *frca; @@ -371,7 +370,7 @@ mmc_alloc_card(struct mmc_host *host, struct mmc_cid *cid, unsigned int *frca) return ERR_PTR(-ENOMEM); mmc_init_card(card, host); - memcpy(&card->cid, cid, sizeof(struct mmc_cid)); + memcpy(card->raw_cid, raw_cid, sizeof(card->raw_cid)); again: 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) * to be discovered. Add new cards to the list. * * 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) { @@ -465,7 +464,6 @@ static void mmc_discover_cards(struct mmc_host *host) while (1) { struct mmc_command cmd; - struct mmc_cid cid; cmd.opcode = MMC_ALL_SEND_CID; cmd.arg = 0; @@ -482,11 +480,9 @@ static void mmc_discover_cards(struct mmc_host *host) break; } - mmc_decode_cid(&cid, cmd.resp); - - card = mmc_find_card(host, &cid); + card = mmc_find_card(host, cmd.resp); if (!card) { - card = mmc_alloc_card(host, &cid, &first_rca); + card = mmc_alloc_card(host, cmd.resp, &first_rca); if (IS_ERR(card)) { err = PTR_ERR(card); break; @@ -528,6 +524,7 @@ static void mmc_read_csds(struct mmc_host *host) } mmc_decode_csd(&card->csd, cmd.resp); + mmc_decode_cid(&card->cid, card->raw_cid); } } diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 7c0e9a8fd281c..d7895ff213d46 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -45,6 +45,7 @@ struct mmc_card { unsigned int state; /* (our) card state */ #define MMC_STATE_PRESENT (1<<0) #define MMC_STATE_DEAD (1<<1) + u32 raw_cid[4]; /* raw card CID */ struct mmc_cid cid; /* card identification */ struct mmc_csd csd; /* card specific */ }; -- 2.53.0