From patchwork Tue Jul 7 15:06: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: 50827 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B7588229FC for ; Tue, 7 Jul 2015 15:08:24 +0000 (UTC) Received: by laar3 with SMTP id r3sf58709952laa.1 for ; Tue, 07 Jul 2015 08:08:23 -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=4EEZeagDzPc8uaYj38+q6dsrM6Mvcez8wRdlX+ZFRLI=; b=iBzZgsPKs9qJNk6YYA+1nYmytScdnBqc7w4vD66RhStDOIq/OK5VrmX4O6UVwltccO MQrgKje8/X8rO9UenEiFkBX2+1ojk6l7qUeJOVYfcLA2gdmDBoT8ce4KmkYE9r5VV6ql o/dNPpV034BtaFHojXtP6twAnmaQe+ggJmRwxnswVtpSGjmwz4BpeCGSTAyuvvzHhnox 4VuYpWu4zXE/wKp/C+4f8v47FlfXUZHajW+2zmCzHeryLP+dOEJwgegdH0LAkRQRh5S1 rCUJ52yRO8DIkjCbmwAKLIe+2UTljwlAsD4OGSgxn1pr55KXzq6OLO5Gz4tVhoMWNYS1 FYZw== X-Gm-Message-State: ALoCoQn5zzUc/cXyE5Gv+zwDsHmSEh9NEIqnGEaBzaruzx5XQKhEvds0DR04Nx4hMo4YMHDXiB3a X-Received: by 10.152.120.69 with SMTP id la5mr2345967lab.7.1436281703485; Tue, 07 Jul 2015 08:08:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.129 with SMTP id m1ls749888laf.76.gmail; Tue, 07 Jul 2015 08:08:23 -0700 (PDT) X-Received: by 10.152.3.70 with SMTP id a6mr4495906laa.44.1436281703301; Tue, 07 Jul 2015 08:08:23 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id wr11si18342970lbc.105.2015.07.07.08.08.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2015 08:08:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lagx9 with SMTP id x9so199426703lag.1 for ; Tue, 07 Jul 2015 08:08:23 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr4432904lbc.112.1436281703197; Tue, 07 Jul 2015 08:08:23 -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 hn6csp2453021lbb; Tue, 7 Jul 2015 08:08:20 -0700 (PDT) X-Received: by 10.66.228.73 with SMTP id sg9mr10056057pac.88.1436281699848; Tue, 07 Jul 2015 08:08:19 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f10si35122756pdp.225.2015.07.07.08.08.18; Tue, 07 Jul 2015 08:08:19 -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 S932491AbbGGPIQ (ORCPT + 29 others); Tue, 7 Jul 2015 11:08:16 -0400 Received: from mail-wg0-f51.google.com ([74.125.82.51]:35968 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756931AbbGGPHO (ORCPT ); Tue, 7 Jul 2015 11:07:14 -0400 Received: by wgbgr6 with SMTP id gr6so16823454wgb.3 for ; Tue, 07 Jul 2015 08:07:11 -0700 (PDT) X-Received: by 10.180.188.48 with SMTP id fx16mr64658645wic.35.1436281631722; Tue, 07 Jul 2015 08:07:11 -0700 (PDT) Received: from localhost.localdomain (host86-178-207-130.range86-178.btcentralplus.com. [86.178.207.130]) by mx.google.com with ESMTPSA id x5sm1360101wif.21.2015.07.07.08.07.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jul 2015 08:07:10 -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 v2 9/9] regulator: pwm-regulator: Don't assign structure attributes right away Date: Tue, 7 Jul 2015 16:06:53 +0100 Message-Id: <1436281613-899-10-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436281613-899-1-git-send-email-lee.jones@linaro.org> References: <1436281613-899-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.49 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 d5cb267..cb48208 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -218,6 +218,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 = { }; @@ -240,14 +241,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)) {