LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] regulator: core: Avoid negative regulator no & initialize it to -1
@ 2014-12-28 16:38 Aniroop Mathur
2014-12-29 16:08 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Aniroop Mathur @ 2014-12-28 16:38 UTC (permalink / raw)
To: lgirdwood, broonie, linux-kernel; +Cc: aniroop.mathur, a.mathur
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>
---
drivers/regulator/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a3c3785..b0729ef 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;
@@ -3550,8 +3550,8 @@ regulator_register(const struct regulator_desc *regulator_desc,
rdev->dev.class = ®ulator_class;
rdev->dev.of_node = of_node_get(config->of_node);
rdev->dev.parent = dev;
- dev_set_name(&rdev->dev, "regulator.%d",
- atomic_inc_return(®ulator_no) - 1);
+ dev_set_name(&rdev->dev, "regulator.%lu",
+ atomic_inc_return(®ulator_no));
ret = device_register(&rdev->dev);
if (ret != 0) {
put_device(&rdev->dev);
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: core: Avoid negative regulator no & initialize it to -1
2014-12-28 16:38 [PATCH] regulator: core: Avoid negative regulator no & initialize it to -1 Aniroop Mathur
@ 2014-12-29 16:08 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2014-12-29 16:08 UTC (permalink / raw)
To: Aniroop Mathur; +Cc: lgirdwood, linux-kernel, a.mathur
[-- Attachment #1: Type: text/plain, Size: 257 bytes --]
On Sun, Dec 28, 2014 at 10:08:38PM +0530, Aniroop Mathur wrote:
> 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.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-29 16:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-28 16:38 [PATCH] regulator: core: Avoid negative regulator no & initialize it to -1 Aniroop Mathur
2014-12-29 16:08 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).