aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mmc/core/mmc.c41
-rw-r--r--drivers/mmc/core/sd.c41
-rw-r--r--include/linux/mmc/host.h1
3 files changed, 69 insertions, 14 deletions
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 2fb9d5f271ea..995db1853a81 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -507,8 +507,6 @@ static void mmc_detect(struct mmc_host *host)
507 } 507 }
508} 508}
509 509
510#ifdef CONFIG_MMC_UNSAFE_RESUME
511
512/* 510/*
513 * Suspend callback from host. 511 * Suspend callback from host.
514 */ 512 */
@@ -551,20 +549,49 @@ static void mmc_resume(struct mmc_host *host)
551 549
552} 550}
553 551
554#else 552#ifdef CONFIG_MMC_UNSAFE_RESUME
555 553
556#define mmc_suspend NULL 554static const struct mmc_bus_ops mmc_ops = {
557#define mmc_resume NULL 555 .remove = mmc_remove,
556 .detect = mmc_detect,
557 .suspend = mmc_suspend,
558 .resume = mmc_resume,
559};
558 560
559#endif 561static void mmc_attach_bus_ops(struct mmc_host *host)
562{
563 mmc_attach_bus(host, &mmc_ops);
564}
565
566#else
560 567
561static const struct mmc_bus_ops mmc_ops = { 568static const struct mmc_bus_ops mmc_ops = {
562 .remove = mmc_remove, 569 .remove = mmc_remove,
563 .detect = mmc_detect, 570 .detect = mmc_detect,
571 .suspend = NULL,
572 .resume = NULL,
573};
574
575static const struct mmc_bus_ops mmc_ops_unsafe = {
576 .remove = mmc_remove,
577 .detect = mmc_detect,
564 .suspend = mmc_suspend, 578 .suspend = mmc_suspend,
565 .resume = mmc_resume, 579 .resume = mmc_resume,
566}; 580};
567 581
582static void mmc_attach_bus_ops(struct mmc_host *host)
583{
584 const struct mmc_bus_ops *bus_ops;
585
586 if (host->caps & MMC_CAP_NONREMOVABLE)
587 bus_ops = &mmc_ops_unsafe;
588 else
589 bus_ops = &mmc_ops;
590 mmc_attach_bus(host, bus_ops);
591}
592
593#endif
594
568/* 595/*
569 * Starting point for MMC card init. 596 * Starting point for MMC card init.
570 */ 597 */
@@ -575,7 +602,7 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
575 BUG_ON(!host); 602 BUG_ON(!host);
576 WARN_ON(!host->claimed); 603 WARN_ON(!host->claimed);
577 604
578 mmc_attach_bus(host, &mmc_ops); 605 mmc_attach_bus_ops(host);
579 606
580 /* 607 /*
581 * We need to get OCR a different way for SPI. 608 * We need to get OCR a different way for SPI.
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 7ad646fe077e..92fa9dceca79 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -561,8 +561,6 @@ static void mmc_sd_detect(struct mmc_host *host)
561 } 561 }
562} 562}
563 563
564#ifdef CONFIG_MMC_UNSAFE_RESUME
565
566/* 564/*
567 * Suspend callback from host. 565 * Suspend callback from host.
568 */ 566 */
@@ -605,20 +603,49 @@ static void mmc_sd_resume(struct mmc_host *host)
605 603
606} 604}
607 605
608#else 606#ifdef CONFIG_MMC_UNSAFE_RESUME
609 607
610#define mmc_sd_suspend NULL 608static const struct mmc_bus_ops mmc_sd_ops = {
611#define mmc_sd_resume NULL 609 .remove = mmc_sd_remove,
610 .detect = mmc_sd_detect,
611 .suspend = mmc_sd_suspend,
612 .resume = mmc_sd_resume,
613};
612 614
613#endif 615static void mmc_sd_attach_bus_ops(struct mmc_host *host)
616{
617 mmc_attach_bus(host, &mmc_sd_ops);
618}
619
620#else
614 621
615static const struct mmc_bus_ops mmc_sd_ops = { 622static const struct mmc_bus_ops mmc_sd_ops = {
616 .remove = mmc_sd_remove, 623 .remove = mmc_sd_remove,
617 .detect = mmc_sd_detect, 624 .detect = mmc_sd_detect,
625 .suspend = NULL,
626 .resume = NULL,
627};
628
629static const struct mmc_bus_ops mmc_sd_ops_unsafe = {
630 .remove = mmc_sd_remove,
631 .detect = mmc_sd_detect,
618 .suspend = mmc_sd_suspend, 632 .suspend = mmc_sd_suspend,
619 .resume = mmc_sd_resume, 633 .resume = mmc_sd_resume,
620}; 634};
621 635
636static void mmc_sd_attach_bus_ops(struct mmc_host *host)
637{
638 const struct mmc_bus_ops *bus_ops;
639
640 if (host->caps & MMC_CAP_NONREMOVABLE)
641 bus_ops = &mmc_sd_ops_unsafe;
642 else
643 bus_ops = &mmc_sd_ops;
644 mmc_attach_bus(host, bus_ops);
645}
646
647#endif
648
622/* 649/*
623 * Starting point for SD card init. 650 * Starting point for SD card init.
624 */ 651 */
@@ -629,7 +656,7 @@ int mmc_attach_sd(struct mmc_host *host, u32 ocr)
629 BUG_ON(!host); 656 BUG_ON(!host);
630 WARN_ON(!host->claimed); 657 WARN_ON(!host->claimed);
631 658
632 mmc_attach_bus(host, &mmc_sd_ops); 659 mmc_sd_attach_bus_ops(host);
633 660
634 /* 661 /*
635 * We need to get OCR a different way for SPI. 662 * We need to get OCR a different way for SPI.
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 631a2fea5264..bb867d2c26bd 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -148,6 +148,7 @@ struct mmc_host {
148#define MMC_CAP_NEEDS_POLL (1 << 5) /* Needs polling for card-detection */ 148#define MMC_CAP_NEEDS_POLL (1 << 5) /* Needs polling for card-detection */
149#define MMC_CAP_8_BIT_DATA (1 << 6) /* Can the host do 8 bit transfers */ 149#define MMC_CAP_8_BIT_DATA (1 << 6) /* Can the host do 8 bit transfers */
150#define MMC_CAP_DISABLE (1 << 7) /* Can the host be disabled */ 150#define MMC_CAP_DISABLE (1 << 7) /* Can the host be disabled */
151#define MMC_CAP_NONREMOVABLE (1 << 8) /* Nonremovable e.g. eMMC */
151 152
152 /* host specific block data */ 153 /* host specific block data */
153 unsigned int max_seg_size; /* see blk_queue_max_segment_size */ 154 unsigned int max_seg_size; /* see blk_queue_max_segment_size */