Skip to content

Commit 2de01e0

Browse files
TravMuravdtor
authored andcommitted
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: Jakob Hauser <jahau@rocketmail.com> Tested-by: Jakob Hauser <jahau@rocketmail.com> Fixes: 075d9b2 ("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> Link: https://lore.kernel.org/r/20241004-zinitix-no-keycodes-v2-1-876dc9fea4b6@trvn.ru Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 22a1893 commit 2de01e0

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

drivers/input/touchscreen/zinitix.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -645,19 +645,29 @@ static int zinitix_ts_probe(struct i2c_client *client)
645645
return error;
646646
}
647647

648-
bt541->num_keycodes = device_property_count_u32(&client->dev, "linux,keycodes");
649-
if (bt541->num_keycodes > ARRAY_SIZE(bt541->keycodes)) {
650-
dev_err(&client->dev, "too many keys defined (%d)\n", bt541->num_keycodes);
651-
return -EINVAL;
652-
}
648+
if (device_property_present(&client->dev, "linux,keycodes")) {
649+
bt541->num_keycodes = device_property_count_u32(&client->dev,
650+
"linux,keycodes");
651+
if (bt541->num_keycodes < 0) {
652+
dev_err(&client->dev, "Failed to count keys (%d)\n",
653+
bt541->num_keycodes);
654+
return bt541->num_keycodes;
655+
} else if (bt541->num_keycodes > ARRAY_SIZE(bt541->keycodes)) {
656+
dev_err(&client->dev, "Too many keys defined (%d)\n",
657+
bt541->num_keycodes);
658+
return -EINVAL;
659+
}
653660

654-
error = device_property_read_u32_array(&client->dev, "linux,keycodes",
655-
bt541->keycodes,
656-
bt541->num_keycodes);
657-
if (error) {
658-
dev_err(&client->dev,
659-
"Unable to parse \"linux,keycodes\" property: %d\n", error);
660-
return error;
661+
error = device_property_read_u32_array(&client->dev,
662+
"linux,keycodes",
663+
bt541->keycodes,
664+
bt541->num_keycodes);
665+
if (error) {
666+
dev_err(&client->dev,
667+
"Unable to parse \"linux,keycodes\" property: %d\n",
668+
error);
669+
return error;
670+
}
661671
}
662672

663673
error = zinitix_init_input_dev(bt541);

0 commit comments

Comments
 (0)