From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Luca Ceresoli <luca@lucaceresoli.net>
Cc: linux-input@vger.kernel.org,
"Lothar Waßmann" <LW@KARO-electronics.de>,
"Manfred Schlaegl" <manfred.schlaegl@ginzinger.com>,
"Rob Herring" <robh@kernel.org>,
"Aniroop Mathur" <a.mathur@samsung.com>,
"Guenter Roeck" <linux@roeck-us.net>,
"Martin Kepplinger" <martink@posteo.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Input: edt-ft5x06 - fix access to non-existing register
Date: Thu, 7 Sep 2017 14:34:17 -0700 [thread overview]
Message-ID: <20170907213417.GD19320@dtor-ws> (raw)
In-Reply-To: <1504615523-9663-1-git-send-email-luca@lucaceresoli.net>
On Tue, Sep 05, 2017 at 02:45:23PM +0200, Luca Ceresoli wrote:
> reg_addr->reg_report_rate is supposed to exist in M06, not M09.
>
> The driver is written to skip avoids access to non-existing registers
> when the register address is NO_REGISTER (0xff). But
> reg_addr->reg_report_rate is initialized to 0x00 by devm_kzalloc() (in
> edt_ft5x06_ts_probe()) and not changed thereafter. So the checks do
> not work and an access to register 0x00 is done.
>
> Fix by setting reg_addr->reg_report_rate to NO_REGISTER.
>
> Also fix the only place where reg_report_rate is checked against zero
> instead of NO_REGISTER.
>
> Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Applied, thank you.
> ---
> drivers/input/touchscreen/edt-ft5x06.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> index f872817e81e4..5bf63f76ddda 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> @@ -593,7 +593,7 @@ static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata)
> tsdata->gain);
> edt_ft5x06_register_write(tsdata, reg_addr->reg_offset,
> tsdata->offset);
> - if (reg_addr->reg_report_rate)
> + if (reg_addr->reg_report_rate != NO_REGISTER)
> edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate,
> tsdata->report_rate);
>
> @@ -874,6 +874,7 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
>
> case M09:
> reg_addr->reg_threshold = M09_REGISTER_THRESHOLD;
> + reg_addr->reg_report_rate = NO_REGISTER;
> reg_addr->reg_gain = M09_REGISTER_GAIN;
> reg_addr->reg_offset = M09_REGISTER_OFFSET;
> reg_addr->reg_num_x = M09_REGISTER_NUM_X;
> --
> 2.7.4
>
--
Dmitry
parent reply other threads:[~2017-09-07 21:34 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <1504615523-9663-1-git-send-email-luca@lucaceresoli.net>]
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=20170907213417.GD19320@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=LW@KARO-electronics.de \
--cc=a.mathur@samsung.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=luca@lucaceresoli.net \
--cc=manfred.schlaegl@ginzinger.com \
--cc=martink@posteo.de \
--cc=robh@kernel.org \
/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).