From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796174344; b=Mz6A8u+Hs0xV/fDdCPyPeAK5bO4oAfLZtvCRyqE5P6Ls/dYoM5df/s4fzB8ONhLPeXHx KJZdPRNr33bA2dlXKcu7265i8NZ1sBFm0NTOslsXqgxYJCicO2gGtm/kuwDRCcN8YI+EB yiaSsaPv225Y4gIrlTiFhllEGdgybXp8gTd98XyYhXpbijgA3onCc7j3wCNmu0j7NEyx8 7csdo0YjwvC/cELOGkTbQisf8j+NyW+EwkrEVPWt9vhBxMDdY4v7ZyyWitMjum90v4Lio HJFaqogAtbeSUbiLuO7uNP1WrVVaYSHrjjVnull06903i+eQPDubI0MDd0rcbyF6gYw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796174344; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Grrd3ErX2lCnxSqnFgYGSMj49iwOc1b2SOybURwB8Q0=; b=MYlHnBx8XfsFJYFzsojVo9roPRnDegRak6LruYhbVRLtIhD1rdxrf0/Sn/RMH85DeaYT rLLvcmxbYJcIj6NYBqPKfUkwdV5N6miG8PukqcWRGmcSIzPs9LSGE5oNB1sWQHpB2Feet EYWvy0s4F9QVW3p5NNT3MkEIjYvqxlWqfXqa4uBzdgzJ7RYVeFAOzrV1zHLrtnYMnQD+I MQuWEfDVwK5az7EIZXjQ4UU/JSV2xgLJ4RzfYxxqdKEAhdC19oxSYHhHOkOYaYWcOpcT0 78QKpfWj3xpUnPSGMqBxHXEo7RTsqCEyxTVucc/k3SkGgW+IojODZ6d40rqUROxHTQw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="n/ZDgqsT"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5987606A322; Wed, 2 Dec 2026 01:19:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=n/ZDgqsT Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20E2C1F00897; Wed, 2 Dec 2026 01:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796174344; bh=Grrd3ErX2lCnxSqnFgYGSMj49iwOc1b2SOybURwB8Q0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=n/ZDgqsTN+QrjIL4pDhuKz7HZeBhFUWfCdreSq6iA52eOA19Ce/LKvgBmpx5L/RJi OpXdeOgGra1nTNqp99gSmftkguj192ir491Udh69MG51P2WS99Oenv+5dr3p/OmkKS y681fPAfOUjb5xquG5dMPkoGT5dKE8XtUaz//Dx5S/a6rqzCXX/GykPuUZM9fu8C/1 glLKsZEySS8TIDzregEG2vYECO4Ff/UK2OVc7V9NWQ/u8GczD48yFxcLF6Vj2HGnfD lQXDkP+6ICLyn7FtJVPFEQShVpmA7bsn67CZA7Kct2mvnIfXt7BCGC0A5Dtkx3m2uT EralQNWejN0SQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 5/7] Input: novatek-nvt-ts - add NT36536 packet decoding Reply-To: sashiko-reviews@lists.linux.dev To: "Qianhui Xu" Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com In-Reply-To: <20261202010542.2508257-5-xiaqinghuan@mail.ustc.edu.cn> References: <20261202010542.2508257-1-xiaqinghuan@mail.ustc.edu.cn> <20261202010542.2508257-5-xiaqinghuan@mail.ustc.edu.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 01:19:03 +0000 X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [High] Input: novatek-nvt-ts - broken X/Y axis setup in nvt_ts_probe() when chip_id is 0 - [High] Input: novatek-nvt-ts - missing linux/bitfield.h include in novatek-nvt-ts-core.c - [High] Input: novatek-nvt-ts: off-by-one payload offset in nvt_ts_report_nt36xxx() - [Medium] Input: novatek-nvt-ts - unregistered ABS_MT_TOUCH_MAJOR axis in nvt_ts_probe() -- commit 2354ad35fa28bbbffb01b63befc83c37b13ef941 Author: Qianhui Xu Input: novatek-nvt-ts - add NT36536 packet decoding This commit adds a per-chip touch reporting callback, implements NT36xxx packet decoding with checksum validation, skips reading the parameter block when chip_id is 0, and adds SPI match entries for NT36536. > diff --git a/drivers/input/touchscreen/novatek-nvt-ts-core.c b/drivers/in= put/touchscreen/novatek-nvt-ts-core.c > index 747fa8bbe3157..f67170474c76e 100644 > --- a/drivers/input/touchscreen/novatek-nvt-ts-core.c > +++ b/drivers/input/touchscreen/novatek-nvt-ts-core.c [ ... ] > @@ -81,6 +85,76 @@ static irqreturn_t nvt_ts_irq(int irq, void *dev_id) > input_mt_sync_frame(data->input); > input_sync(data->input); > =20 > + return 0; > +} > + > +/* > + * NT36xxx checksum: the byte at NVT_TS_NT36XXX_CHECKSUM is the two's > + * complement of the sum of the first 64 payload bytes. > + */ > +static bool nvt_ts_nt36xxx_checksum_ok(const u8 *buf) > +{ > + u8 sum =3D 0; > + int i; > + > + for (i =3D 1; i < NVT_TS_NT36XXX_CHECKSUM; i++) > + sum +=3D buf[i]; > + > + return (u8)(~sum + 1) =3D=3D buf[NVT_TS_NT36XXX_CHECKSUM]; > +} > + > +/* > + * NT36xxx packet: 108 bytes of payload plus a checksum, records start at > + * offset 1, coordinates are 16 bit big endian and b[5] carries the widt= h. > + */ > +static int nvt_ts_report_nt36xxx(struct nvt_ts_data *data) > +{ > + struct device *dev =3D data->dev; > + int i, error; > + > + error =3D nvt_ts_read_data(data, NVT_TS_TOUCH_START, data->buf, > + NVT_TS_NT36XXX_PACKET_SIZE); > + if (error) > + return error; > + > + if (!nvt_ts_nt36xxx_checksum_ok(data->buf)) { > + dev_dbg(dev, "bad touch packet checksum\n"); > + return -EIO; > + } > + > + for (i =3D 0; i < data->max_touches; i++) { > + const u8 *touch =3D &data->buf[1 + i * NVT_TS_TOUCH_SIZE]; [Severity: High] Are the checksum and touch record offsets in data->buf off by one byte? nvt_ts_spi_read() already sends the register address and dummy byte in a separate two-byte cmd buffer via spi_write_then_read() before reading the response into buf: drivers/input/touchscreen/novatek-nvt-ts-spi.c:nvt_ts_spi_read() { ... u8 cmd[2] =3D { reg & 0x7f, 0 }; return spi_write_then_read(spi, cmd, sizeof(cmd), buf, count); } The first payload byte therefore lands at data->buf[0] rather than data->buf[1] (matching nvt_ts_report_nt11205()). Starting the checksum loop and record decoding at index 1 skips the first byte of record 0, folds the checksum byte at data->buf[64] into sum, compares against data->buf[65], and shifts every touch record by one byte. > + u8 state =3D FIELD_GET(NVT_TS_TOUCH_TYPE_MASK, touch[0]); [Severity: High] Does using FIELD_GET() here require including ? Neither novatek-nvt-ts-core.c nor novatek-nvt-ts.h includes it, which breaks the build on architectures such as x86_64 that do not pull it in transitively. > + unsigned int id =3D (touch[0] >> NVT_TS_TOUCH_SLOT_SHIFT) - 1; > + unsigned int x, y, width; > + > + if (state !=3D NVT_TS_TOUCH_NEW && state !=3D NVT_TS_TOUCH_UPDATE) > + continue; > + if (id >=3D data->max_touches) > + continue; > + > + x =3D get_unaligned_be16(&touch[1]); > + y =3D get_unaligned_be16(&touch[3]); > + width =3D touch[5] ?: 1; > + > + input_mt_slot(data->input, id); > + input_mt_report_slot_state(data->input, MT_TOOL_FINGER, true); > + touchscreen_report_pos(data->input, &data->prop, x, y, true); > + input_report_abs(data->input, ABS_MT_TOUCH_MAJOR, width); [Severity: Medium] Are these ABS_MT_TOUCH_MAJOR events dropped by the input core? nvt_ts_probe() never registers ABS_MT_TOUCH_MAJOR via input_set_abs_params(), so the bit is not set in input->absbit and input_get_disposition() ignores every reported width value. [ ... ] > @@ -223,9 +318,17 @@ int nvt_ts_probe(struct device *dev, const struct nv= t_ts_bus_ops *bus_ops, > input->open =3D nvt_ts_start; > input->close =3D nvt_ts_stop; > =20 > - input_set_abs_params(input, ABS_MT_POSITION_X, 0, width - 1, 0, 0); > - input_set_abs_params(input, ABS_MT_POSITION_Y, 0, height - 1, 0, 0); > + if (width) > + input_set_abs_params(input, ABS_MT_POSITION_X, 0, width - 1, 0, 0); > + if (height) > + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, height - 1, 0, 0); > touchscreen_parse_properties(input, true, &data->prop); > + if (!width) > + input_set_abs_params(input, ABS_MT_POSITION_X, 0, > + data->prop.max_x - 1, 0, 0); > + if (!height) > + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, > + data->prop.max_y - 1, 0, 0); [Severity: High] Does touchscreen_parse_properties() reject the DT geometry when chip_id is 0 (so width and height are 0)? Inside touchscreen_parse_properties(), touchscreen_set_params() checks that the axis bit is already set in dev->absbit before applying properties: drivers/input/touchscreen.c:touchscreen_set_params() { if (!test_bit(axis, dev->absbit)) { dev_warn(&dev->dev, "Parameters are specified but the axis %lu is not set up\n", axis); return; } ... } Because ABS_MT_POSITION_X and ABS_MT_POSITION_Y are not enabled before touchscreen_parse_properties(), it warns and leaves data->prop.max_x and data->prop.max_y at 0, and the subsequent input_set_abs_params() calls set the maximum X and Y coordinates to -1. In addition, when the axes are set up beforehand (for example with input_set_capability(input, EV_ABS, ...)), touchscreen_parse_properties() already configures input->absinfo with size - 1, fuzz, resolution and axis swapping, so calling input_set_abs_params() afterwards with data->prop.max_x - 1 would subtract 1 a second time and overwrite those properties. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202010542.2508= 257-1-xiaqinghuan@mail.ustc.edu.cn?part=3D5