Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751953AbaL1Qih (ORCPT ); Sun, 28 Dec 2014 11:38:37 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:36882 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751809AbaL1Qif (ORCPT ); Sun, 28 Dec 2014 11:38:35 -0500 From: Aniroop Mathur To: , , Cc: , Subject: [PATCH] regulator: core: Avoid negative regulator no & initialize it to -1 Date: Sun, 28 Dec 2014 22:08:38 +0530 Message-Id: <1419784718-3704-1-git-send-email-aniroop.mathur@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/