Skip to contentSkip to conversation

regulator: Remove a redundant device_remove_file call in create_regulator

PATCH In review Axel Lin 2 participants 6 messages Nov 5, 2010 Voltage and current regulator framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/3 regulator: Remove a redundant device_remove_file call in create_regulator

We already have device_remove_file() in error path, no need to call it before goto link_name_err.

---
 drivers/regulator/core.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/regulator/core.c +0 -1
index f1d10c9..5ee67ba 100644
@@ -1052,7 +1052,6 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
 			printk(KERN_WARNING
 			       "%s: could not add device link %s err %d\n",
 			       __func__, dev->kobj.name, err);
-			device_remove_file(dev, &regulator->dev_attr);
 			goto link_name_err;
 		}
 	}
Signature · 1 line
1.7.2
author
#1 lore raw

PATCH 2/3 regulator: Ensure enough delay time for enabling regulator

Integer division will truncate the result, this patch ensures we have enough delay time for enabling regulator.

---
 drivers/regulator/core.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/regulator/core.c +3 -2
index 5ee67ba..0dd9a57 100644
@@ -1312,9 +1312,10 @@ static int _regulator_enable(struct regulator_dev *rdev)
 			if (ret < 0)
 				return ret;
 
-			if (delay >= 1000)
+			if (delay >= 1000) {
 				mdelay(delay / 1000);
-			else if (delay)
+				udelay(delay % 1000);
+			} else if (delay)
 				udelay(delay);
 
 		} else if (ret < 0) {
Signature · 1 line
1.7.2
#2 lore raw

Re: [PATCH 2/3] regulator: Ensure enough delay time for enabling regulator

drivers/regulator/core.c static int _regulator_enable(struct regulator_dev *rdev) · line 1319

Quoted 7 lines · Axel Lin
drivers/regulator/core.c +3 -2
-			if (delay >= 1000)
+			if (delay >= 1000) {
 				mdelay(delay / 1000);
-			else if (delay)
+				udelay(delay % 1000);
+			} else if (delay)
 				udelay(delay);

This looks good but please change this to use { } in the else case also; I find this very helpful for legibility.

author
#3 lore raw

PATCH 3/3 regulator: Return proper error for regulator_register()

In reply to Axel Lin
---
 drivers/regulator/core.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/regulator/core.c +2 -0
index 0dd9a57..59a7119 100644
@@ -2346,6 +2346,7 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
 	if (init_data->supply_regulator && init_data->supply_regulator_dev) {
 		dev_err(dev,
 			"Supply regulator specified by both name and dev\n");
+		ret = -EINVAL;
 		goto scrub;
 	}
 
@@ -2364,6 +2365,7 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
 		if (!found) {
 			dev_err(dev, "Failed to find supply %s\n",
 				init_data->supply_regulator);
+			ret = -ENODEV;
 			goto scrub;
 		}
 
Signature · 1 line
1.7.2