From nobody Sun Nov 24 23:52:47 2024 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 E23C5A94F; Thu, 31 Oct 2024 12:31:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730377894; cv=none; b=PfZw1kmLSEMjb0scmzX+iIfQOATM6Ni3rQLCmNEqHlAjvTU8YLmoL1Pmv8M13ABZY1hPDyGiNc4fszJTAvvAZoJgyaL5jdHxc0UJM+PTtrVNKPrAaghXUi/D1Thqv0iZ3TNWlDipEOMbgwrDPRuUwE4SnlAYiQLcmAjPguk7kHg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730377894; c=relaxed/simple; bh=BZJ0RVtEMiHD3D0I0figvDtyWGphvQVr6X2533QJCzA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bqx56JiI70jxO1faK3uhGQ1/s2w+iKkiv7U+9F9FvmSCwiIfLz3iz8YDGHy6jTxFamKr84/QPGrtOHJ/HwABHwaaRvFJmG/KUtD1U31W8zxpU6hlJfGMG2rTHZuc5nF5IvfAPMqBgRH7SRes9IrDQ0FxoUAQHnECzt9Xna4PX+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=F2XBUMeb; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F2XBUMeb" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5c935d99dc5so1126924a12.1; Thu, 31 Oct 2024 05:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730377891; x=1730982691; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VK3Tp+WJUMgT1yRHpvd1XzSykhIw6PWcpTXBEG2GUHo=; b=F2XBUMebUOrSmNo2UcyOArISzXRusYcTbFIx7GMpeIdYY8+pkIcq1sM+ZZTKYXw9ys Z46K33tOsm1cXd27s0vsLB6sRROvLeHXjZefypnINsAyuSboWJd2leABWPkoGnhbE8vM HpIIrXNZCji/F/dJsLarNAcYUlS8kAodI9NR4bPVOismIdCzgyADWfGja8vSaupri+Rj grZyFyXZ9MT26InR4fJOK5w6tUBI+uwQdDdrnaCijp1IdzYGfrvBS8Ti0tM2LSV6Ob7g iHE0g942Rr+05z0O6upjZpuTwswl+BSSA4jAtQVaa7cvgDKmWMY8ddFCPNKAi+igMznc NZtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730377891; x=1730982691; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VK3Tp+WJUMgT1yRHpvd1XzSykhIw6PWcpTXBEG2GUHo=; b=t9fJFPw+F8LC3vRby68eWJ5E9jkSqVUcRw+nTORuvXQsR4dMpGZsxlB9wKBIvzJ0SC V0prrwzuBlkw33acpNY5PxdktAKslZOT7HU39gVRxjvEBS/LIZvQ6hUR+P0LSflh655d gwPFDTvQwFDonJ3SVQj2hlIv0jAt7Ti20h4J4UVx8H6f/Ck524hIALLe1NOPF4sf/xOy dSVGS2EjibAqVGVsQrhIVP6qNvhs35ckKbf9H5O6FSGIkCMI8MgZpxYcGdlxs7hILMQK GncCqKIwqGCaisPDycpDP9Qk/ajcHnns+/Rvii+DcwR3qEqHlrn6Y+ReHFlL2lZCqo4Z dKXw== X-Forwarded-Encrypted: i=1; AJvYcCX/WGul5Nr74lSUKEMbuStzDioo21YqsVj4IbtTFFmmaKtgGTc0ktVKPe6mimqjNdKXdMI/iTARrxS9LD/z@vger.kernel.org, AJvYcCXYuPsUNMZPegMgXgRADSNS+xSbPnE/1sNJM+h9sg20BJiyNyW1Dy3IviHSlLArvgVLYe+9CJjfYny39Q==@vger.kernel.org X-Gm-Message-State: AOJu0Yxz3D57kmSM+oKVOZmeaHL5ba3w6zQDWdVU1Q4n3f72nvTTRzGA mjgTEorwoOgtnccOQHPVRUQ6dwqHUEr0qF/zp6/ynSFo7hr0T0xh X-Google-Smtp-Source: AGHT+IFV/LP8zhT6TgEtmC6U/n8wD0DLAN7TckNQUa6rPE9QJ/wUJciPnvUSFhe+u/pL65CvLt+87w== X-Received: by 2002:a05:6402:3589:b0:5c9:4b8c:b910 with SMTP id 4fb4d7f45d1cf-5cbbf87959bmr14880296a12.2.1730377890968; Thu, 31 Oct 2024 05:31:30 -0700 (PDT) Received: from ux-UP-WHL01.. (mailgw01.goodix.com. [45.117.96.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ceac77051csm526749a12.32.2024.10.31.05.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 05:31:30 -0700 (PDT) From: Charles Wang 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 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 Message-ID: <20241031123113.18843-2-charles.goodix@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241031123113.18843-1-charles.goodix@gmail.com> References: <20241031123113.18843-1-charles.goodix@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 =3D len; + *resp_len =3D len - GOODIX_HID_PKG_LEN_SIZE; return 0; } =20 @@ -446,7 +446,10 @@ static int goodix_hid_get_raw_report(struct hid_device= *hid, if (error) return error; =20 - len =3D min(len, response_data_len - GOODIX_HID_PKG_LEN_SIZE); + /* Empty reprot response */ + if (!response_data_len) + return 0; + len =3D min(len, response_data_len); /* Step3: read response data(skip 2bytes of hid pkg length) */ error =3D goodix_spi_read(ts, ts->hid_report_addr + GOODIX_HID_ACK_HEADER_SIZE + --=20 2.43.0 From nobody Sun Nov 24 23:52:47 2024 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (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 826B719D899; Thu, 31 Oct 2024 12:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730377900; cv=none; b=cw+Ro+bYPkJ8s3kRbO13CTWbviKDtzYGFJMWzdJyrauCcbXALKFojC8Mf7neDC5CqFhxzc5P03A3WEc+63uIzX/CKA1c8E/OamJ3GRBhkeaJ8DiBgIZcVSPwtYZaBOAUeVMuLdm6klHvjVE+X7wSAbGF8n5CNZFMwa2+ihpqFfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730377900; c=relaxed/simple; bh=H7GIctt0io2N4XE4yFaBYUE6NcdV5pi8sBEJ0BLVIcE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nmdnmCUtw+uqBiomIGA1h1VfNzrq60hIV1m6/hNWOrn3EjuB2ggUe53mLU8j/tIPd6nbktrcmzsoSbfuRwzB3gQwv/fr8Ch40Y7P5yvFs68mmjDPC8LnAwhvuBoHybSvP61ltElG6nZ1JKZNftl0KLY5ZWQJ6wpVb+PrRrXzqZE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OdOq5jEd; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OdOq5jEd" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-5c95a962c2bso1114687a12.2; Thu, 31 Oct 2024 05:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730377897; x=1730982697; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=030u3nkgqedDZazDWxOyhP0BS2swBwPxC1Ur78jbHOY=; b=OdOq5jEd+TuIiwmd6zIWdPgo/frKKPEuO+3m7Bqb4iYu7mKI5XaZbPBXrK8S4Dz0l2 VueQYv4YhpkrPt8OfL934GudBrgZaS8Z7tzdlHsqJJ+rHB6fXQNEsYritLC82eieyhHg 8wRaHkvIngwZ4vz222HNE7n3dSq7v42GnOSNpJBE/e8FN369EcqZj+YhzkqLsaS99fwF xosUJQLMX7NeoiRSns2u/WmyDhJtT8t0cWgXjz9/53PXvVE1ug7AB5DmdR31LzfsVY42 SWXdfBalLTeFsgdASh3sxITQzp65REQaEvTzqUeYCuKbQacLJH79eXEYi8qVD7/elGbi aNiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730377897; x=1730982697; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=030u3nkgqedDZazDWxOyhP0BS2swBwPxC1Ur78jbHOY=; b=gT1ZQEw3+XS0EzSJZEdRWHzTCM1SgtewH0lk8k5GJCadO67MIv6RygZUy+drj1GNX9 tFIpJVJKNtO96cVu5eoxQEecfz90nScglBN4lSGqBODHQNC00bKoNyx7bbwePJS32PhK XQVsCmZ30cn43ie0anK5XFObcmIfbaAjikRX48WNirChZPGwa1eVfvWxMRaSPqqCabOw lE4z2MsN0qoWmK//tMbh76EsvKQf3yuhRMJOCIfjD2VwEnotLICOLmXMe3WoJ882TDNV JBqRZ2OYcGs0Alw6dTfi0Evhkw5yBBbdPAT33jXSu+qqHdM9nmUyLGWPIIN+SYDmJS5D 9FRQ== X-Forwarded-Encrypted: i=1; AJvYcCVF4sQsMOQW3n2GkCCrG5M1EVLdDUBn8UuNVBgr9JU9EZiYb+gv4Pw6HCoSVsYHCzX4NzE1wqf2wGcHsA==@vger.kernel.org, AJvYcCWwGzSyn/PsspoyzdwJd7oZCWtp6R3GoBpZEq/J7X+rVbAZQCFahxzN6ktLoLNL75vQoMhit+XmlPd5kGGH@vger.kernel.org X-Gm-Message-State: AOJu0Yx902ZzH9U6EYb5qmxy1n3TWAq4/zzaQCjdvqR+baLf2EWAipeG MGVeUN8SmvKsTa5AJ1Gopi4P28cdoEhabIygjB090Lsi40QfOYy5 X-Google-Smtp-Source: AGHT+IH0UeUBvxeS44aCna1iU7XCoZV3dRZdsr4JnU03vEsWIFnzNHvhx5PruG7Y55OLauRG9pTdBQ== X-Received: by 2002:a05:6402:5247:b0:5c9:59e6:e908 with SMTP id 4fb4d7f45d1cf-5cea966bd10mr2164366a12.6.1730377896533; Thu, 31 Oct 2024 05:31:36 -0700 (PDT) Received: from ux-UP-WHL01.. (mailgw01.goodix.com. [45.117.96.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ceac77051csm526749a12.32.2024.10.31.05.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 05:31:36 -0700 (PDT) From: Charles Wang 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 Subject: [PATCH v2 2/2] HID: hid-goodix: Fix HID get/set feature operation overwritten problem Date: Thu, 31 Oct 2024 20:31:13 +0800 Message-ID: <20241031123113.18843-3-charles.goodix@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241031123113.18843-1-charles.goodix@gmail.com> References: <20241031123113.18843-1-charles.goodix@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Implement the hid get/set feature report function using a separate address, rather than sharing an address with coordinate reporting, to prevent feature events from being overwritten by coordinate events. Signed-off-by: Charles Wang --- drivers/hid/hid-goodix-spi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-goodix-spi.c b/drivers/hid/hid-goodix-spi.c index 077a91ee1..6ae2300a6 100644 --- a/drivers/hid/hid-goodix-spi.c +++ b/drivers/hid/hid-goodix-spi.c @@ -19,6 +19,7 @@ #define GOODIX_HID_DESC_ADDR 0x1058C #define GOODIX_HID_REPORT_DESC_ADDR 0x105AA #define GOODIX_HID_SIGN_ADDR 0x10D32 +#define GOODIX_HID_CMD_ADDR 0x10364 =20 #define GOODIX_HID_GET_REPORT_CMD 0x02 #define GOODIX_HID_SET_REPORT_CMD 0x03 @@ -348,7 +349,7 @@ static int goodix_hid_check_ack_status(struct goodix_ts= _data *ts, u32 *resp_len) * - byte 0: Ack flag, value of 1 for data ready * - bytes 1-2: Response data length */ - error =3D goodix_spi_read(ts, ts->hid_report_addr, + error =3D goodix_spi_read(ts, GOODIX_HID_CMD_ADDR, &hdr, sizeof(hdr)); if (!error && (hdr.flag & GOODIX_HID_ACK_READY_FLAG)) { len =3D le16_to_cpu(hdr.size); @@ -431,7 +432,7 @@ static int goodix_hid_get_raw_report(struct hid_device = *hid, tx_len +=3D args_len; =20 /* Step1: write report request info */ - error =3D goodix_spi_write(ts, ts->hid_report_addr, tmp_buf, tx_len); + error =3D goodix_spi_write(ts, GOODIX_HID_CMD_ADDR, tmp_buf, tx_len); if (error) { dev_err(ts->dev, "failed send read feature cmd, %d", error); return error; @@ -451,7 +452,7 @@ static int goodix_hid_get_raw_report(struct hid_device = *hid, return 0; len =3D min(len, response_data_len); /* Step3: read response data(skip 2bytes of hid pkg length) */ - error =3D goodix_spi_read(ts, ts->hid_report_addr + + error =3D goodix_spi_read(ts, GOODIX_HID_CMD_ADDR + GOODIX_HID_ACK_HEADER_SIZE + GOODIX_HID_PKG_LEN_SIZE, buf, len); if (error) { @@ -521,7 +522,7 @@ static int goodix_hid_set_raw_report(struct hid_device = *hid, memcpy(tmp_buf + tx_len, buf, len); tx_len +=3D len; =20 - error =3D goodix_spi_write(ts, ts->hid_report_addr, tmp_buf, tx_len); + error =3D goodix_spi_write(ts, GOODIX_HID_CMD_ADDR, tmp_buf, tx_len); if (error) { dev_err(ts->dev, "failed send report: %*ph", tx_len, tmp_buf); return error; @@ -752,7 +753,7 @@ static int goodix_spi_set_power(struct goodix_ts_data *= ts, int power_state) power_control_cmd[5] =3D power_state; =20 guard(mutex)(&ts->hid_request_lock); - error =3D goodix_spi_write(ts, ts->hid_report_addr, power_control_cmd, + error =3D goodix_spi_write(ts, GOODIX_HID_CMD_ADDR, power_control_cmd, sizeof(power_control_cmd)); if (error) { dev_err(ts->dev, "failed set power mode: %s", --=20 2.43.0