mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yassine Oudjana <yassine.oudjana@gmail.com>
To: Nikita Travkin <nikita@trvn.ru>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jakob Hauser <jahau@rocketmail.com>,
	Yassine Oudjana <y.oudjana@protonmail.com>
Subject: Re: [PATCH v2] Input: zinitix - Don't fail if linux,keycodes prop is absent
Date: Sun, 6 Oct 2024 11:28:50 +0300	[thread overview]
Message-ID: <26eaccf4-f1c3-4d98-a123-4577c5b7530b@gmail.com> (raw)
In-Reply-To: <20241004-zinitix-no-keycodes-v2-1-876dc9fea4b6@trvn.ru>

From: Yassine Oudjana <y.oudjana@protonmail.com>

On 04/10/2024 7:17 pm, Nikita Travkin wrote:
> When initially adding the touchkey support, a mistake was made in the
> property parsing code. The possible negative errno from
> device_property_count_u32() was never checked, which was an oversight
> left from converting to it from the of_property as part of the review
> fixes.
> 
> Re-add the correct handling of the absent property, in which case zero
> touchkeys should be assumed, which would disable the feature.
> 
> Reported-by: Jakob Hauser <jahau@rocketmail.com>
> Tested-by: Jakob Hauser <jahau@rocketmail.com>
> Fixes: 075d9b22c8fe ("Input: zinitix - add touchkey support")
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Nikita Travkin <nikita@trvn.ru>

Tested-by: Yassine Oudjana <y.oudjana@protonmail.com>

> ---
> Changes in v2:
> - Refactored the change to simplify the code (Dmitry)
> - Link to v1: https://lore.kernel.org/r/20241002-zinitix-no-keycodes-v1-1-e84029601491@trvn.ru
> ---
>   drivers/input/touchscreen/zinitix.c | 34 ++++++++++++++++++++++------------
>   1 file changed, 22 insertions(+), 12 deletions(-)
> 
> 
> ---
> base-commit: fe21733536749bb1b31c9c84e0b8d2ab8d82ce13
> change-id: 20241002-zinitix-no-keycodes-f0fe1bdaccb2
> 
> Best regards,
> 
> diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c
> index 52b3950460e2..716d6fa60f86 100644
> --- a/drivers/input/touchscreen/zinitix.c
> +++ b/drivers/input/touchscreen/zinitix.c
> @@ -645,19 +645,29 @@ static int zinitix_ts_probe(struct i2c_client *client)
>   		return error;
>   	}
>   
> -	bt541->num_keycodes = device_property_count_u32(&client->dev, "linux,keycodes");
> -	if (bt541->num_keycodes > ARRAY_SIZE(bt541->keycodes)) {
> -		dev_err(&client->dev, "too many keys defined (%d)\n", bt541->num_keycodes);
> -		return -EINVAL;
> -	}
> +	if (device_property_present(&client->dev, "linux,keycodes")) {
> +		bt541->num_keycodes = device_property_count_u32(&client->dev,
> +								"linux,keycodes");
> +		if (bt541->num_keycodes < 0) {
> +			dev_err(&client->dev, "Failed to count keys (%d)\n",
> +				bt541->num_keycodes);
> +			return bt541->num_keycodes;
> +		} else if (bt541->num_keycodes > ARRAY_SIZE(bt541->keycodes)) {
> +			dev_err(&client->dev, "Too many keys defined (%d)\n",
> +				bt541->num_keycodes);
> +			return -EINVAL;
> +		}
>   
> -	error = device_property_read_u32_array(&client->dev, "linux,keycodes",
> -					       bt541->keycodes,
> -					       bt541->num_keycodes);
> -	if (error) {
> -		dev_err(&client->dev,
> -			"Unable to parse \"linux,keycodes\" property: %d\n", error);
> -		return error;
> +		error = device_property_read_u32_array(&client->dev,
> +						       "linux,keycodes",
> +						       bt541->keycodes,
> +						       bt541->num_keycodes);
> +		if (error) {
> +			dev_err(&client->dev,
> +				"Unable to parse \"linux,keycodes\" property: %d\n",
> +				error);
> +			return error;
> +		}
>   	}
>   
>   	error = zinitix_init_input_dev(bt541);


  reply	other threads:[~2024-10-06  8:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-04 16:17 Nikita Travkin
2024-10-06  8:28 ` Yassine Oudjana [this message]
2024-10-19  0:13 ` 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=26eaccf4-f1c3-4d98-a123-4577c5b7530b@gmail.com \
    --to=yassine.oudjana@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jahau@rocketmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nikita@trvn.ru \
    --cc=y.oudjana@protonmail.com \
    /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

all inboxes | Powered by JetHome®