diff options
-rw-r--r-- | drivers/mmc/core/mmc.c | 22 | ||||
-rw-r--r-- | drivers/mmc/core/sd.c | 23 | ||||
-rw-r--r-- | drivers/mmc/core/sysfs.c | 5 | ||||
-rw-r--r-- | include/linux/mmc/card.h | 12 |
4 files changed, 34 insertions, 28 deletions
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 619581e49163..42cc2867ed7d 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -56,7 +56,7 @@ static const unsigned int tacc_mant[] = { | |||
56 | /* | 56 | /* |
57 | * Given the decoded CSD structure, decode the raw CID to our CID structure. | 57 | * Given the decoded CSD structure, decode the raw CID to our CID structure. |
58 | */ | 58 | */ |
59 | static void mmc_decode_cid(struct mmc_card *card) | 59 | static int mmc_decode_cid(struct mmc_card *card) |
60 | { | 60 | { |
61 | u32 *resp = card->raw_cid; | 61 | u32 *resp = card->raw_cid; |
62 | 62 | ||
@@ -101,15 +101,16 @@ static void mmc_decode_cid(struct mmc_card *card) | |||
101 | default: | 101 | default: |
102 | printk("%s: card has unknown MMCA version %d\n", | 102 | printk("%s: card has unknown MMCA version %d\n", |
103 | mmc_hostname(card->host), card->csd.mmca_vsn); | 103 | mmc_hostname(card->host), card->csd.mmca_vsn); |
104 | mmc_card_set_bad(card); | 104 | return -EINVAL; |
105 | break; | ||
106 | } | 105 | } |
106 | |||
107 | return 0; | ||
107 | } | 108 | } |
108 | 109 | ||
109 | /* | 110 | /* |
110 | * Given a 128-bit response, decode to our card CSD structure. | 111 | * Given a 128-bit response, decode to our card CSD structure. |
111 | */ | 112 | */ |
112 | static void mmc_decode_csd(struct mmc_card *card) | 113 | static int mmc_decode_csd(struct mmc_card *card) |
113 | { | 114 | { |
114 | struct mmc_csd *csd = &card->csd; | 115 | struct mmc_csd *csd = &card->csd; |
115 | unsigned int e, m, csd_struct; | 116 | unsigned int e, m, csd_struct; |
@@ -123,8 +124,7 @@ static void mmc_decode_csd(struct mmc_card *card) | |||
123 | if (csd_struct != 1 && csd_struct != 2) { | 124 | if (csd_struct != 1 && csd_struct != 2) { |
124 | printk("%s: unrecognised CSD structure version %d\n", | 125 | printk("%s: unrecognised CSD structure version %d\n", |
125 | mmc_hostname(card->host), csd_struct); | 126 | mmc_hostname(card->host), csd_struct); |
126 | mmc_card_set_bad(card); | 127 | return -EINVAL; |
127 | return; | ||
128 | } | 128 | } |
129 | 129 | ||
130 | csd->mmca_vsn = UNSTUFF_BITS(resp, 122, 4); | 130 | csd->mmca_vsn = UNSTUFF_BITS(resp, 122, 4); |
@@ -149,6 +149,8 @@ static void mmc_decode_csd(struct mmc_card *card) | |||
149 | csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3); | 149 | csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3); |
150 | csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); | 150 | csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); |
151 | csd->write_partial = UNSTUFF_BITS(resp, 21, 1); | 151 | csd->write_partial = UNSTUFF_BITS(resp, 21, 1); |
152 | |||
153 | return 0; | ||
152 | } | 154 | } |
153 | 155 | ||
154 | /* | 156 | /* |
@@ -300,8 +302,12 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
300 | if (err != MMC_ERR_NONE) | 302 | if (err != MMC_ERR_NONE) |
301 | goto free_card; | 303 | goto free_card; |
302 | 304 | ||
303 | mmc_decode_csd(card); | 305 | err = mmc_decode_csd(card); |
304 | mmc_decode_cid(card); | 306 | if (err < 0) |
307 | goto free_card; | ||
308 | err = mmc_decode_cid(card); | ||
309 | if (err < 0) | ||
310 | goto free_card; | ||
305 | } | 311 | } |
306 | 312 | ||
307 | /* | 313 | /* |
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 6597e778f70e..c1dfd03d559a 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c | |||
@@ -88,7 +88,7 @@ static void mmc_decode_cid(struct mmc_card *card) | |||
88 | /* | 88 | /* |
89 | * Given a 128-bit response, decode to our card CSD structure. | 89 | * Given a 128-bit response, decode to our card CSD structure. |
90 | */ | 90 | */ |
91 | static void mmc_decode_csd(struct mmc_card *card) | 91 | static int mmc_decode_csd(struct mmc_card *card) |
92 | { | 92 | { |
93 | struct mmc_csd *csd = &card->csd; | 93 | struct mmc_csd *csd = &card->csd; |
94 | unsigned int e, m, csd_struct; | 94 | unsigned int e, m, csd_struct; |
@@ -151,15 +151,16 @@ static void mmc_decode_csd(struct mmc_card *card) | |||
151 | default: | 151 | default: |
152 | printk("%s: unrecognised CSD structure version %d\n", | 152 | printk("%s: unrecognised CSD structure version %d\n", |
153 | mmc_hostname(card->host), csd_struct); | 153 | mmc_hostname(card->host), csd_struct); |
154 | mmc_card_set_bad(card); | 154 | return -EINVAL; |
155 | return; | ||
156 | } | 155 | } |
156 | |||
157 | return 0; | ||
157 | } | 158 | } |
158 | 159 | ||
159 | /* | 160 | /* |
160 | * Given a 64-bit response, decode to our card SCR structure. | 161 | * Given a 64-bit response, decode to our card SCR structure. |
161 | */ | 162 | */ |
162 | static void mmc_decode_scr(struct mmc_card *card) | 163 | static int mmc_decode_scr(struct mmc_card *card) |
163 | { | 164 | { |
164 | struct sd_scr *scr = &card->scr; | 165 | struct sd_scr *scr = &card->scr; |
165 | unsigned int scr_struct; | 166 | unsigned int scr_struct; |
@@ -174,12 +175,13 @@ static void mmc_decode_scr(struct mmc_card *card) | |||
174 | if (scr_struct != 0) { | 175 | if (scr_struct != 0) { |
175 | printk("%s: unrecognised SCR structure version %d\n", | 176 | printk("%s: unrecognised SCR structure version %d\n", |
176 | mmc_hostname(card->host), scr_struct); | 177 | mmc_hostname(card->host), scr_struct); |
177 | mmc_card_set_bad(card); | 178 | return -EINVAL; |
178 | return; | ||
179 | } | 179 | } |
180 | 180 | ||
181 | scr->sda_vsn = UNSTUFF_BITS(resp, 56, 4); | 181 | scr->sda_vsn = UNSTUFF_BITS(resp, 56, 4); |
182 | scr->bus_widths = UNSTUFF_BITS(resp, 48, 4); | 182 | scr->bus_widths = UNSTUFF_BITS(resp, 48, 4); |
183 | |||
184 | return 0; | ||
183 | } | 185 | } |
184 | 186 | ||
185 | /* | 187 | /* |
@@ -342,7 +344,10 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
342 | if (err != MMC_ERR_NONE) | 344 | if (err != MMC_ERR_NONE) |
343 | goto free_card; | 345 | goto free_card; |
344 | 346 | ||
345 | mmc_decode_csd(card); | 347 | err = mmc_decode_csd(card); |
348 | if (err < 0) | ||
349 | goto free_card; | ||
350 | |||
346 | mmc_decode_cid(card); | 351 | mmc_decode_cid(card); |
347 | } | 352 | } |
348 | 353 | ||
@@ -361,7 +366,9 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
361 | if (err != MMC_ERR_NONE) | 366 | if (err != MMC_ERR_NONE) |
362 | goto free_card; | 367 | goto free_card; |
363 | 368 | ||
364 | mmc_decode_scr(card); | 369 | err = mmc_decode_scr(card); |
370 | if (err < 0) | ||
371 | goto free_card; | ||
365 | 372 | ||
366 | /* | 373 | /* |
367 | * Fetch switch information from card. | 374 | * Fetch switch information from card. |
diff --git a/drivers/mmc/core/sysfs.c b/drivers/mmc/core/sysfs.c index 5c9ce02e7e55..843b1fbba557 100644 --- a/drivers/mmc/core/sysfs.c +++ b/drivers/mmc/core/sysfs.c | |||
@@ -72,12 +72,11 @@ static void mmc_release_card(struct device *dev) | |||
72 | /* | 72 | /* |
73 | * This currently matches any MMC driver to any MMC card - drivers | 73 | * This currently matches any MMC driver to any MMC card - drivers |
74 | * themselves make the decision whether to drive this card in their | 74 | * themselves make the decision whether to drive this card in their |
75 | * probe method. However, we force "bad" cards to fail. | 75 | * probe method. |
76 | */ | 76 | */ |
77 | static int mmc_bus_match(struct device *dev, struct device_driver *drv) | 77 | static int mmc_bus_match(struct device *dev, struct device_driver *drv) |
78 | { | 78 | { |
79 | struct mmc_card *card = dev_to_mmc_card(dev); | 79 | return 1; |
80 | return !mmc_card_bad(card); | ||
81 | } | 80 | } |
82 | 81 | ||
83 | static int | 82 | static int |
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 800425e05165..badf702fcff4 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h | |||
@@ -69,11 +69,9 @@ struct mmc_card { | |||
69 | #define MMC_TYPE_SD 1 /* SD card */ | 69 | #define MMC_TYPE_SD 1 /* SD card */ |
70 | unsigned int state; /* (our) card state */ | 70 | unsigned int state; /* (our) card state */ |
71 | #define MMC_STATE_PRESENT (1<<0) /* present in sysfs */ | 71 | #define MMC_STATE_PRESENT (1<<0) /* present in sysfs */ |
72 | #define MMC_STATE_DEAD (1<<1) /* device no longer in stack */ | 72 | #define MMC_STATE_READONLY (1<<1) /* card is read-only */ |
73 | #define MMC_STATE_BAD (1<<2) /* unrecognised device */ | 73 | #define MMC_STATE_HIGHSPEED (1<<2) /* card is in high speed mode */ |
74 | #define MMC_STATE_READONLY (1<<3) /* card is read-only */ | 74 | #define MMC_STATE_BLOCKADDR (1<<3) /* card uses block-addressing */ |
75 | #define MMC_STATE_HIGHSPEED (1<<4) /* card is in high speed mode */ | ||
76 | #define MMC_STATE_BLOCKADDR (1<<5) /* card uses block-addressing */ | ||
77 | u32 raw_cid[4]; /* raw card CID */ | 75 | u32 raw_cid[4]; /* raw card CID */ |
78 | u32 raw_csd[4]; /* raw card CSD */ | 76 | u32 raw_csd[4]; /* raw card CSD */ |
79 | u32 raw_scr[2]; /* raw card SCR */ | 77 | u32 raw_scr[2]; /* raw card SCR */ |
@@ -88,15 +86,11 @@ struct mmc_card { | |||
88 | #define mmc_card_sd(c) ((c)->type == MMC_TYPE_SD) | 86 | #define mmc_card_sd(c) ((c)->type == MMC_TYPE_SD) |
89 | 87 | ||
90 | #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT) | 88 | #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT) |
91 | #define mmc_card_dead(c) ((c)->state & MMC_STATE_DEAD) | ||
92 | #define mmc_card_bad(c) ((c)->state & MMC_STATE_BAD) | ||
93 | #define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY) | 89 | #define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY) |
94 | #define mmc_card_highspeed(c) ((c)->state & MMC_STATE_HIGHSPEED) | 90 | #define mmc_card_highspeed(c) ((c)->state & MMC_STATE_HIGHSPEED) |
95 | #define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR) | 91 | #define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR) |
96 | 92 | ||
97 | #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) | 93 | #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) |
98 | #define mmc_card_set_dead(c) ((c)->state |= MMC_STATE_DEAD) | ||
99 | #define mmc_card_set_bad(c) ((c)->state |= MMC_STATE_BAD) | ||
100 | #define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY) | 94 | #define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY) |
101 | #define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED) | 95 | #define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED) |
102 | #define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR) | 96 | #define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR) |