aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorAniroop Mathur <aniroop.mathur@gmail.com>2014-12-28 22:08:38 +0530
committerMark Brown <broonie@kernel.org>2014-12-29 16:08:46 +0000
commit72dca06f62c50415de3202f204200f58769d0b8b (patch)
treeba3835f0ae82f33389dbb3896af6473c71b8adb2 /drivers/regulator
parentLinux 3.19-rc1 (diff)
downloadlinux-dev-72dca06f62c50415de3202f204200f58769d0b8b.tar.xz
linux-dev-72dca06f62c50415de3202f204200f58769d0b8b.zip
regulator: core: Avoid negative regulator no & initialize it to -1
This patch initializes regulator_no to -1 to avoid extra subtraction operation performed every time we register a regulator and avoid negative regulator no in its name. Signed-off-by: Aniroop Mathur <a.mathur@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/core.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e225711bb8bc..4bc5ea9721c2 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3585,7 +3585,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
{
const struct regulation_constraints *constraints = NULL;
const struct regulator_init_data *init_data;
- static atomic_t regulator_no = ATOMIC_INIT(0);
+ static atomic_t regulator_no = ATOMIC_INIT(-1);
struct regulator_dev *rdev;
struct device *dev;
int ret, i;
@@ -3658,8 +3658,8 @@ regulator_register(const struct regulator_desc *regulator_desc,
/* register with sysfs */
rdev->dev.class = &regulator_class;
rdev->dev.parent = dev;
- dev_set_name(&rdev->dev, "regulator.%d",
- atomic_inc_return(&regulator_no) - 1);
+ dev_set_name(&rdev->dev, "regulator.%lu",
+ atomic_inc_return(&regulator_no));
ret = device_register(&rdev->dev);
if (ret != 0) {
put_device(&rdev->dev);