From: Dmitry Osipenko <digetx@gmail.com>
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
"Johnny Chuang" <johnny.chuang.emc@gmail.com>,
"Jasper Korten" <jja2000@gmail.com>,
"Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: linux-input@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v1] Input: elants_i2c - fix division by zero if firmware reports zero phys size
Date: Tue, 2 Mar 2021 13:08:24 +0300 [thread overview]
Message-ID: <20210302100824.3423-1-digetx@gmail.com> (raw)
Touchscreen firmware of ASUS Transformer TF700T reports zeros for the phys
size. Hence check whether the size is zero and don't set the resolution in
this case.
Reported-by: Jasper Korten <jja2000@gmail.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
Please note that ASUS TF700T isn't yet supported by upstream kernel,
hence this is not a critical fix.
drivers/input/touchscreen/elants_i2c.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index 4c2b579f6c8b..a2e1cc4192b0 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -1441,14 +1441,16 @@ static int elants_i2c_probe(struct i2c_client *client,
touchscreen_parse_properties(ts->input, true, &ts->prop);
- if (ts->chip_id == EKTF3624) {
+ if (ts->chip_id == EKTF3624 && ts->phy_x && ts->phy_y) {
/* calculate resolution from size */
ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, ts->phy_x);
ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, ts->phy_y);
}
- input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res);
- input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res);
+ if (ts->x_res > 0)
+ input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res);
+ if (ts->y_res > 0)
+ input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res);
if (ts->major_res > 0)
input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, ts->major_res);
--
2.29.2
next reply other threads:[~2021-03-02 10:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 10:08 Dmitry Osipenko [this message]
2021-03-03 23:19 ` [PATCH v1] Input: elants_i2c - fix division by zero if firmware reports zero phys size Michał Mirosław
2021-03-26 13:24 ` Dmitry Osipenko
2021-03-28 4:44 ` Dmitry Torokhov
2021-03-28 17:21 ` Dmitry Osipenko
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=20210302100824.3423-1-digetx@gmail.com \
--to=digetx@gmail.com \
--cc=clamor95@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jja2000@gmail.com \
--cc=johnny.chuang.emc@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
/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).