diff options
Diffstat (limited to 'drivers/mmc/core/mmc.c')
-rw-r--r-- | drivers/mmc/core/mmc.c | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 42cc2867ed7..e4371555160 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include "core.h" | 19 | #include "core.h" |
20 | #include "sysfs.h" | 20 | #include "sysfs.h" |
21 | #include "bus.h" | ||
21 | #include "mmc_ops.h" | 22 | #include "mmc_ops.h" |
22 | 23 | ||
23 | static const unsigned int tran_exp[] = { | 24 | static const unsigned int tran_exp[] = { |
@@ -413,8 +414,7 @@ static void mmc_detect(struct mmc_host *host) | |||
413 | mmc_release_host(host); | 414 | mmc_release_host(host); |
414 | 415 | ||
415 | if (err != MMC_ERR_NONE) { | 416 | if (err != MMC_ERR_NONE) { |
416 | mmc_remove_card(host->card); | 417 | mmc_remove(host); |
417 | host->card = NULL; | ||
418 | 418 | ||
419 | mmc_claim_host(host); | 419 | mmc_claim_host(host); |
420 | mmc_detach_bus(host); | 420 | mmc_detach_bus(host); |
@@ -422,6 +422,53 @@ static void mmc_detect(struct mmc_host *host) | |||
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | MMC_ATTR_FN(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1], | ||
426 | card->raw_cid[2], card->raw_cid[3]); | ||
427 | MMC_ATTR_FN(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1], | ||
428 | card->raw_csd[2], card->raw_csd[3]); | ||
429 | MMC_ATTR_FN(date, "%02d/%04d\n", card->cid.month, card->cid.year); | ||
430 | MMC_ATTR_FN(fwrev, "0x%x\n", card->cid.fwrev); | ||
431 | MMC_ATTR_FN(hwrev, "0x%x\n", card->cid.hwrev); | ||
432 | MMC_ATTR_FN(manfid, "0x%06x\n", card->cid.manfid); | ||
433 | MMC_ATTR_FN(name, "%s\n", card->cid.prod_name); | ||
434 | MMC_ATTR_FN(oemid, "0x%04x\n", card->cid.oemid); | ||
435 | MMC_ATTR_FN(serial, "0x%08x\n", card->cid.serial); | ||
436 | |||
437 | static struct device_attribute mmc_dev_attrs[] = { | ||
438 | MMC_ATTR_RO(cid), | ||
439 | MMC_ATTR_RO(csd), | ||
440 | MMC_ATTR_RO(date), | ||
441 | MMC_ATTR_RO(fwrev), | ||
442 | MMC_ATTR_RO(hwrev), | ||
443 | MMC_ATTR_RO(manfid), | ||
444 | MMC_ATTR_RO(name), | ||
445 | MMC_ATTR_RO(oemid), | ||
446 | MMC_ATTR_RO(serial), | ||
447 | __ATTR_NULL, | ||
448 | }; | ||
449 | |||
450 | /* | ||
451 | * Adds sysfs entries as relevant. | ||
452 | */ | ||
453 | static int mmc_sysfs_add(struct mmc_host *host, struct mmc_card *card) | ||
454 | { | ||
455 | int ret; | ||
456 | |||
457 | ret = mmc_add_attrs(card, mmc_dev_attrs); | ||
458 | if (ret < 0) | ||
459 | return ret; | ||
460 | |||
461 | return 0; | ||
462 | } | ||
463 | |||
464 | /* | ||
465 | * Removes the sysfs entries added by mmc_sysfs_add(). | ||
466 | */ | ||
467 | static void mmc_sysfs_remove(struct mmc_host *host, struct mmc_card *card) | ||
468 | { | ||
469 | mmc_remove_attrs(card, mmc_dev_attrs); | ||
470 | } | ||
471 | |||
425 | #ifdef CONFIG_MMC_UNSAFE_RESUME | 472 | #ifdef CONFIG_MMC_UNSAFE_RESUME |
426 | 473 | ||
427 | /* | 474 | /* |
@@ -455,9 +502,7 @@ static void mmc_resume(struct mmc_host *host) | |||
455 | 502 | ||
456 | err = mmc_sd_init_card(host, host->ocr, host->card); | 503 | err = mmc_sd_init_card(host, host->ocr, host->card); |
457 | if (err != MMC_ERR_NONE) { | 504 | if (err != MMC_ERR_NONE) { |
458 | mmc_remove_card(host->card); | 505 | mmc_remove(host); |
459 | host->card = NULL; | ||
460 | |||
461 | mmc_detach_bus(host); | 506 | mmc_detach_bus(host); |
462 | } | 507 | } |
463 | 508 | ||
@@ -474,6 +519,8 @@ static void mmc_resume(struct mmc_host *host) | |||
474 | static const struct mmc_bus_ops mmc_ops = { | 519 | static const struct mmc_bus_ops mmc_ops = { |
475 | .remove = mmc_remove, | 520 | .remove = mmc_remove, |
476 | .detect = mmc_detect, | 521 | .detect = mmc_detect, |
522 | .sysfs_add = mmc_sysfs_add, | ||
523 | .sysfs_remove = mmc_sysfs_remove, | ||
477 | .suspend = mmc_suspend, | 524 | .suspend = mmc_suspend, |
478 | .resume = mmc_resume, | 525 | .resume = mmc_resume, |
479 | }; | 526 | }; |
@@ -518,7 +565,7 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr) | |||
518 | 565 | ||
519 | mmc_release_host(host); | 566 | mmc_release_host(host); |
520 | 567 | ||
521 | err = mmc_register_card(host->card); | 568 | err = mmc_add_card(host->card); |
522 | if (err) | 569 | if (err) |
523 | goto reclaim_host; | 570 | goto reclaim_host; |
524 | 571 | ||