Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: core: Initiate suspend|resume from mmc bus instead of mmc host

The host should be responsible to suspend|resume the host and not the
card. This patch changes this behaviour, by moving the responsiblity
to the mmc bus instead which already holds the card device.

The exported functions mmc_suspend|resume_host are now to be considered
as depcrecated. Once all host drivers moves away from using them, we
can remove them. As of now, a successful error code is always returned.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Chris Ball <cjb@laptop.org>

authored by

Ulf Hansson and committed by
Chris Ball
986892ca 74590263

+19 -26
+16 -3
drivers/mmc/core/bus.c
··· 127 127 { 128 128 struct mmc_driver *drv = to_mmc_driver(dev->driver); 129 129 struct mmc_card *card = mmc_dev_to_card(dev); 130 - int ret = 0; 130 + struct mmc_host *host = card->host; 131 + int ret; 131 132 132 - if (dev->driver && drv->suspend) 133 + if (dev->driver && drv->suspend) { 133 134 ret = drv->suspend(card); 135 + if (ret) 136 + return ret; 137 + } 138 + 139 + ret = host->bus_ops->suspend(host); 134 140 return ret; 135 141 } 136 142 ··· 144 138 { 145 139 struct mmc_driver *drv = to_mmc_driver(dev->driver); 146 140 struct mmc_card *card = mmc_dev_to_card(dev); 147 - int ret = 0; 141 + struct mmc_host *host = card->host; 142 + int ret; 143 + 144 + ret = host->bus_ops->resume(host); 145 + if (ret) 146 + pr_warn("%s: error %d during resume (card was removed?)\n", 147 + mmc_hostname(host), ret); 148 148 149 149 if (dev->driver && drv->resume) 150 150 ret = drv->resume(card); 151 + 151 152 return ret; 152 153 } 153 154 #endif
+3 -23
drivers/mmc/core/core.c
··· 2619 2619 */ 2620 2620 int mmc_suspend_host(struct mmc_host *host) 2621 2621 { 2622 - int err = 0; 2623 - 2624 - mmc_bus_get(host); 2625 - if (host->bus_ops && !host->bus_dead) { 2626 - if (host->bus_ops->suspend) 2627 - err = host->bus_ops->suspend(host); 2628 - } 2629 - mmc_bus_put(host); 2630 - 2631 - return err; 2622 + /* This function is deprecated */ 2623 + return 0; 2632 2624 } 2633 2625 EXPORT_SYMBOL(mmc_suspend_host); 2634 2626 ··· 2630 2638 */ 2631 2639 int mmc_resume_host(struct mmc_host *host) 2632 2640 { 2633 - int err; 2634 - 2635 - mmc_bus_get(host); 2636 - if (host->bus_ops && !host->bus_dead) { 2637 - BUG_ON(!host->bus_ops->resume); 2638 - err = host->bus_ops->resume(host); 2639 - if (err) 2640 - pr_warning("%s: error %d during resume " 2641 - "(card was removed?)\n", 2642 - mmc_hostname(host), err); 2643 - } 2644 - mmc_bus_put(host); 2645 - 2641 + /* This function is deprecated */ 2646 2642 return 0; 2647 2643 } 2648 2644 EXPORT_SYMBOL(mmc_resume_host);