From 167d41dce7633b70aae4175fdec734e1cdd3a190 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Sat, 23 Mar 2013 11:00:41 +0100 Subject: regulator: Fix typo in of_get_regulator function comments Signed-off-by: Maxime Ripard Signed-off-by: Mark Brown --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index da9782bd27d..edfa2230d47 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -116,7 +116,7 @@ static const char *rdev_get_name(struct regulator_dev *rdev) * @supply: regulator supply name * * Extract the regulator device node corresponding to the supply name. - * retruns the device node corresponding to the regulator if found, else + * returns the device node corresponding to the regulator if found, else * returns NULL. */ static struct device_node *of_get_regulator(struct device *dev, const char *supply) -- cgit v1.2.3 From 0f7b87f0acc04e4f22ec5d3f2283a80993ca3aa8 Mon Sep 17 00:00:00 2001 From: Andrew Bresticker Date: Thu, 4 Apr 2013 15:27:47 -0700 Subject: regulator: core: don't require a supply when supply_name is specified Regulator drivers may specify regulator_desc->supply_name which regulator_register() will use to find the supply node for a regulator. If no supply was specified in the device tree or the supply has yet to be registered regulator_register() will fail, deferring the probe of the regulator. In the case where no supply node was specified in the device tree, there is no supply and it is pointless to try and find one later, so go ahead and add the regulator without the supply. Signed-off-by: Andrew Bresticker Signed-off-by: Mark Brown --- drivers/regulator/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index edfa2230d47..a51e1e5fdff 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3477,7 +3477,14 @@ regulator_register(const struct regulator_desc *regulator_desc, r = regulator_dev_lookup(dev, supply, &ret); - if (!r) { + if (ret == -ENODEV) { + /* + * No supply was specified for this regulator and + * there will never be one. + */ + ret = 0; + goto add_dev; + } else if (!r) { dev_err(dev, "Failed to find supply %s\n", supply); ret = -EPROBE_DEFER; goto scrub; @@ -3495,6 +3502,7 @@ regulator_register(const struct regulator_desc *regulator_desc, } } +add_dev: /* add consumers devices */ if (init_data) { for (i = 0; i < init_data->num_consumer_supplies; i++) { -- cgit v1.2.3 From 1e4b545cdd93318379c6b1fb0a99536fa3260f53 Mon Sep 17 00:00:00 2001 From: Nishanth Menon Date: Tue, 16 Apr 2013 16:45:16 -0500 Subject: regulator: core: return err value for regulator_get if there is no DT binding commit 6d191a5fc7a969d972f1681e1c23781aecb06a61 (regulator: core: Don't defer probe if there's no DT binding for a supply) Attempted to differentiate between regulator_get() with an actual DT binding for the supply and when there is none to avoid unnecessary deferal. However, ret value supplied by regulator_dev_lookup() is being ignored by regulator_get(). So, exit with the appropriate return value. Signed-off-by: Nishanth Menon Signed-off-by: Mark Brown --- drivers/regulator/core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a51e1e5fdff..73edb0ef6e1 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1229,7 +1229,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, struct regulator_dev *rdev; struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); const char *devname = NULL; - int ret; + int ret = 0; if (id == NULL) { pr_err("get() with no identifier\n"); @@ -1245,6 +1245,15 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, if (rdev) goto found; + /* + * If we have return value from dev_lookup fail, we do not expect to + * succeed, so, quit with appropriate error value + */ + if (ret) { + regulator = ERR_PTR(ret); + goto out; + } + if (board_wants_dummy_regulator) { rdev = dummy_regulator_rdev; goto found; -- cgit v1.2.3 From 020501f1a0911af70873e4d3d122b2e1889ccd03 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sat, 27 Apr 2013 13:58:08 +0800 Subject: regulator: Remove NULL test before calling regulator_unregister() It's safe to call regulator_unregister() with NULL, thus remove the NULL test before regulator_unregister() calls. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/max1586.c | 3 +-- drivers/regulator/max8649.c | 6 ++---- drivers/regulator/max8660.c | 3 +-- drivers/regulator/s5m8767.c | 6 ++---- drivers/regulator/tps6524x-regulator.c | 3 +-- 5 files changed, 7 insertions(+), 14 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index 8c5a54f541b..6b2217b404b 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c @@ -232,8 +232,7 @@ static int max1586_pmic_remove(struct i2c_client *client) int i; for (i = 0; i <= MAX1586_V6; i++) - if (max1586->rdev[i]) - regulator_unregister(max1586->rdev[i]); + regulator_unregister(max1586->rdev[i]); return 0; } diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c index 3ca14380f22..f4442700361 100644 --- a/drivers/regulator/max8649.c +++ b/drivers/regulator/max8649.c @@ -275,10 +275,8 @@ static int max8649_regulator_remove(struct i2c_client *client) { struct max8649_regulator_info *info = i2c_get_clientdata(client); - if (info) { - if (info->regulator) - regulator_unregister(info->regulator); - } + if (info) + regulator_unregister(info->regulator); return 0; } diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index 4d7c635c36c..d428ef9a626 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c @@ -426,8 +426,7 @@ static int max8660_remove(struct i2c_client *client) int i; for (i = 0; i < MAX8660_V_END; i++) - if (max8660->rdev[i]) - regulator_unregister(max8660->rdev[i]); + regulator_unregister(max8660->rdev[i]); return 0; } diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 8a831947c35..2dd74e25439 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -923,8 +923,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) return 0; err: for (i = 0; i < s5m8767->num_regulators; i++) - if (rdev[i]) - regulator_unregister(rdev[i]); + regulator_unregister(rdev[i]); return ret; } @@ -936,8 +935,7 @@ static int s5m8767_pmic_remove(struct platform_device *pdev) int i; for (i = 0; i < s5m8767->num_regulators; i++) - if (rdev[i]) - regulator_unregister(rdev[i]); + regulator_unregister(rdev[i]); return 0; } diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c index 843ee0a9bb9..06e92761afd 100644 --- a/drivers/regulator/tps6524x-regulator.c +++ b/drivers/regulator/tps6524x-regulator.c @@ -584,8 +584,7 @@ static int pmic_remove(struct spi_device *spi) if (!hw) return 0; for (i = 0; i < N_REGULATORS; i++) { - if (hw->rdev[i]) - regulator_unregister(hw->rdev[i]); + regulator_unregister(hw->rdev[i]); hw->rdev[i] = NULL; } spi_set_drvdata(spi, NULL); -- cgit v1.2.3