aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPierre Ossman <drzeus@drzeus.cx>2007-07-22 17:08:30 -0400
committerPierre Ossman <drzeus@drzeus.cx>2007-09-23 03:14:43 -0400
commitadf66a0dc5e8be8d4e64f3c2114f9b175558235b (patch)
treeafb62fc80a700a86a3e7613e1e6652e1e03f95bb /drivers
parent17b0429dde9ab60f9cee8e07ab28c7dc6cfe6efd (diff)
mmc: improve error code feedback
Now that we use "normal" error codes, improve the reporting and response to error codes in the core. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/core/mmc.c27
-rw-r--r--drivers/mmc/core/sd.c22
2 files changed, 36 insertions, 13 deletions
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index fe483d5af744..258fe73eeaa7 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -176,14 +176,20 @@ static int mmc_read_ext_csd(struct mmc_card *card)
176 ext_csd = kmalloc(512, GFP_KERNEL); 176 ext_csd = kmalloc(512, GFP_KERNEL);
177 if (!ext_csd) { 177 if (!ext_csd) {
178 printk(KERN_ERR "%s: could not allocate a buffer to " 178 printk(KERN_ERR "%s: could not allocate a buffer to "
179 "receive the ext_csd. mmc v4 cards will be " 179 "receive the ext_csd.\n", mmc_hostname(card->host));
180 "treated as v3.\n", mmc_hostname(card->host));
181 return -ENOMEM; 180 return -ENOMEM;
182 } 181 }
183 182
184 err = mmc_send_ext_csd(card, ext_csd); 183 err = mmc_send_ext_csd(card, ext_csd);
185 if (err) { 184 if (err) {
186 /* 185 /*
186 * We all hosts that cannot perform the command
187 * to fail more gracefully
188 */
189 if (err != -EINVAL)
190 goto out;
191
192 /*
187 * High capacity cards should have this "magic" size 193 * High capacity cards should have this "magic" size
188 * stored in their CSD. 194 * stored in their CSD.
189 */ 195 */
@@ -199,6 +205,7 @@ static int mmc_read_ext_csd(struct mmc_card *card)
199 mmc_hostname(card->host)); 205 mmc_hostname(card->host));
200 err = 0; 206 err = 0;
201 } 207 }
208
202 goto out; 209 goto out;
203 } 210 }
204 211
@@ -269,8 +276,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
269 goto err; 276 goto err;
270 277
271 if (oldcard) { 278 if (oldcard) {
272 if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0) 279 if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0) {
280 err = -ENOENT;
273 goto err; 281 goto err;
282 }
274 283
275 card = oldcard; 284 card = oldcard;
276 } else { 285 } else {
@@ -278,8 +287,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
278 * Allocate card structure. 287 * Allocate card structure.
279 */ 288 */
280 card = mmc_alloc_card(host); 289 card = mmc_alloc_card(host);
281 if (IS_ERR(card)) 290 if (IS_ERR(card)) {
291 err = PTR_ERR(card);
282 goto err; 292 goto err;
293 }
283 294
284 card->type = MMC_TYPE_MMC; 295 card->type = MMC_TYPE_MMC;
285 card->rca = 1; 296 card->rca = 1;
@@ -304,10 +315,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
304 goto free_card; 315 goto free_card;
305 316
306 err = mmc_decode_csd(card); 317 err = mmc_decode_csd(card);
307 if (err < 0) 318 if (err)
308 goto free_card; 319 goto free_card;
309 err = mmc_decode_cid(card); 320 err = mmc_decode_cid(card);
310 if (err < 0) 321 if (err)
311 goto free_card; 322 goto free_card;
312 } 323 }
313 324
@@ -379,7 +390,7 @@ free_card:
379 mmc_remove_card(card); 390 mmc_remove_card(card);
380err: 391err:
381 392
382 return -EIO; 393 return err;
383} 394}
384 395
385/* 396/*
@@ -587,6 +598,6 @@ err:
587 printk(KERN_ERR "%s: error %d whilst initialising MMC card\n", 598 printk(KERN_ERR "%s: error %d whilst initialising MMC card\n",
588 mmc_hostname(host), err); 599 mmc_hostname(host), err);
589 600
590 return 0; 601 return err;
591} 602}
592 603
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 00895c99d9bb..0a04a6e86ca1 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -213,10 +213,18 @@ static int mmc_read_switch(struct mmc_card *card)
213 213
214 err = mmc_sd_switch(card, 0, 0, 1, status); 214 err = mmc_sd_switch(card, 0, 0, 1, status);
215 if (err) { 215 if (err) {
216 /*
217 * We all hosts that cannot perform the command
218 * to fail more gracefully
219 */
220 if (err != -EINVAL)
221 goto out;
222
216 printk(KERN_WARNING "%s: problem reading switch " 223 printk(KERN_WARNING "%s: problem reading switch "
217 "capabilities, performance might suffer.\n", 224 "capabilities, performance might suffer.\n",
218 mmc_hostname(card->host)); 225 mmc_hostname(card->host));
219 err = 0; 226 err = 0;
227
220 goto out; 228 goto out;
221 } 229 }
222 230
@@ -324,8 +332,10 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
324 goto err; 332 goto err;
325 333
326 if (oldcard) { 334 if (oldcard) {
327 if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0) 335 if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0) {
336 err = -ENOENT;
328 goto err; 337 goto err;
338 }
329 339
330 card = oldcard; 340 card = oldcard;
331 } else { 341 } else {
@@ -333,8 +343,10 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
333 * Allocate card structure. 343 * Allocate card structure.
334 */ 344 */
335 card = mmc_alloc_card(host); 345 card = mmc_alloc_card(host);
336 if (IS_ERR(card)) 346 if (IS_ERR(card)) {
347 err = PTR_ERR(card);
337 goto err; 348 goto err;
349 }
338 350
339 card->type = MMC_TYPE_SD; 351 card->type = MMC_TYPE_SD;
340 memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); 352 memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
@@ -358,7 +370,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
358 goto free_card; 370 goto free_card;
359 371
360 err = mmc_decode_csd(card); 372 err = mmc_decode_csd(card);
361 if (err < 0) 373 if (err)
362 goto free_card; 374 goto free_card;
363 375
364 mmc_decode_cid(card); 376 mmc_decode_cid(card);
@@ -449,7 +461,7 @@ free_card:
449 mmc_remove_card(card); 461 mmc_remove_card(card);
450err: 462err:
451 463
452 return -EIO; 464 return err;
453} 465}
454 466
455/* 467/*
@@ -666,6 +678,6 @@ err:
666 printk(KERN_ERR "%s: error %d whilst initialising SD card\n", 678 printk(KERN_ERR "%s: error %d whilst initialising SD card\n",
667 mmc_hostname(host), err); 679 mmc_hostname(host), err);
668 680
669 return 0; 681 return err;
670} 682}
671 683