Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp512308ybn; Wed, 2 Oct 2019 01:36:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzu+Zi5wjqFQ86UxZA8FuygTb6bJWUqr04HCFmMeAKE56mAFd3hUFw92TPYM7A6iCNdSF89 X-Received: by 2002:a17:906:938b:: with SMTP id l11mr1981259ejx.67.1570005392735; Wed, 02 Oct 2019 01:36:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570005392; cv=none; d=google.com; s=arc-20160816; b=P1sQKVBhpvXFfK2xBRHlr7PPf+m4M/a+0Xulu2hZV6fYfgpQScGuvoZuil0fWk0QAB YI82iYl9Ru+m5i9PtMBHtIS3tMgOQWgUs2NjXmhXaqaScDLTvOKSZOavvjz6LEK00Trn 5F/2xruzGNRZaQxJCeMUYsAQSzWTn4Jy/T8I0mJqicP/EwapE+Fz4JLyWG//rDRqHhPC YHM3ljl/D5StFgWUcoHcC4WnsduoEcJ2dSMKJeXmgiVhYBt9+lAI5fSWXgd/KvJA3qxm AMAJhWg3BsMtn2xQjgV5+XfB/kb8j5m8brvl7xmIJQdolx1hCkHfTfGxl0tk86zSkpH6 pREw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=nwxcOLfUwI8BdzYl9FQWj9wPJ+Jwr+OD8hheb9j+02o=; b=P8rCBEkTX2BkHXvM87QXL5DwetQZYR+R+B/3BJ6qSpXkFifXizND7PfaHWY6B/c246 yduLfIDZnDSyJkqskx17DNv/PXl54dTaAe8uVfk9o+SwDHgvRlF6y0zhFnpbfdi8uGTA dpU1UjXsoFIrUfK4KqKN3KBeap0zb9JMgXBYxo0JjYD5NHN+umFJHqFCQbVvsn7Kmg7P tB3hd2oTbPt+68IeaiWR9LpsZdevCXcjVhtasoBCdWoHQsj0X3ipSMHDIFU9EC7+84XJ latWqWym/6lZ8DRb/MIgeuzU0lK1RiwL1hvoDzWV5n7dF2u5UlB4L0yTMni+IkuGGtTi zN0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a33si11375459edf.121.2019.10.02.01.36.07; Wed, 02 Oct 2019 01:36:32 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726383AbfJBHda (ORCPT + 99 others); Wed, 2 Oct 2019 03:33:30 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:37463 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbfJBHda (ORCPT ); Wed, 2 Oct 2019 03:33:30 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iFZ8T-0006eS-7W; Wed, 02 Oct 2019 09:33:21 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iFZ8S-0006Cj-0p; Wed, 02 Oct 2019 09:33:20 +0200 Date: Wed, 2 Oct 2019 09:33:19 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: David Laight Cc: 'Anson Huang' , "thierry.reding@gmail.com" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , "linux-pwm@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "Linux-imx@nxp.com" Subject: Re: [PATCH] pwm: pwm-imx27: Use 'dev' instead of dereferencing it repeatedly Message-ID: <20191002073319.tv55olneh6i6x4ir@pengutronix.de> References: <1569315593-769-1-git-send-email-Anson.Huang@nxp.com> <6cfb1595992b46dc884731555e6f0334@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6cfb1595992b46dc884731555e6f0334@AcuMS.aculab.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 24, 2019 at 09:46:20AM +0000, David Laight wrote: > From: Anson Huang > > Sent: 24 September 2019 10:00 > > Add helper variable dev = &pdev->dev to simply the code. > > > > Signed-off-by: Anson Huang > > --- > > drivers/pwm/pwm-imx27.c | 13 +++++++------ > > 1 file changed, 7 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c > > index 434a351..3afee29 100644 > > --- a/drivers/pwm/pwm-imx27.c > > +++ b/drivers/pwm/pwm-imx27.c > > @@ -290,27 +290,28 @@ MODULE_DEVICE_TABLE(of, pwm_imx27_dt_ids); > > > > static int pwm_imx27_probe(struct platform_device *pdev) > > { > > + struct device *dev = &pdev->dev; > > struct pwm_imx27_chip *imx; > > > > - imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL); > > + imx = devm_kzalloc(dev, sizeof(*imx), GFP_KERNEL); > > if (imx == NULL) > > return -ENOMEM; > > > > platform_set_drvdata(pdev, imx); > > > > - imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); > > + imx->clk_ipg = devm_clk_get(dev, "ipg"); > > if (IS_ERR(imx->clk_ipg)) { > > - dev_err(&pdev->dev, "getting ipg clock failed with %ld\n", > > + dev_err(dev, "getting ipg clock failed with %ld\n", > > PTR_ERR(imx->clk_ipg)); > > return PTR_ERR(imx->clk_ipg); > > } > > > > - imx->clk_per = devm_clk_get(&pdev->dev, "per"); > > + imx->clk_per = devm_clk_get(dev, "per"); > > if (IS_ERR(imx->clk_per)) { > > int ret = PTR_ERR(imx->clk_per); > > > > if (ret != -EPROBE_DEFER) > > - dev_err(&pdev->dev, > > + dev_err(dev, > > "failed to get peripheral clock: %d\n", > > ret); > > Hopefully the compiler will optimise this back otherwise you've added another > local variable which may cause spilling to stack. I wonder that in reply to this comment nobody actually tried. I just did that and applying the patch doesn't change the resulting binary. (Tested with gcc 7.3.1). > For a setup function it probably doesn't matter, but in general it might > have a small negative performance impact. > > In any case this doesn't shorten any lines enough to remove line-wrap > and using &pdev->dev is really one less variable to mentally track > when reading the code. On the other hand having a variable named "dev" is so usual that I personally slightly prefer using it instead of &pdev->dev. So I think (given there is no effect on the compiled result) this is really just about personal taste and so to actually switch from one preference to the other needs a better justification IMHO. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |