linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Duson Lin <dusonlin@emc.com.tw>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
	bleung@chromium.org, agnescheng@chromium.org, phoenix@emc.com.tw,
	jeff.chuang@emc.com.tw
Subject: Re: [PATCH v2] Input: add i2c/smbus driver for elan touchpad
Date: Thu, 24 Jul 2014 11:05:16 -0700	[thread overview]
Message-ID: <20140724180516.GA26752@core.coreip.homeip.net> (raw)
In-Reply-To: <1389064083-11018-1-git-send-email-dusonlin@emc.com.tw>

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

  parent reply	other threads:[~2014-07-24 18:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07  3:08 [PATCH v2] Input: add i2c/smbus driver for elan touchpad Duson Lin
2014-01-10 20:30 ` Benson Leung
2014-02-07  0:21   ` Benson Leung
2014-02-19 21:48     ` Benson Leung
2014-07-24 18:05 ` Dmitry Torokhov [this message]
2014-07-25 18:05   ` cheng wei Lin
2014-07-25 18:20     ` Dmitry Torokhov
2014-07-25 20:06       ` Dmitry Torokhov
2014-07-26  8:12         ` cheng wei Lin
2014-10-03 21:03 ` Dmitry Torokhov
2014-10-03 21:06   ` Dmitry Torokhov
2014-10-06  9:24     ` Mark Rutland
2014-10-06 16:37       ` Dmitry Torokhov
2014-10-03 21:30   ` Benson Leung
  -- strict thread matches above, loose matches on Subject: below --
2013-12-18  3:46 Duson Lin
2014-02-07  0:10 ` Benson Leung

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140724180516.GA26752@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=agnescheng@chromium.org \
    --cc=bleung@chromium.org \
    --cc=dusonlin@emc.com.tw \
    --cc=jeff.chuang@emc.com.tw \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phoenix@emc.com.tw \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).