Skip to content

Commit

Permalink
mmc: core: Drop superfluous validations in mmc_hw|sw_reset()
Browse files Browse the repository at this point in the history
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 <ulf.hansson@linaro.org>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20210212131532.236775-1-ulf.hansson@linaro.org
  • Loading branch information
Ulf Hansson committed Mar 30, 2021
1 parent 147186f commit fefdd3c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
2 changes: 1 addition & 1 deletion drivers/mmc/core/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
md->reset_done |= type;
err = mmc_hw_reset(host);
/* Ensure we switch back to the correct partition */
if (err != -EOPNOTSUPP) {
if (err) {
struct mmc_blk_data *main_md =
dev_get_drvdata(&host->card->dev);
int part_err;
Expand Down
21 changes: 1 addition & 20 deletions drivers/mmc/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2080,18 +2080,7 @@ int mmc_hw_reset(struct mmc_host *host)
{
int ret;

if (!host->card)
return -EINVAL;

mmc_bus_get(host);
if (!host->bus_ops || host->bus_dead || !host->bus_ops->hw_reset) {
mmc_bus_put(host);
return -EOPNOTSUPP;
}

ret = host->bus_ops->hw_reset(host);
mmc_bus_put(host);

if (ret < 0)
pr_warn("%s: tried to HW reset card, got error %d\n",
mmc_hostname(host), ret);
Expand All @@ -2104,18 +2093,10 @@ int mmc_sw_reset(struct mmc_host *host)
{
int ret;

if (!host->card)
return -EINVAL;

mmc_bus_get(host);
if (!host->bus_ops || host->bus_dead || !host->bus_ops->sw_reset) {
mmc_bus_put(host);
if (!host->bus_ops->sw_reset)
return -EOPNOTSUPP;
}

ret = host->bus_ops->sw_reset(host);
mmc_bus_put(host);

if (ret)
pr_warn("%s: tried to SW reset card, got error %d\n",
mmc_hostname(host), ret);
Expand Down

0 comments on commit fefdd3c

Please sign in to comment.