From: Thierry Reding <thierry.reding@gmail.com>
To: David Laight <David.Laight@aculab.com>
Cc: "linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>,
'Anson Huang' <Anson.Huang@nxp.com>,
"shawnguo@kernel.org" <shawnguo@kernel.org>,
"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Linux-imx@nxp.com" <Linux-imx@nxp.com>,
"kernel@pengutronix.de" <kernel@pengutronix.de>,
"festevam@gmail.com" <festevam@gmail.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] pwm: pwm-imx27: Use 'dev' instead of dereferencing it repeatedly
Date: Tue, 24 Sep 2019 12:52:09 +0200 [thread overview]
Message-ID: <20190924105209.GC14924@ulmo> (raw)
In-Reply-To: <6cfb1595992b46dc884731555e6f0334@AcuMS.aculab.com>
[-- Attachment #1.1: Type: text/plain, Size: 2372 bytes --]
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 <Anson.Huang@nxp.com>
> > ---
> > 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.
> 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.
>
> David
I agree. A positive diffstat is often a good indication that it's not
worth it. Don't get me wrong, I think there are cases where an extra
local variable can be worth it, but this isn't one of them, so it's
really just unnecessary churn.
Thierry
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-09-24 10:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-24 8:59 [PATCH] pwm: pwm-imx27: Use 'dev' instead of dereferencing it repeatedly Anson Huang
2019-09-24 9:46 ` David Laight
2019-09-24 10:03 ` Anson Huang
2019-09-24 10:43 ` David Laight
2019-09-25 2:36 ` Anson Huang
2019-09-24 10:52 ` Thierry Reding [this message]
2019-10-02 7:33 ` Uwe Kleine-König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190924105209.GC14924@ulmo \
--to=thierry.reding@gmail.com \
--cc=Anson.Huang@nxp.com \
--cc=David.Laight@aculab.com \
--cc=Linux-imx@nxp.com \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).