mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] regulator: core: Initialize regulator_no to -1
@ 2014-12-28 15:57 Aniroop Mathur
  0 siblings, 0 replies; only message in thread
From: Aniroop Mathur @ 2014-12-28 15:57 UTC (permalink / raw)
  To: lgirdwood, broonie, linux-kernel; +Cc: aniroop.mathur, a.mathur

From: Aniroop Mathur <a.mathur@samsung.com>

This patch initializes regulator_no to -1 to avoid extra subtraction
operation performed every time we register a regulator.

Signed-off-by: Aniroop Mathur <a.mathur@samsung.com>
---
 drivers/regulator/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a3c3785..4da1d98 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3481,7 +3481,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;
@@ -3551,7 +3551,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
 	rdev->dev.of_node = of_node_get(config->of_node);
 	rdev->dev.parent = dev;
 	dev_set_name(&rdev->dev, "regulator.%d",
-		     atomic_inc_return(&regulator_no) - 1);
+		     atomic_inc_return(&regulator_no));
 	ret = device_register(&rdev->dev);
 	if (ret != 0) {
 		put_device(&rdev->dev);
-- 
1.9.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-12-28 15:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-28 15:57 [PATCH] regulator: core: Initialize regulator_no to -1 Aniroop Mathur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®