lkml.org 
[lkml]   [2015]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 06/15] twl4030_charger: split uA calculation into a function.
On Mon, 2 Mar 2015 22:05:18 +0100 Pavel Machek <pavel@ucw.cz> wrote:

> On Tue 2015-02-24 15:33:51, NeilBrown wrote:
> > We will need this calculation in other places, so
> > create functions to map between register value and uA value.
> >
> > Signed-off-by: NeilBrown <neilb@suse.de>
>
> Acked-by: Pavel Machek <pavel@ucw.cz>

Thanks.


>
> > +static int regval2ua(int regval, bool cgain)
> > +{
> > + if (cgain)
> > + return (regval * 16618 - 8500 * 1000) / 5;
> > + else
> > + return (regval * 16618 - 8500 * 1000) / 10;
> > +}
>
> int res = (regval * 16618 - 8500 * 1000);
> if (cgain)
> return res / 5;
> return res / 10;
>
> ?
> Pavel

Maybe ... not sure it is really more readable. I think I'll leave it as is.

Thanks,
NeilBrown
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2015-03-04 10:41    [W:1.410 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site