diff options
Diffstat (limited to 'drivers/mmc')
-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 |
3 files changed, 31 insertions, 19 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 |