Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85411643 authored by Pradosh Das's avatar Pradosh Das
Browse files

Revert "Revert "mmc: core: Update SD card removal logic based on cd gpio state""



This reverts commit b0685665.

Change-Id: I8a5c30e75fc6c2bf7f92f11b9c82484685bd4dad
Signed-off-by: default avatarPradosh Das <prados@codeaurora.org>
parent a63c4e46
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -4725,9 +4725,7 @@ static int mmc_blk_probe(struct mmc_card *card)

	dev_set_drvdata(&card->dev, md);

#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
	mmc_set_bus_resume_policy(card->host, 1);
#endif

	if (mmc_add_disk(md))
		goto out;
@@ -4772,9 +4770,7 @@ static void mmc_blk_remove(struct mmc_card *card)
	pm_runtime_put_noidle(&card->dev);
	mmc_blk_remove_req(md);
	dev_set_drvdata(&card->dev, NULL);
#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
	mmc_set_bus_resume_policy(card->host, 0);
#endif
}

static int _mmc_blk_suspend(struct mmc_card *card, bool wait)
+10 −7
Original line number Diff line number Diff line
@@ -1883,10 +1883,9 @@ EXPORT_SYMBOL(mmc_start_req);
 */
void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
{
#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
	if (mmc_bus_needs_resume(host))
		mmc_resume_bus(host);
#endif

	__mmc_start_req(host, mrq);
	mmc_wait_for_req_done(host, mrq);
}
@@ -2322,10 +2321,9 @@ void mmc_get_card(struct mmc_card *card)
{
	pm_runtime_get_sync(&card->dev);
	mmc_claim_host(card->host);
#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME

	if (mmc_bus_needs_resume(card->host))
		mmc_resume_bus(card->host);
#endif
}
EXPORT_SYMBOL(mmc_get_card);

@@ -3277,6 +3275,7 @@ int mmc_resume_bus(struct mmc_host *host)
{
	unsigned long flags;
	int err = 0;
	int card_present = true;

	if (!mmc_bus_needs_resume(host))
		return -EINVAL;
@@ -3287,7 +3286,10 @@ int mmc_resume_bus(struct mmc_host *host)
	spin_unlock_irqrestore(&host->lock, flags);

	mmc_bus_get(host);
	if (host->bus_ops && !host->bus_dead && host->card) {
	if (host->ops->get_cd)
		card_present = host->ops->get_cd(host);

	if (host->bus_ops && !host->bus_dead && host->card && card_present) {
		mmc_power_up(host, host->card->ocr);
		BUG_ON(!host->bus_ops->resume);
		err = host->bus_ops->resume(host);
@@ -4523,7 +4525,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,
	struct mmc_host *host = container_of(
		notify_block, struct mmc_host, pm_notify);
	unsigned long flags;
	int err = 0;
	int err = 0, present = 0;

	switch (mode) {
	case PM_RESTORE_PREPARE:
@@ -4574,7 +4576,8 @@ int mmc_pm_notify(struct notifier_block *notify_block,
			present = !!mmc_gpio_get_cd(host);

		if (mmc_bus_manual_resume(host) &&
				!host->ignore_bus_resume_flags) {
				!host->ignore_bus_resume_flags &&
				present) {
			spin_unlock_irqrestore(&host->lock, flags);
			break;
		}
+21 −1
Original line number Diff line number Diff line
@@ -1143,6 +1143,9 @@ static void mmc_sd_remove(struct mmc_host *host)
 */
static int mmc_sd_alive(struct mmc_host *host)
{
	if (host->ops->get_cd && !host->ops->get_cd(host))
		return -ENOMEDIUM;

	return mmc_send_status(host->card, NULL);
}

@@ -1171,7 +1174,15 @@ static void mmc_sd_detect(struct mmc_host *host)
		return;
	}

	mmc_power_up(host, host->ocr_avail);
	if (mmc_bus_needs_resume(host))
		mmc_resume_bus(host);

	if (host->ops->get_cd && !host->ops->get_cd(host)) {
		err = -ENOMEDIUM;
		mmc_card_set_removed(host->card);
		mmc_card_clr_suspended(host->card);
		goto out;
	}

	/*
	 * Just check if our card has been removed.
@@ -1195,6 +1206,7 @@ static void mmc_sd_detect(struct mmc_host *host)
	err = _mmc_detect_card_removed(host);
#endif

out:
	mmc_put_card(host->card);

	if (err) {
@@ -1279,6 +1291,11 @@ static int _mmc_sd_resume(struct mmc_host *host)
	if (!mmc_card_suspended(host->card))
		goto out;

	if (host->ops->get_cd && !host->ops->get_cd(host)) {
		mmc_card_clr_suspended(host->card);
		goto out;
	}

	mmc_power_up(host, host->card->ocr);
#ifdef CONFIG_MMC_PARANOID_SD_INIT
	retries = 5;
@@ -1379,6 +1396,9 @@ static int mmc_sd_runtime_resume(struct mmc_host *host)

static int mmc_sd_reset(struct mmc_host *host)
{
	if (host->ops->get_cd && !host->ops->get_cd(host))
		return -ENOMEDIUM;

	mmc_power_cycle(host, host->card->ocr);
	return mmc_sd_init_card(host, host->card->ocr, host->card);
}
+4 −0
Original line number Diff line number Diff line
@@ -34,6 +34,10 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id)
{
	/* Schedule a card detection after a debounce timeout */
	struct mmc_host *host = dev_id;
	int present = host->ops->get_cd(host);

	pr_debug("%s: cd gpio irq, gpio state %d (CARD_%s)\n",
		mmc_hostname(host), present, present?"INSERT":"REMOVAL");

	host->trigger_card_event = true;
	mmc_detect_change(host, msecs_to_jiffies(200));
+6 −0
Original line number Diff line number Diff line
@@ -643,6 +643,7 @@ static inline void *mmc_cmdq_private(struct mmc_host *host)
#define mmc_bus_manual_resume(host) ((host)->bus_resume_flags & \
				MMC_BUSRESUME_MANUAL_RESUME)

#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
static inline void mmc_set_bus_resume_policy(struct mmc_host *host, int manual)
{
	if (manual)
@@ -650,6 +651,11 @@ static inline void mmc_set_bus_resume_policy(struct mmc_host *host, int manual)
	else
		host->bus_resume_flags &= ~MMC_BUSRESUME_MANUAL_RESUME;
}
#else
static inline void mmc_set_bus_resume_policy(struct mmc_host *host, int manual)
{
}
#endif

extern int mmc_resume_bus(struct mmc_host *host);