linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Charles Wang <charles.goodix@gmail.com>
To: dmitry.torokhov@gmail.com, hbarnor@chromium.org
Cc: jikos@kernel.org, bentiss@kernel.org, dianders@chromium.org,
	dan.carpenter@linaro.org, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Charles Wang <charles.goodix@gmail.com>
Subject: [PATCH v2 1/2] HID: hid-goodix: Return 0 when receiving an empty HID feature package
Date: Thu, 31 Oct 2024 20:31:12 +0800	[thread overview]
Message-ID: <20241031123113.18843-2-charles.goodix@gmail.com> (raw)
In-Reply-To: <20241031123113.18843-1-charles.goodix@gmail.com>

Align with the i2c-hid driver by returning 0 instead of -EINVAL when
an empty response is received, ensuring that userspace programs utilizing
the hidraw node receive consistent return values.

Signed-off-by: Charles Wang <charles.goodix@gmail.com>
---
 drivers/hid/hid-goodix-spi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-goodix-spi.c b/drivers/hid/hid-goodix-spi.c
index 0f87bf9c6..077a91ee1 100644
--- a/drivers/hid/hid-goodix-spi.c
+++ b/drivers/hid/hid-goodix-spi.c
@@ -356,7 +356,7 @@ static int goodix_hid_check_ack_status(struct goodix_ts_data *ts, u32 *resp_len)
 				dev_err(ts->dev, "hrd.size too short: %d", len);
 				return -EINVAL;
 			}
-			*resp_len = len;
+			*resp_len = len - GOODIX_HID_PKG_LEN_SIZE;
 			return 0;
 		}
 
@@ -446,7 +446,10 @@ static int goodix_hid_get_raw_report(struct hid_device *hid,
 	if (error)
 		return error;
 
-	len = min(len, response_data_len - GOODIX_HID_PKG_LEN_SIZE);
+	/* Empty reprot response */
+	if (!response_data_len)
+		return 0;
+	len = min(len, response_data_len);
 	/* Step3: read response data(skip 2bytes of hid pkg length) */
 	error = goodix_spi_read(ts, ts->hid_report_addr +
 				GOODIX_HID_ACK_HEADER_SIZE +
-- 
2.43.0


  reply	other threads:[~2024-10-31 12:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-31 12:31 [PATCH v2 0/2] HID: hid-goodix: Improve handling of HID feature reports Charles Wang
2024-10-31 12:31 ` Charles Wang [this message]
2024-10-31 12:31 ` [PATCH v2 2/2] HID: hid-goodix: Fix HID get/set feature operation overwritten problem Charles Wang
2024-11-06 14:09 ` [PATCH v2 0/2] HID: hid-goodix: Improve handling of HID feature reports Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241031123113.18843-2-charles.goodix@gmail.com \
    --to=charles.goodix@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=dianders@chromium.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hbarnor@chromium.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).