From patchwork Wed Jun 10 07:57:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 49678 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5D3DA20C81 for ; Wed, 10 Jun 2015 07:59:31 +0000 (UTC) Received: by wizw5 with SMTP id w5sf10444237wiz.2 for ; Wed, 10 Jun 2015 00:59:30 -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=1TN34zHe+Se5dubJ+JWtTuVGuLvb3zblgio/OaZZP7E=; b=dp0lZyhuYbIY3JTZcjyFj+YXbhKDpK5daARw6RDHcZSl9wTcmNa9cT1G0Y7SviaRYg 3otJG5f6qpz86DChBfJotxWqPCaQCa7s931ZSeOFb2WkJGrG6qO33VkMOYSxKEU7xKM7 nETwnKMEECdQMP1rfMgu5ab5CskMEQY+/YC7bgFr8+ZLx+UVofXdpXM1jy+d/UZ8tksS /1Fl0U5o4U37Te3i/9VXEBk1Si6pEhnDCAy3MM1lYZPTUyY8lvCXGGPi0jROCh3E1tNF ARzYV/b6JtGGDY/iD2G8kqXWj/AA7qd1JM7cmGjVyDMcOgsw7JMGZ+wggH/y8ZeWjimK Mfmw== X-Gm-Message-State: ALoCoQngPQlZSXJrFIG6WMAMHS+EIzyuLrr0S4T2W/xaTzha7OFxAX5UZns7imGeq+fTh+YMRF22 X-Received: by 10.112.161.105 with SMTP id xr9mr1834868lbb.20.1433923170673; Wed, 10 Jun 2015 00:59:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.5.35 with SMTP id cj3ls194128lad.7.gmail; Wed, 10 Jun 2015 00:59:30 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr1884085lbc.41.1433923170499; Wed, 10 Jun 2015 00:59:30 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id c4si8100174lbd.9.2015.06.10.00.59.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jun 2015 00:59:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by labko7 with SMTP id ko7so27427101lab.2 for ; Wed, 10 Jun 2015 00:59:30 -0700 (PDT) X-Received: by 10.152.6.69 with SMTP id y5mr1921213lay.72.1433923170374; Wed, 10 Jun 2015 00:59:30 -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 hn6csp3156285lbb; Wed, 10 Jun 2015 00:59:29 -0700 (PDT) X-Received: by 10.70.128.13 with SMTP id nk13mr3483039pdb.21.1433923168619; Wed, 10 Jun 2015 00:59:28 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si12614211pat.229.2015.06.10.00.59.27; Wed, 10 Jun 2015 00:59:28 -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 S933496AbbFJH7W (ORCPT + 28 others); Wed, 10 Jun 2015 03:59:22 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:35028 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933225AbbFJH6J (ORCPT ); Wed, 10 Jun 2015 03:58:09 -0400 Received: by wiga1 with SMTP id a1so39323567wig.0 for ; Wed, 10 Jun 2015 00:58:07 -0700 (PDT) X-Received: by 10.194.120.106 with SMTP id lb10mr3904039wjb.54.1433923087684; Wed, 10 Jun 2015 00:58:07 -0700 (PDT) Received: from localhost.localdomain (host81-129-170-231.range81-129.btcentralplus.com. [81.129.170.231]) by mx.google.com with ESMTPSA id c3sm13135187wja.3.2015.06.10.00.58.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jun 2015 00:58:06 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: kernel@stlinux.com, broonie@kernel.org, lgirdwood@gmail.com, Lee Jones Subject: [REBASED 5/5] regulator: pwm-regulator: Don't assign structure attributes right away Date: Wed, 10 Jun 2015 08:57:53 +0100 Message-Id: <1433923073-907-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433923073-907-1-git-send-email-lee.jones@linaro.org> References: <1433923073-907-1-git-send-email-lee.jones@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: lee.jones@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.42 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: , Perhaps this is just personal preference, but ... This patch introduces a new local variable to receive and test regulator initialisation data. It simplifies and cleans up the code making it that little bit easier to read and maintain. The local value is assigned to the structure attribute when all the others are. This is the way we usually do things. Prevents this kind of nonsense: this->is->just.silly = fetch_silly_value(&pointer); if (!this->is->just.silly) { printk("Silly value failed: %d\n", this->is->just.silly); return this->is->just.silly; } Signed-off-by: Lee Jones --- drivers/regulator/pwm-regulator.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index b37b616..2bfcb52 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -231,6 +231,7 @@ static int pwm_regulator_init_continuous(struct platform_device *pdev, static int pwm_regulator_probe(struct platform_device *pdev) { + const struct regulator_init_data *init_data; struct pwm_regulator_data *drvdata; struct regulator_dev *regulator; struct regulator_config config = { }; @@ -253,14 +254,15 @@ static int pwm_regulator_probe(struct platform_device *pdev) if (ret) return ret; - config.init_data = of_get_regulator_init_data(&pdev->dev, np, - &pwm_regulator_desc); - if (!config.init_data) + init_data = of_get_regulator_init_data(&pdev->dev, np, + &pwm_regulator_desc); + if (!init_data) return -ENOMEM; config.of_node = np; config.dev = &pdev->dev; config.driver_data = drvdata; + config.init_data = init_data; drvdata->pwm = devm_pwm_get(&pdev->dev, NULL); if (IS_ERR(drvdata->pwm)) {