Skip to content

Commit fefdd3c

Browse files
committed
mmc: core: Drop superfluous validations in mmc_hw|sw_reset()
The mmc_hw|sw_reset() APIs are designed to be called solely from upper layers, which means drivers that operates on top of the struct mmc_card, like the mmc block device driver and an SDIO functional driver. Additionally, as long as the struct mmc_host has a valid pointer to a struct mmc_card, the corresponding host->bus_ops pointer stays valid and assigned. For these reasons, let's drop the superfluous reference counting and the redundant validations in mmc_hw|sw_reset(). Signed-off-by: Ulf Hansson <[email protected]> Reviewed-by: Adrian Hunter <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 147186f commit fefdd3c

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

drivers/mmc/core/block.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
947947
md->reset_done |= type;
948948
err = mmc_hw_reset(host);
949949
/* Ensure we switch back to the correct partition */
950-
if (err != -EOPNOTSUPP) {
950+
if (err) {
951951
struct mmc_blk_data *main_md =
952952
dev_get_drvdata(&host->card->dev);
953953
int part_err;

drivers/mmc/core/core.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,18 +2080,7 @@ int mmc_hw_reset(struct mmc_host *host)
20802080
{
20812081
int ret;
20822082

2083-
if (!host->card)
2084-
return -EINVAL;
2085-
2086-
mmc_bus_get(host);
2087-
if (!host->bus_ops || host->bus_dead || !host->bus_ops->hw_reset) {
2088-
mmc_bus_put(host);
2089-
return -EOPNOTSUPP;
2090-
}
2091-
20922083
ret = host->bus_ops->hw_reset(host);
2093-
mmc_bus_put(host);
2094-
20952084
if (ret < 0)
20962085
pr_warn("%s: tried to HW reset card, got error %d\n",
20972086
mmc_hostname(host), ret);
@@ -2104,18 +2093,10 @@ int mmc_sw_reset(struct mmc_host *host)
21042093
{
21052094
int ret;
21062095

2107-
if (!host->card)
2108-
return -EINVAL;
2109-
2110-
mmc_bus_get(host);
2111-
if (!host->bus_ops || host->bus_dead || !host->bus_ops->sw_reset) {
2112-
mmc_bus_put(host);
2096+
if (!host->bus_ops->sw_reset)
21132097
return -EOPNOTSUPP;
2114-
}
21152098

21162099
ret = host->bus_ops->sw_reset(host);
2117-
mmc_bus_put(host);
2118-
21192100
if (ret)
21202101
pr_warn("%s: tried to SW reset card, got error %d\n",
21212102
mmc_hostname(host), ret);

0 commit comments

Comments
 (0)