lkml.org 
[lkml]   [2014]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] Input: add i2c/smbus driver for elan touchpad
Hi,

On Tue, Jan 07, 2014 at 11:08:03AM +0800, Duson Lin wrote:
> +/*
> + ******************************************************************
> + * General functions
> + ******************************************************************
> + */
> +/*
> + * (value from firmware) * 10 + 790 = dpi
> + * we also have to convert dpi to dots/mm (*10/254 to avoid floating point)
> + */
> +static unsigned int elan_convert_res(char val)
> +{
> + int res;
> + if (val & 0x80) {
> + val = ~val + 1;
> + res = (790 - val * 10) * 10 / 254;
> + } else
> + res = (val * 10 + 790) * 10 / 254;
> + return res;
> +}

Why isn't this simply:

res = ((int)val * 10 + 790) * 10 / 254;

?

If high bit is 1 you basically do the 2 complement by hand to get to
positive and then subtract. Which shoudl be the same as adding positive
value.

Thanks.

--
Dmitry


\
 
 \ /
  Last update: 2014-07-24 20:41    [W:0.080 / U:1.396 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site