* [PATCH 1/2] mmc: core: Drop superfluous validations in mmc_hw|sw_reset()
[not found] <p2/0002-mmc-core-Drop-reference-counting-of-the-bus_ops.patch>
@ 2021-02-12 13:15 ` Ulf Hansson
2021-02-16 8:32 ` Adrian Hunter
0 siblings, 1 reply; 2+ messages in thread
From: Ulf Hansson @ 2021-02-12 13:15 UTC (permalink / raw)
To: linux-mmc, Ulf Hansson
Cc: Adrian Hunter, Linus Walleij, Wolfram Sang, Pierre Ossman,
Russell King, linux-kernel
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>
---
Note, ideally mmc_hw|sw_reset() shall be converted to take a struct mmc_card*
as an in-parameter, rather than the current struct mmc_host*, but that is left
to a future/separate change.
---
drivers/mmc/core/block.c | 2 +-
drivers/mmc/core/core.c | 21 +--------------------
2 files changed, 2 insertions(+), 21 deletions(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index b877f62df366..b7d3f5a73388 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -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;
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 1136b859ddd8..2e41fa598bd6 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -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);
@@ -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);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/2] mmc: core: Drop superfluous validations in mmc_hw|sw_reset()
2021-02-12 13:15 ` [PATCH 1/2] mmc: core: Drop superfluous validations in mmc_hw|sw_reset() Ulf Hansson
@ 2021-02-16 8:32 ` Adrian Hunter
0 siblings, 0 replies; 2+ messages in thread
From: Adrian Hunter @ 2021-02-16 8:32 UTC (permalink / raw)
To: Ulf Hansson, linux-mmc
Cc: Linus Walleij, Wolfram Sang, Pierre Ossman, Russell King, linux-kernel
On 12/02/21 3:15 pm, Ulf Hansson wrote:
> 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>
> ---
>
> Note, ideally mmc_hw|sw_reset() shall be converted to take a struct mmc_card*
> as an in-parameter, rather than the current struct mmc_host*, but that is left
> to a future/separate change.
>
> ---
> drivers/mmc/core/block.c | 2 +-
> drivers/mmc/core/core.c | 21 +--------------------
> 2 files changed, 2 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index b877f62df366..b7d3f5a73388 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -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;
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 1136b859ddd8..2e41fa598bd6 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -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);
> @@ -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);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-16 8:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <p2/0002-mmc-core-Drop-reference-counting-of-the-bus_ops.patch>
2021-02-12 13:15 ` [PATCH 1/2] mmc: core: Drop superfluous validations in mmc_hw|sw_reset() Ulf Hansson
2021-02-16 8:32 ` Adrian Hunter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).