Commit 9116752f authored by Ulf Hansson's avatar Ulf Hansson

mmc: core: Return error at failure of request CD/WP in mmc_of_parse()

Instead of just printing an error when mmc_of_parse() fails to request
CD/WP GPIO pins, let's propagate all errors, except for -ENOENT.
Earlier only -EPROBE_DEFER was handled correctly.

As a side effect of this change and by relying on host drivers to
handle the errors during ->probe(), we don't need to free any data in
the error path.

This also means we are actually fixing a bug, since we remove the call
to mmc_gpio_free_cd() which wasn't the correct function to invoke to
handle cleanup. Instead that should have been mmc_gpiod_free_cd().
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent fc702cb3
...@@ -367,16 +367,10 @@ int mmc_of_parse(struct mmc_host *host) ...@@ -367,16 +367,10 @@ int mmc_of_parse(struct mmc_host *host)
ret = mmc_gpiod_request_cd(host, "cd", 0, true, ret = mmc_gpiod_request_cd(host, "cd", 0, true,
0, &cd_gpio_invert); 0, &cd_gpio_invert);
if (ret) { if (!ret)
if (ret == -EPROBE_DEFER)
return ret;
if (ret != -ENOENT) {
dev_err(host->parent,
"Failed to request CD GPIO: %d\n",
ret);
}
} else
dev_info(host->parent, "Got CD GPIO\n"); dev_info(host->parent, "Got CD GPIO\n");
else if (ret != -ENOENT)
return ret;
/* /*
* There are two ways to flag that the CD line is inverted: * There are two ways to flag that the CD line is inverted:
...@@ -397,16 +391,10 @@ int mmc_of_parse(struct mmc_host *host) ...@@ -397,16 +391,10 @@ int mmc_of_parse(struct mmc_host *host)
ro_cap_invert = of_property_read_bool(np, "wp-inverted"); ro_cap_invert = of_property_read_bool(np, "wp-inverted");
ret = mmc_gpiod_request_ro(host, "wp", 0, false, 0, &ro_gpio_invert); ret = mmc_gpiod_request_ro(host, "wp", 0, false, 0, &ro_gpio_invert);
if (ret) { if (!ret)
if (ret == -EPROBE_DEFER)
goto out;
if (ret != -ENOENT) {
dev_err(host->parent,
"Failed to request WP GPIO: %d\n",
ret);
}
} else
dev_info(host->parent, "Got WP GPIO\n"); dev_info(host->parent, "Got WP GPIO\n");
else if (ret != -ENOENT)
return ret;
/* See the comment on CD inversion above */ /* See the comment on CD inversion above */
if (ro_cap_invert ^ ro_gpio_invert) if (ro_cap_invert ^ ro_gpio_invert)
...@@ -458,10 +446,6 @@ int mmc_of_parse(struct mmc_host *host) ...@@ -458,10 +446,6 @@ int mmc_of_parse(struct mmc_host *host)
} }
return 0; return 0;
out:
mmc_gpio_free_cd(host);
return ret;
} }
EXPORT_SYMBOL(mmc_of_parse); EXPORT_SYMBOL(mmc_of_parse);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment