[Gta04-owner] Gta04-owner Digest, Vol 51, Issue 5

Rainer Blome rainer.blome at gmx.de
Wed Mar 4 23:53:47 CET 2015



Am 04.03.2015 um 12:00 schrieb gta04-owner-request at goldelico.com:
> Date: Wed, 4 Mar 2015 20:20:33 +1100
> From: NeilBrown <neilb at suse.de>
> To: Pavel Machek <pavel at ucw.cz>
> Cc: Samuel Ortiz <sameo at linux.intel.com>, linux-pm at vger.kernel.org,
> 	Tony Lindgren <tony at atomide.com>, Lee Jones <lee.jones at linaro.org>,
> 	Sebastian Reichel <sre at kernel.org>, linux-kernel at vger.kernel.org,
> 	GTA04 owners <gta04-owner at goldelico.com>,	Dmitry Eremin-Solenikov
> 	<dbaryshkov at gmail.com>, linux-omap at vger.kernel.org,	David Woodhouse
> 	<dwmw2 at infradead.org>
> Subject: Re: [Gta04-owner] [PATCH 06/15] twl4030_charger: split uA
> 	calculation into a function.
> Message-ID: <20150304202033.653292df at notabene.brown>
> Content-Type: text/plain; charset="us-ascii"
> 
> On Mon, 2 Mar 2015 22:05:18 +0100 Pavel Machek <pavel at ucw.cz> wrote:
>> On Tue 2015-02-24 15:33:51, NeilBrown wrote:
>>> +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.

int gain = cgain ? 5 : 10;
return (regval * 16618 - 8500 * 1000) / gain;

-Rainer


More information about the Gta04-owner mailing list