Input: msg2638 - only read linux,keycodes array if necessary

The linux,keycodes property is optional.
Fix the driver not probing when it's not specified.

Fixes: c18ef50346 ("Input: msg2638 - add support for msg2138 key events")
Signed-off-by: Vincent Knecht <vincent.knecht@mailoo.org>
Link: https://lore.kernel.org/r/20221130210202.2069213-1-vincent.knecht@mailoo.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
Vincent Knecht 2022-11-30 15:15:25 -08:00 committed by Dmitry Torokhov
parent b2b80d9dd1
commit a5df8025f3

View file

@ -412,13 +412,15 @@ static int msg2638_ts_probe(struct i2c_client *client)
msg2638->num_keycodes = ARRAY_SIZE(msg2638->keycodes);
}
error = device_property_read_u32_array(dev, "linux,keycodes",
msg2638->keycodes,
msg2638->num_keycodes);
if (error) {
dev_err(dev, "Unable to read linux,keycodes values: %d\n",
error);
return error;
if (msg2638->num_keycodes > 0) {
error = device_property_read_u32_array(dev, "linux,keycodes",
msg2638->keycodes,
msg2638->num_keycodes);
if (error) {
dev_err(dev, "Unable to read linux,keycodes values: %d\n",
error);
return error;
}
}
error = devm_request_threaded_irq(dev, client->irq,