[PATCH 2/3] mci: Rely on NULL being a dummy regulator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 drivers/mci/mci-core.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 3efd80a8a..c71d91fd0 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)
-- 
2.19.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux