Skip to content

Commit 8d46e04

Browse files
author
Ulf Hansson
committed
mmc: Merge branch fixes into next
Merge the mmc fixes for v6.10-rc[n] into the next branch, to allow them to get tested together with the new mmc changes that are targeted for v6.11. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2 parents 1f14028 + ab069ce commit 8d46e04

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

drivers/mmc/host/sdhci.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,26 +2515,29 @@ EXPORT_SYMBOL_GPL(sdhci_get_cd_nogpio);
25152515

25162516
static int sdhci_check_ro(struct sdhci_host *host)
25172517
{
2518-
unsigned long flags;
2518+
bool allow_invert = false;
25192519
int is_readonly;
25202520

2521-
spin_lock_irqsave(&host->lock, flags);
2522-
2523-
if (host->flags & SDHCI_DEVICE_DEAD)
2521+
if (host->flags & SDHCI_DEVICE_DEAD) {
25242522
is_readonly = 0;
2525-
else if (host->ops->get_ro)
2523+
} else if (host->ops->get_ro) {
25262524
is_readonly = host->ops->get_ro(host);
2527-
else if (mmc_can_gpio_ro(host->mmc))
2525+
} else if (mmc_can_gpio_ro(host->mmc)) {
25282526
is_readonly = mmc_gpio_get_ro(host->mmc);
2529-
else
2527+
/* Do not invert twice */
2528+
allow_invert = !(host->mmc->caps2 & MMC_CAP2_RO_ACTIVE_HIGH);
2529+
} else {
25302530
is_readonly = !(sdhci_readl(host, SDHCI_PRESENT_STATE)
25312531
& SDHCI_WRITE_PROTECT);
2532+
allow_invert = true;
2533+
}
25322534

2533-
spin_unlock_irqrestore(&host->lock, flags);
2535+
if (is_readonly >= 0 &&
2536+
allow_invert &&
2537+
(host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT))
2538+
is_readonly = !is_readonly;
25342539

2535-
/* This quirk needs to be replaced by a callback-function later */
2536-
return host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT ?
2537-
!is_readonly : is_readonly;
2540+
return is_readonly;
25382541
}
25392542

25402543
#define SAMPLE_COUNT 5

0 commit comments

Comments
 (0)