diff options
author | Aniroop Mathur <aniroop.mathur@gmail.com> | 2014-12-28 11:38:38 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-12-29 11:08:46 -0500 |
commit | 72dca06f62c50415de3202f204200f58769d0b8b (patch) | |
tree | ba3835f0ae82f33389dbb3896af6473c71b8adb2 /drivers/regulator | |
parent | 97bf6af1f928216fd6c5a66e8a57bfa95a659672 (diff) |
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.c | 6 |
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, | |||
3585 | { | 3585 | { |
3586 | const struct regulation_constraints *constraints = NULL; | 3586 | const struct regulation_constraints *constraints = NULL; |
3587 | const struct regulator_init_data *init_data; | 3587 | const struct regulator_init_data *init_data; |
3588 | static atomic_t regulator_no = ATOMIC_INIT(0); | 3588 | static atomic_t regulator_no = ATOMIC_INIT(-1); |
3589 | struct regulator_dev *rdev; | 3589 | struct regulator_dev *rdev; |
3590 | struct device *dev; | 3590 | struct device *dev; |
3591 | int ret, i; | 3591 | int ret, i; |
@@ -3658,8 +3658,8 @@ regulator_register(const struct regulator_desc *regulator_desc, | |||
3658 | /* register with sysfs */ | 3658 | /* register with sysfs */ |
3659 | rdev->dev.class = ®ulator_class; | 3659 | rdev->dev.class = ®ulator_class; |
3660 | rdev->dev.parent = dev; | 3660 | rdev->dev.parent = dev; |
3661 | dev_set_name(&rdev->dev, "regulator.%d", | 3661 | dev_set_name(&rdev->dev, "regulator.%lu", |
3662 | atomic_inc_return(®ulator_no) - 1); | 3662 | atomic_inc_return(®ulator_no)); |
3663 | ret = device_register(&rdev->dev); | 3663 | ret = device_register(&rdev->dev); |
3664 | if (ret != 0) { | 3664 | if (ret != 0) { |
3665 | put_device(&rdev->dev); | 3665 | put_device(&rdev->dev); |