Commit fbd64f9
mmc: sdhci: Do not invert write-protect twice
mmc_of_parse() reads device property "wp-inverted" and sets
MMC_CAP2_RO_ACTIVE_HIGH if it is true. MMC_CAP2_RO_ACTIVE_HIGH is used
to invert a write-protect (AKA read-only) GPIO value.
sdhci_get_property() also reads "wp-inverted" and sets
SDHCI_QUIRK_INVERTED_WRITE_PROTECT which is used to invert the
write-protect value as well but also acts upon a value read out from the
SDHCI_PRESENT_STATE register.
Many drivers call both mmc_of_parse() and sdhci_get_property(),
so that both MMC_CAP2_RO_ACTIVE_HIGH and
SDHCI_QUIRK_INVERTED_WRITE_PROTECT will be set if the controller has
device property "wp-inverted".
Amend the logic in sdhci_check_ro() to allow for that possibility,
so that the write-protect value is not inverted twice.
Also do not invert the value if it is a negative error value. Note that
callers treat an error the same as not-write-protected, so the result is
functionally the same in that case.
Also do not invert the value if sdhci host operation ->get_ro() is used.
None of the users of that callback set SDHCI_QUIRK_INVERTED_WRITE_PROTECT
directly or indirectly, but two do call mmc_gpio_get_ro(), so leave it to
them to deal with that if they ever set SDHCI_QUIRK_INVERTED_WRITE_PROTECT
in the future.
Fixes: 6d5cd06 ("mmc: sdhci: use WP GPIO in sdhci_check_ro()")
Signed-off-by: Adrian Hunter <[email protected]>
Cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Ulf Hansson <[email protected]>1 parent 84bb8d8 commit fbd64f9
1 file changed
+15
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2515 | 2515 | | |
2516 | 2516 | | |
2517 | 2517 | | |
| 2518 | + | |
2518 | 2519 | | |
2519 | 2520 | | |
2520 | 2521 | | |
2521 | 2522 | | |
2522 | 2523 | | |
2523 | | - | |
| 2524 | + | |
2524 | 2525 | | |
2525 | | - | |
| 2526 | + | |
2526 | 2527 | | |
2527 | | - | |
| 2528 | + | |
2528 | 2529 | | |
2529 | | - | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
2530 | 2533 | | |
2531 | 2534 | | |
| 2535 | + | |
| 2536 | + | |
2532 | 2537 | | |
2533 | 2538 | | |
2534 | 2539 | | |
2535 | | - | |
2536 | | - | |
2537 | | - | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
2538 | 2546 | | |
2539 | 2547 | | |
2540 | 2548 | | |
| |||
0 commit comments