summaryrefslogtreecommitdiffstats
path: root/drivers/mci
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2018-12-12 23:10:32 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2018-12-17 12:26:14 +0100
commitac6bbe6ab32309218d1806572e0f1f331f9a8dcd (patch)
tree1048413b9066683a3e015f252b63625982082eb7 /drivers/mci
parent7036c933612dc7004b90d7d3c9d1a208d3a22db1 (diff)
downloadbarebox-ac6bbe6ab32309218d1806572e0f1f331f9a8dcd.tar.gz
barebox-ac6bbe6ab32309218d1806572e0f1f331f9a8dcd.tar.xz
mci: Rely on NULL being a dummy regulator
Since NULL, is a dummy regulator, we can drop a bit of error checking logic and simplify the code if we assing host->supply to NULL in case we can't find an appropriate regulator during probing. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mci')
-rw-r--r--drivers/mci/mci-core.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index c8d1d5e164..2693100956 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1650,13 +1650,11 @@ static int mci_card_probe(struct mci *mci)
return -ENODEV;
}
- if (!IS_ERR(host->supply)) {
- ret = regulator_enable(host->supply);
- if (ret) {
- dev_err(&mci->dev, "failed to enable regulator: %s\n",
- strerror(-ret));
- return ret;
- }
+ ret = regulator_enable(host->supply);
+ if (ret) {
+ dev_err(&mci->dev, "failed to enable regulator: %s\n",
+ strerror(-ret));
+ return ret;
}
/* start with a host interface reset */
@@ -1728,8 +1726,7 @@ on_error:
if (rc != 0) {
host->clock = 0; /* disable the MCI clock */
mci_set_ios(mci);
- if (!IS_ERR(host->supply))
- regulator_disable(host->supply);
+ regulator_disable(host->supply);
}
return rc;
@@ -1816,8 +1813,10 @@ int mci_register(struct mci_host *host)
mci->dev.detect = mci_detect;
host->supply = regulator_get(host->hw_dev, "vmmc");
- if (IS_ERR(host->supply))
+ if (IS_ERR(host->supply)) {
dev_err(&mci->dev, "Failed to get 'vmmc' regulator.\n");
+ host->supply = NULL;
+ }
ret = register_device(&mci->dev);
if (ret)