Commit 2de01e0e authored by Nikita Travkin's avatar Nikita Travkin Committed by Dmitry Torokhov

Input: zinitix - don't fail if linux,keycodes prop is absent

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: default avatarJakob Hauser <jahau@rocketmail.com>
Tested-by: default avatarJakob Hauser <jahau@rocketmail.com>
Fixes: 075d9b22 ("Input: zinitix - add touchkey support")
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarNikita Travkin <nikita@trvn.ru>
Tested-by: default avatarYassine Oudjana <y.oudjana@protonmail.com>
Link: https://lore.kernel.org/r/20241004-zinitix-no-keycodes-v2-1-876dc9fea4b6@trvn.ruSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 22a18935
...@@ -645,19 +645,29 @@ static int zinitix_ts_probe(struct i2c_client *client) ...@@ -645,19 +645,29 @@ static int zinitix_ts_probe(struct i2c_client *client)
return error; return error;
} }
bt541->num_keycodes = device_property_count_u32(&client->dev, "linux,keycodes"); if (device_property_present(&client->dev, "linux,keycodes")) {
if (bt541->num_keycodes > ARRAY_SIZE(bt541->keycodes)) { bt541->num_keycodes = device_property_count_u32(&client->dev,
dev_err(&client->dev, "too many keys defined (%d)\n", bt541->num_keycodes); "linux,keycodes");
return -EINVAL; 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", error = device_property_read_u32_array(&client->dev,
bt541->keycodes, "linux,keycodes",
bt541->num_keycodes); bt541->keycodes,
if (error) { bt541->num_keycodes);
dev_err(&client->dev, if (error) {
"Unable to parse \"linux,keycodes\" property: %d\n", error); dev_err(&client->dev,
return error; "Unable to parse \"linux,keycodes\" property: %d\n",
error);
return error;
}
} }
error = zinitix_init_input_dev(bt541); error = zinitix_init_input_dev(bt541);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment