From patchwork Fri Jun 5 18:42:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 49597 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ABAA42462C for ; Fri, 5 Jun 2015 18:44:37 +0000 (UTC) Received: by laboh3 with SMTP id oh3sf21829683lab.0 for ; Fri, 05 Jun 2015 11:44:36 -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=7pIy3CywXtmWfswDYv86+ZovM1qpYQNoYR7ne149mSg=; b=cSsLiTWOSfagI2uCmcZOTHk3VmcqQHwFioUROAfxtI/bo7B1pzFBS7G0zBGFm67EVS 1HMqoi8IXhaalniRbc6Z8SqK4RIM6uh22fLLNJv+GvdJcZtpCqpl5lvzr+7ij/UES8iZ KyHcs7SH33lupxoLoVXmo2pGsBgIgPu6l3zisDo1gZvmivYd3uze04ZDTbpDfQlsJNAD 4t1a7dWTmysX5xgIBytxcffZRgTEKqGQJW4HwmQVrtEXhfSXyWLu6ame3UnUVvW55Wfp 0PV2D20qSMwmnfiukwdv/CVVZuGOqusmeGW1sbVDCIBdFOPQ7xI18WwNUkHJ++U8Qlgb +a0A== X-Gm-Message-State: ALoCoQmXGVrROZTqfaXFEdMrKUDSJ/FEeS0gIQ8Z/bccdQ0noEDgaPR/AemSZIeD9doZRqHYvMs+ X-Received: by 10.180.216.12 with SMTP id om12mr9743679wic.1.1433529876642; Fri, 05 Jun 2015 11:44:36 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.99 with SMTP id l3ls417326lam.4.gmail; Fri, 05 Jun 2015 11:44:36 -0700 (PDT) X-Received: by 10.112.158.103 with SMTP id wt7mr4630557lbb.5.1433529876376; Fri, 05 Jun 2015 11:44:36 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id a4si491002lak.156.2015.06.05.11.44.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jun 2015 11:44:36 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by labko7 with SMTP id ko7so60367940lab.2 for ; Fri, 05 Jun 2015 11:44:36 -0700 (PDT) X-Received: by 10.152.206.75 with SMTP id lm11mr4522267lac.41.1433529876276; Fri, 05 Jun 2015 11:44:36 -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 hn6csp71498lbb; Fri, 5 Jun 2015 11:44:35 -0700 (PDT) X-Received: by 10.66.90.137 with SMTP id bw9mr8158446pab.52.1433529874451; Fri, 05 Jun 2015 11:44:34 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fl4si11941581pab.108.2015.06.05.11.44.33; Fri, 05 Jun 2015 11:44:34 -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 S932894AbbFESo2 (ORCPT + 28 others); Fri, 5 Jun 2015 14:44:28 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:38097 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754703AbbFESnK (ORCPT ); Fri, 5 Jun 2015 14:43:10 -0400 Received: by wibdq8 with SMTP id dq8so27762965wib.1 for ; Fri, 05 Jun 2015 11:43:09 -0700 (PDT) X-Received: by 10.180.82.100 with SMTP id h4mr20213563wiy.61.1433529789804; Fri, 05 Jun 2015 11:43:09 -0700 (PDT) Received: from localhost.localdomain ([213.205.253.199]) by mx.google.com with ESMTPSA id be3sm4473541wib.21.2015.06.05.11.43.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jun 2015 11:43:09 -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: [PATCH 5/8] regulator: pwm-regulator: Don't assign structure attributes right away Date: Fri, 5 Jun 2015 19:42:48 +0100 Message-Id: <1433529771-24496-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433529771-24496-1-git-send-email-lee.jones@linaro.org> References: <1433529771-24496-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.44 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 ae32086..779ecf9 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -96,6 +96,7 @@ static struct regulator_desc pwm_regulator_desc = { static int pwm_regulator_probe(struct platform_device *pdev) { + const struct regulator_init_data *init_data; struct pwm_regulator_data *drvdata; struct property *prop; struct regulator_dev *regulator; @@ -142,14 +143,15 @@ static int pwm_regulator_probe(struct platform_device *pdev) 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)) {