summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen/resistive-adc-touch.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2021-10-26 11:03:02 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2021-10-26 11:03:02 -0300
commit3a55445f11e6b1dbdc1e7f2684a519089d2e163c (patch)
treece449fbd02b8dde1adf10bf4e2f291c9fa1fe4dc /drivers/input/touchscreen/resistive-adc-touch.c
parent342cb7ebf5e29fff4dc09ab2c8f37d710f8f5206 (diff)
parent3906fe9bb7f1a2c8667ae54e967dc8690824f4ea (diff)
Merge remote-tracking branch 'torvalds/master' into perf/core
To pick up the fixes from upstream. Fix simple conflict on session.c related to the file position fix that went upstream and is touched by the active decomp changes in perf/core. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'drivers/input/touchscreen/resistive-adc-touch.c')
-rw-r--r--drivers/input/touchscreen/resistive-adc-touch.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/input/touchscreen/resistive-adc-touch.c b/drivers/input/touchscreen/resistive-adc-touch.c
index 744544a723b7..6f754a8d30b1 100644
--- a/drivers/input/touchscreen/resistive-adc-touch.c
+++ b/drivers/input/touchscreen/resistive-adc-touch.c
@@ -71,19 +71,22 @@ static int grts_cb(const void *data, void *private)
unsigned int z2 = touch_info[st->ch_map[GRTS_CH_Z2]];
unsigned int Rt;
- Rt = z2;
- Rt -= z1;
- Rt *= st->x_plate_ohms;
- Rt = DIV_ROUND_CLOSEST(Rt, 16);
- Rt *= x;
- Rt /= z1;
- Rt = DIV_ROUND_CLOSEST(Rt, 256);
- /*
- * On increased pressure the resistance (Rt) is decreasing
- * so, convert values to make it looks as real pressure.
- */
- if (Rt < GRTS_DEFAULT_PRESSURE_MAX)
- press = GRTS_DEFAULT_PRESSURE_MAX - Rt;
+ if (likely(x && z1)) {
+ Rt = z2;
+ Rt -= z1;
+ Rt *= st->x_plate_ohms;
+ Rt = DIV_ROUND_CLOSEST(Rt, 16);
+ Rt *= x;
+ Rt /= z1;
+ Rt = DIV_ROUND_CLOSEST(Rt, 256);
+ /*
+ * On increased pressure the resistance (Rt) is
+ * decreasing so, convert values to make it looks as
+ * real pressure.
+ */
+ if (Rt < GRTS_DEFAULT_PRESSURE_MAX)
+ press = GRTS_DEFAULT_PRESSURE_MAX - Rt;
+ }
}
if ((!x && !y) || (st->pressure && (press < st->pressure_min))) {