diff options
author | Pierre Ossman <drzeus@drzeus.cx> | 2007-07-22 11:52:06 -0400 |
---|---|---|
committer | Pierre Ossman <drzeus@drzeus.cx> | 2007-07-25 19:54:06 -0400 |
commit | 2986d0bf23d97d68804ccfa80965073ccf1af242 (patch) | |
tree | 64b3bdcb2642978127582a1fc2ca09e240b1ece5 /drivers/mmc | |
parent | cf795bfb3ad4e2f8f6bb346aa8edb8272d4c70a2 (diff) |
mmc: Don't hold lock when releasing an added card
When the card has been added to the device model, it might be bound
to a card driver. Therefore, we have to release the host lock when
trying to remove it as we otherwise might deadlock with the driver.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/core/mmc.c | 13 | ||||
-rw-r--r-- | drivers/mmc/core/sd.c | 13 |
2 files changed, 16 insertions, 10 deletions
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 1a889e9c5316..cd0c6b246fed 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -499,14 +499,17 @@ static void mmc_resume(struct mmc_host *host) | |||
499 | BUG_ON(!host->card); | 499 | BUG_ON(!host->card); |
500 | 500 | ||
501 | mmc_claim_host(host); | 501 | mmc_claim_host(host); |
502 | |||
503 | err = mmc_init_card(host, host->ocr, host->card); | 502 | err = mmc_init_card(host, host->ocr, host->card); |
503 | mmc_release_host(host); | ||
504 | |||
504 | if (err != MMC_ERR_NONE) { | 505 | if (err != MMC_ERR_NONE) { |
505 | mmc_remove(host); | 506 | mmc_remove(host); |
507 | |||
508 | mmc_claim_host(host); | ||
506 | mmc_detach_bus(host); | 509 | mmc_detach_bus(host); |
510 | mmc_release_host(host); | ||
507 | } | 511 | } |
508 | 512 | ||
509 | mmc_release_host(host); | ||
510 | } | 513 | } |
511 | 514 | ||
512 | #else | 515 | #else |
@@ -567,14 +570,14 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr) | |||
567 | 570 | ||
568 | err = mmc_add_card(host->card); | 571 | err = mmc_add_card(host->card); |
569 | if (err) | 572 | if (err) |
570 | goto reclaim_host; | 573 | goto remove_card; |
571 | 574 | ||
572 | return 0; | 575 | return 0; |
573 | 576 | ||
574 | reclaim_host: | 577 | remove_card: |
575 | mmc_claim_host(host); | ||
576 | mmc_remove_card(host->card); | 578 | mmc_remove_card(host->card); |
577 | host->card = NULL; | 579 | host->card = NULL; |
580 | mmc_claim_host(host); | ||
578 | err: | 581 | err: |
579 | mmc_detach_bus(host); | 582 | mmc_detach_bus(host); |
580 | mmc_release_host(host); | 583 | mmc_release_host(host); |
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index df3bbfea2269..0b478de48acc 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c | |||
@@ -573,14 +573,17 @@ static void mmc_sd_resume(struct mmc_host *host) | |||
573 | BUG_ON(!host->card); | 573 | BUG_ON(!host->card); |
574 | 574 | ||
575 | mmc_claim_host(host); | 575 | mmc_claim_host(host); |
576 | |||
577 | err = mmc_sd_init_card(host, host->ocr, host->card); | 576 | err = mmc_sd_init_card(host, host->ocr, host->card); |
577 | mmc_release_host(host); | ||
578 | |||
578 | if (err != MMC_ERR_NONE) { | 579 | if (err != MMC_ERR_NONE) { |
579 | mmc_sd_remove(host); | 580 | mmc_sd_remove(host); |
581 | |||
582 | mmc_claim_host(host); | ||
580 | mmc_detach_bus(host); | 583 | mmc_detach_bus(host); |
584 | mmc_release_host(host); | ||
581 | } | 585 | } |
582 | 586 | ||
583 | mmc_release_host(host); | ||
584 | } | 587 | } |
585 | 588 | ||
586 | #else | 589 | #else |
@@ -648,14 +651,14 @@ int mmc_attach_sd(struct mmc_host *host, u32 ocr) | |||
648 | 651 | ||
649 | err = mmc_add_card(host->card); | 652 | err = mmc_add_card(host->card); |
650 | if (err) | 653 | if (err) |
651 | goto reclaim_host; | 654 | goto remove_card; |
652 | 655 | ||
653 | return 0; | 656 | return 0; |
654 | 657 | ||
655 | reclaim_host: | 658 | remove_card: |
656 | mmc_claim_host(host); | ||
657 | mmc_remove_card(host->card); | 659 | mmc_remove_card(host->card); |
658 | host->card = NULL; | 660 | host->card = NULL; |
661 | mmc_claim_host(host); | ||
659 | err: | 662 | err: |
660 | mmc_detach_bus(host); | 663 | mmc_detach_bus(host); |
661 | mmc_release_host(host); | 664 | mmc_release_host(host); |