[<prev] [next>] [day] [month] [year] [list]
Message-ID: <5d66a168.1c69fb81.570fd.ae07@mx.google.com>
Date: Wed, 28 Aug 2019 08:44:39 -0700
From: Stephen Boyd <swboyd@...omium.org>
To: Amit Kucheria <amit.kucheria@...aro.org>
Cc: Daniel Lezcano <daniel.lezcano@...aro.org>,
Mark Rutland <mark.rutland@....com>,
Rob Herring <robh+dt@...nel.org>,
Zhang Rui <rui.zhang@...el.com>,
Andy Gross <agross@...nel.org>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Eduardo Valentin <edubezval@...il.com>,
linux-arm-msm <linux-arm-msm@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Marc Gonzalez <marc.w.gonzalez@...e.fr>,
Brian Masney <masneyb@...tation.org>,
Linux PM list <linux-pm@...r.kernel.org>
Subject: Re: [PATCH v2 14/15] drivers: thermal: tsens: Create function to return sign-extended temperature
Quoting Amit Kucheria (2019-08-28 03:35:28)
> (Resending, replied only to Stephen by mistake)
>
> On Wed, Aug 28, 2019 at 6:08 AM Stephen Boyd <swboyd@...omium.org> wrote:
> >
> > Quoting Amit Kucheria (2019-08-27 05:14:10)
> > > @@ -310,6 +328,10 @@ int __init init_common(struct tsens_priv *priv)
> > > goto err_put_device;
> > > }
> > > }
> > > +
> > > + /* Save away resolution of signed temperature value for this IP */
> > > + priv->tempres = priv->fields[LAST_TEMP_0].msb - priv->fields
> [LAST_TEMP_0].lsb;
> > > +
> >
> > Why not just calculate this in the function that uses it? Is there a
> > reason to stash it away in the struct?
>
> To avoid recalculating in an often-called function. It doesn't change for an IP
> version.
>
> We can't make it static either inside that function since the initializer isn't
> constant.
>
This sounds like a super micro optimization. It's a couple derefs and a
subtraction. If it isn't used anywhere else please just move it into the
function where it's used.
Powered by blists - more mailing lists