Skip to content

Commit

Permalink
Input: ads7846 - optimize order of calculating Rt in ads7846_rx()
Browse files Browse the repository at this point in the history
Alter the if expression for calculating Rt. The old implementation would
run unnecessary code when the ADS7843 device was used.

The patch also fixes the code style to kernel standard.

Signed-off-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Hans-Christian Egtvedt authored and Dmitry Torokhov committed Jul 23, 2008
1 parent 494f685 commit 9460b65
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/input/touchscreen/ads7846.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,19 +517,19 @@ static void ads7846_rx(void *ads)
if (x == MAX_12BIT)
x = 0;

if (likely(x && z1)) {
if (ts->model == 7843) {
Rt = ts->pressure_max / 2;
} else if (likely(x && z1)) {
/* compute touch pressure resistance using equation #2 */
Rt = z2;
Rt -= z1;
Rt *= x;
Rt *= ts->x_plate_ohms;
Rt /= z1;
Rt = (Rt + 2047) >> 12;
} else
} else {
Rt = 0;

if (ts->model == 7843)
Rt = ts->pressure_max / 2;
}

/* Sample found inconsistent by debouncing or pressure is beyond
* the maximum. Don't report it to user space, repeat at least
Expand Down

0 comments on commit 9460b65

Please sign in to comment.