From patchwork Thu Jul 16 18:16:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 51200 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3DE7D22A8A for ; Thu, 16 Jul 2015 18:21:10 +0000 (UTC) Received: by widic2 with SMTP id ic2sf6481587wid.1 for ; Thu, 16 Jul 2015 11:21:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=LZgdfH3YWmBHqTnhfsUuRcc4nThcaqAFovqdnnd/kTE=; b=KBiPJo6+M28sGLfKd1JgJmvRjQ70mxyQaMRLvgTJQSO2qluHHTobMEnqu89+jIQFQj A+Z6N3UCNyvrAOxL2u6ptFuasbGx0pcTCeR+B4xF492hpYfZzlzMsHsNZOXWJV5e9viX rQ+F0H8f1Cn7b3W0hUYT/mWg2aTQAfmCVcYitQTaRHVMdK0F1j2fT3NGWevFNK8RdprH yVignLwkf8yy7sVAhtl8aUAeMIehZNbbl7pMNxr4aIf8i1FZZNsDo7rSIISE0VOKNJzT seHBKQOWyolmoPX2kVSR2tXsyYkps6xDrZjLuVyTCqh/DyG3n1aGyIf0ZuQnpmwVX+67 g5Eg== X-Gm-Message-State: ALoCoQlpqs1VEpqwvyG1xYApvDz4kxdxCq9MgOGYslCzAjZ3vlJScJQwyVhLKqmFW01JwpjtSQjr X-Received: by 10.152.179.136 with SMTP id dg8mr5456878lac.4.1437070869521; Thu, 16 Jul 2015 11:21:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.7.136 with SMTP id dc8ls438726lad.101.gmail; Thu, 16 Jul 2015 11:21:09 -0700 (PDT) X-Received: by 10.112.205.1 with SMTP id lc1mr10580990lbc.94.1437070869219; Thu, 16 Jul 2015 11:21:09 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id z7si7605459laj.139.2015.07.16.11.21.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 11:21:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by laem6 with SMTP id m6so48434240lae.0 for ; Thu, 16 Jul 2015 11:21:09 -0700 (PDT) X-Received: by 10.152.36.102 with SMTP id p6mr10629225laj.19.1437070869098; Thu, 16 Jul 2015 11:21:09 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp422623lbb; Thu, 16 Jul 2015 11:21:07 -0700 (PDT) X-Received: by 10.66.165.67 with SMTP id yw3mr21196447pab.95.1437070867226; Thu, 16 Jul 2015 11:21:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id go9si14298828pac.210.2015.07.16.11.21.06; Thu, 16 Jul 2015 11:21:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756149AbbGPSVD (ORCPT + 28 others); Thu, 16 Jul 2015 14:21:03 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:35357 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755903AbbGPSTm (ORCPT ); Thu, 16 Jul 2015 14:19:42 -0400 Received: by pdrg1 with SMTP id g1so48064738pdr.2 for ; Thu, 16 Jul 2015 11:19:42 -0700 (PDT) X-Received: by 10.68.103.164 with SMTP id fx4mr21193994pbb.125.1437070781975; Thu, 16 Jul 2015 11:19:41 -0700 (PDT) Received: from localhost.localdomain ([202.62.77.106]) by smtp.gmail.com with ESMTPSA id k5sm8679182pda.34.2015.07.16.11.19.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jul 2015 11:19:41 -0700 (PDT) From: Vaibhav Hiremath To: linux-arm-kernel@lists.infradead.org Cc: broonie@kernel.org, lgirdwood@gmail.com, sameo@linux.intel.com, lee.jones@linaro.org, linux-kernel@vger.kernel.org, Vaibhav Hiremath Subject: [PATCH 2/5] regulator: 88pm800: Update driver to use devm_regulator_register fn Date: Thu, 16 Jul 2015 23:46:55 +0530 Message-Id: <1437070618-21330-3-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437070618-21330-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1437070618-21330-1-git-send-email-vaibhav.hiremath@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vaibhav.hiremath@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch replaces standard regulator_register with devm_regulator_register() fn, as using devm_regulator_register() fn simplifies the driver return/exit path. As part of this update, patch also cleanups up all unnecessary changes which is result of this patch - - Remove _remove() fn, as devm_ variant takes care of it. - Remove pm800_regulators.regulators[] field, as it was only needed during cleanup, so we no longer need this. This also saved some amount of memory. Signed-off-by: Vaibhav Hiremath --- drivers/regulator/88pm800.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c index 11f7ab2..3b37170 100644 --- a/drivers/regulator/88pm800.c +++ b/drivers/regulator/88pm800.c @@ -78,7 +78,6 @@ struct pm800_regulator_info { }; struct pm800_regulators { - struct regulator_dev *regulators[PM800_ID_RG_MAX]; struct pm80x_chip *chip; struct regmap *map; }; @@ -318,6 +317,8 @@ static int pm800_regulator_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pm800_data); for (i = 0; i < PM800_ID_RG_MAX; i++) { + struct regulator_dev *regulator; + if (!pdata || pdata->num_regulators == 0) init_data = pm800_regulator_matches[i].init_data; else @@ -331,16 +332,12 @@ static int pm800_regulator_probe(struct platform_device *pdev) config.regmap = pm800_data->map; config.of_node = pm800_regulator_matches[i].of_node; - pm800_data->regulators[i] = - regulator_register(&info->desc, &config); - if (IS_ERR(pm800_data->regulators[i])) { - ret = PTR_ERR(pm800_data->regulators[i]); + regulator = devm_regulator_register(&pdev->dev, + &info->desc, &config); + if (IS_ERR(regulator)) { + ret = PTR_ERR(regulator); dev_err(&pdev->dev, "Failed to register %s\n", info->desc.name); - - while (--i >= 0) - regulator_unregister(pm800_data->regulators[i]); - return ret; } } @@ -348,23 +345,11 @@ static int pm800_regulator_probe(struct platform_device *pdev) return 0; } -static int pm800_regulator_remove(struct platform_device *pdev) -{ - struct pm800_regulators *pm800_data = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < PM800_ID_RG_MAX; i++) - regulator_unregister(pm800_data->regulators[i]); - - return 0; -} - static struct platform_driver pm800_regulator_driver = { .driver = { .name = "88pm80x-regulator", }, .probe = pm800_regulator_probe, - .remove = pm800_regulator_remove, }; module_platform_driver(pm800_regulator_driver);