From nobody Thu Nov 28 08:42:05 2024 Received: from box.trvn.ru (box.trvn.ru [45.141.101.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC9471D042F; Wed, 2 Oct 2024 13:17:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.141.101.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727875072; cv=none; b=kr7Zy9pDkfa3vanPbZg62ot4PwUXGeyW8pTB6ZZ+AArrAXddrfbp4VYDwEFxUHqzu8JSrUSdxa8JeiOCIvuCw/kgsapEYBAebvXrEPGRQVLXxzM8ccT/V/v2f3t2KIcqltgrzTYczDgYFChrhM08pcDkSjaJ0CZSKIJE9IhHqPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727875072; c=relaxed/simple; bh=8P6cWE6Y3SA/zxE+3Ctl2dClY9Gtv8gEj/Eg/FUpoR4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=T0/wUdmIALObH/IfKd9eLON78xR/ysuBs3SYwU0h27f2DJuJ90ueKt8jM+EmJWSqQH/Ba4Xo1Fj6bqKBO1EzGCVuNvAm4S4hSLL+bFdByXXzyKwLi7VUlis+pzhrIQiWzEXcQxdvgdaV9qYQRZmXfCrA8L/Z0JQRYlj6l62QaEM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=trvn.ru; spf=pass smtp.mailfrom=trvn.ru; dkim=pass (2048-bit key) header.d=trvn.ru header.i=@trvn.ru header.b=zqY7cPgJ; arc=none smtp.client-ip=45.141.101.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=trvn.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trvn.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=trvn.ru header.i=@trvn.ru header.b="zqY7cPgJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1727874151; bh=8P6cWE6Y3SA/zxE+3Ctl2dClY9Gtv8gEj/Eg/FUpoR4=; h=From:Date:Subject:To:Cc:From; b=zqY7cPgJb9jmR5CQdr+rUu91FIIOb0nZOoZKYK8nlZfcjVsEACwf0h4v7cHJu++PP iDxQDStZkNj/mfCKymU35/45mH7PmU+lMJ0TU4TE6I3iSg0nLhXsAXgLwZ2RD9Xyeo aJYW28OMLTfFfUUZHfwkI5aZ41wR3wUVzkVxCFtiZ4L1pIWHQNDHtl2Os4Lrsqzech ImgETqwl8ZCcE/sJwcFTyAzkSFvoheosAglciE1ke8n2+PEskR3LiOKYkq5JDLGDNf n16j0xxLncfFsimO5aokwpK4JpHQpewO0cUVhEDyA15H3gee0Rv4d+xi6iocSvZiVy oV6+g9UAyKPMw== Received: from authenticated-user (box.trvn.ru [45.141.101.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id A19121328; Wed, 2 Oct 2024 18:02:30 +0500 (+05) From: Nikita Travkin Date: Wed, 02 Oct 2024 18:01:48 +0500 Subject: [PATCH] Input: zinitix - Don't fail if linux,keycodes prop is absent Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241002-zinitix-no-keycodes-v1-1-e84029601491@trvn.ru> X-B4-Tracking: v=1; b=H4sIADtE/WYC/x3MTQqAIBBA4avErBtQadVVooU/Yw2BhkZY4t2Tl t/ivQqZElOGeaiQ6ObMMXTIcQC767ARsusGJdQkhVD4cuCLC4aIBz02OsrohSdpnLbWKOjlmch z+a/L2toHUxAg/2UAAAA= To: Dmitry Torokhov , Linus Walleij Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Jakob Hauser , Nikita Travkin X-Developer-Signature: v=1; a=openpgp-sha256; l=2631; i=nikita@trvn.ru; h=from:subject:message-id; bh=8P6cWE6Y3SA/zxE+3Ctl2dClY9Gtv8gEj/Eg/FUpoR4=; b=owEBbQKS/ZANAwAIAUMc7O4oGb91AcsmYgBm/URjhNJb/Nku0RJgsyjBRT6aSmzh4qPldUF3p GI3pSYDMSqJAjMEAAEIAB0WIQTAhK9UUj+qg34uxUdDHOzuKBm/dQUCZv1EYwAKCRBDHOzuKBm/ dYNfD/oDmMTMH/R3m8mf1l4fxqoZcnmt8vw3gAnQcyLuyuzMHp8nSkcLn0Nds+XX0bjVcQap/fv tR/dwidlIeDsoxaX1p5a91c29+U+R6Vwb0OZaOzkXEWVyrfoI2v33UY23OHlkrKpjVhXVGfGI5r UaE9Cb7sUeA++XZMIefBoVz/d52nGPoTJSGjQvyd3uYLUCWgT1Pk1MKTXfX+xtM4n19M0ujUXsl N+k92N8WFpPIVw1DAE7/CDMhijjrqz72OdAPAG6CHDL3bH4F2B1qYQHdBxGnGM9GSKr8X6tGPS2 a468eVIWB63NorWrOewuygiAmIinBrEEsfH9j2rj9hj/QiNWi7XJVi0QHH101c3q7ZDqNW/arQp NVoa2lgTmrbfduOjWRMxt3UY06omFeUd3MB60pLUvvMN6DYVSxSAHW6wVZXIVbHauJZOIsUiWzL MeMuXwTMiaCIQw7/x88Zr3sM1pO5nxftVGE+ESBEIuywvJesK5PIg2LMM7z6i4kePBwSk5fBTvc cB/tGw8EViFO/pVZRPoESjKrzyWV98J4RjpQSng1hFdJSXIYkkAG2WXmKLw+GrD86SiSxFFteUR Fna65JTi86PU9gsNGWXLi8XuCZV+2WLzgrMKBen8ITylM9Z6PhW9Hz5R1CD5m88Z7k2VvWRFh2u /Lxd2QPAJ5oN8ZA== X-Developer-Key: i=nikita@trvn.ru; a=openpgp; fpr=C084AF54523FAA837E2EC547431CECEE2819BF75 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 Tested-by: Jakob Hauser Fixes: 075d9b22c8fe ("Input: zinitix - add touchkey support") Signed-off-by: Nikita Travkin Reviewed-by: Linus Walleij --- drivers/input/touchscreen/zinitix.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscree= n/zinitix.c index 52b3950460e2..1f726653940c 100644 --- a/drivers/input/touchscreen/zinitix.c +++ b/drivers/input/touchscreen/zinitix.c @@ -645,19 +645,30 @@ static int zinitix_ts_probe(struct i2c_client *client) return error; } =20 - bt541->num_keycodes =3D device_property_count_u32(&client->dev, "linux,ke= ycodes"); - if (bt541->num_keycodes > ARRAY_SIZE(bt541->keycodes)) { - dev_err(&client->dev, "too many keys defined (%d)\n", bt541->num_keycode= s); - return -EINVAL; + error =3D device_property_count_u32(&client->dev, "linux,keycodes"); + if (error =3D=3D -EINVAL || error =3D=3D -ENODATA) { + bt541->num_keycodes =3D 0; + } else if (error < 0) { + dev_err(&client->dev, "Failed to count \"linux,keycodes\" property: %d\n= ", error); + return error; + } else { + bt541->num_keycodes =3D error; } =20 - error =3D 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; + if (bt541->num_keycodes > 0) { + if (bt541->num_keycodes > ARRAY_SIZE(bt541->keycodes)) { + dev_err(&client->dev, "too many keys defined (%d)\n", bt541->num_keycod= es); + return -EINVAL; + } + + error =3D 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; + } } =20 error =3D zinitix_init_input_dev(bt541); --- base-commit: fe21733536749bb1b31c9c84e0b8d2ab8d82ce13 change-id: 20241002-zinitix-no-keycodes-f0fe1bdaccb2 Best regards, --=20 Nikita Travkin