lkml.org 
[lkml]   [2019]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 14/15] drivers: thermal: tsens: Create function to return sign-extended temperature
From
Date
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@chromium.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.

\
 
 \ /
  Last update: 2019-08-28 17:44    [W:0.075 / U:1.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site