linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-input@vger.kernel.org, Henrik Rydberg <rydberg@bitmath.org>
Subject: Re: [PATCH v1 4/5] Input: edt-ft5x06 - do not try to allocate too much memory
Date: Fri, 6 Mar 2020 17:08:37 -0800	[thread overview]
Message-ID: <20200307010837.GO217608@dtor-ws> (raw)
In-Reply-To: <20200303180917.12563-4-andriy.shevchenko@linux.intel.com>

On Tue, Mar 03, 2020 at 08:09:16PM +0200, Andy Shevchenko wrote:
> When mode switch happens we try to allocate too much memory in case
> when num_x and num_y are being assigned to their maximum.
> 
> Since the resolution should come from property in such case, reassign
> values back to num_x and num_y to prevent too much memory allocation.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/input/touchscreen/edt-ft5x06.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> index a05c6b597d43..1023d4134b8d 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> @@ -1178,6 +1178,13 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
>  
>  	touchscreen_parse_properties(input, true, &tsdata->prop);
>  
> +	if (tsdata->num_x == U16_MAX && tsdata->prop.max_x &&
> +	    tsdata->num_y == U16_MAX && tsdata->prop.max_y) {
> +		/* Reassign num_x and num_y from properties */
> +		tsdata->num_x = tsdata->prop.max_x;
> +		tsdata->num_y = tsdata->prop.max_y;

No. num_x and num_y reprsenet number of electrodes on a given axis and
we should not be assigning maximum coordinates to them.

Moreover, the factory mode can only be activated on M06, where we do
read these values from registers, so we will not be allocating too much
memory. If anything, we should add error handling for
edt_ft5x06_register_read() when trying to fetch num_x and num_y.

Thanks.

-- 
Dmitry

  reply	other threads:[~2020-03-07  1:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-03 18:09 [PATCH v1 1/5] Input: of_touchscreen - explicitly choose axis Andy Shevchenko
2020-03-03 18:09 ` [PATCH v1 2/5] Input: edt-ft5x06 - refactor condition in edt_ft5x06_debugfs_mode_set() Andy Shevchenko
2020-03-07  1:11   ` Dmitry Torokhov
2020-03-03 18:09 ` [PATCH v1 3/5] Input: edt-ft5x06 - use U16_MAX instead of -1 Andy Shevchenko
2020-05-11 10:09   ` Andy Shevchenko
2020-03-03 18:09 ` [PATCH v1 4/5] Input: edt-ft5x06 - do not try to allocate too much memory Andy Shevchenko
2020-03-07  1:08   ` Dmitry Torokhov [this message]
2020-05-11 10:08     ` Andy Shevchenko
2020-03-03 18:09 ` [PATCH v1 5/5] Input: edt-ft5x06 - allocate buffer once for debugging Andy Shevchenko
2020-03-07  0:57   ` Dmitry Torokhov
2020-03-07  1:12 ` [PATCH v1 1/5] Input: of_touchscreen - explicitly choose axis Dmitry Torokhov

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=20200307010837.GO217608@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-input@vger.kernel.org \
    --cc=rydberg@bitmath.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).