From nobody Sat Feb 7 07:24:31 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00D7F238150; Tue, 9 Dec 2025 07:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765266678; cv=none; b=VSJhjn3aHCx859wjJhiZMGFNghnueuNbtMKe8QwwxguI1Pb/N+pcnrVtNllWz+iOrEu+haWDqNl4ryqR7dS2OHnm8/1RMBpnJExtTKbb+DPpblffs4TmAtq6OwMnwXEsU1BSHDT5+Es9mxh6Yz2VTqh6OzvT7i9jAxQ1Cqxo0Cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765266678; c=relaxed/simple; bh=X7gzcrK0aAd5Kpru55vWr3x3CCst6tZRCsKUzGkpRcg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s5mDDuPd+Jcif2vVmOGAPwX9gOcrqIn6dRB676FLBo7n/vfXeXitGhZSHA/jwwjCFZR0Tj2/8ZCS8ZfaOUNpLR4tY7iR6KeeRgHhtAPAzT3jzVmXkHlyPZxjznuUQajGo9N1QbnPafrUza8VqhG5FxZ4YtjDOsaGGp6undXiLxc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=C3F3UU8N; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="C3F3UU8N" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765266677; x=1796802677; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X7gzcrK0aAd5Kpru55vWr3x3CCst6tZRCsKUzGkpRcg=; b=C3F3UU8NQJeqfy63WNfCMOlh0BjH4y054OjOj1kW26qmri1QiWnxJUOi 6Mv+Bk+9vHgDNoYpMAaqaZPOhtUlfcbo8HaHhN7A5U4EIwyQO/5RGqIVc IQmxNg2SPdOZQKMQg/IX1Z86fSY2xlJfbgrzgmnWyyt6dSKdNVxiuHCnj JypcWct4jkCwIt7R6OhJVXd8DNUerqGE8uB97Vzzk9W5mxEgJnSTsHaEj T5VEsZkJxCa4QjdZu5sz9C08gNce0Rats1OtwNLGNcWUYFsPYuXOxqO0k 41KxI24TL9X1LvBtYaQva8Ea9ww7Dm1rUZAM+I7bU2z1lH/T2+C40t7X0 w==; X-CSE-ConnectionGUID: C7q0gC0ZQsCrhUKwlWkC2Q== X-CSE-MsgGUID: 3Fu20+GkQfGi6LWB202vAg== X-IronPort-AV: E=McAfee;i="6800,10657,11636"; a="66942707" X-IronPort-AV: E=Sophos;i="6.20,260,1758610800"; d="scan'208";a="66942707" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2025 23:51:16 -0800 X-CSE-ConnectionGUID: 3gQi4zfXSPi5JMGyBAHgZg== X-CSE-MsgGUID: zQCH4prpS/CBP+giQTIMAg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,260,1758610800"; d="scan'208";a="200599859" Received: from shsensorbuild.sh.intel.com ([10.239.132.250]) by fmviesa005.fm.intel.com with ESMTP; 08 Dec 2025 23:51:14 -0800 From: Even Xu To: jikos@kernel.org, bentiss@kernel.org Cc: srinivas.pandruvada@linux.intel.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Even Xu Subject: [PATCH v2 1/4] HID: Intel-thc-hid: Intel-quicki2c: Use size_t for all length variables Date: Tue, 9 Dec 2025 15:52:12 +0800 Message-Id: <20251209075215.1535371-2-even.xu@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20251209075215.1535371-1-even.xu@intel.com> References: <20251209075215.1535371-1-even.xu@intel.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" Convert all length-related variables in the QuickI2C protocol layer to use size_t type to follow kernel coding conventions. This includes: - All buffer length parameters and variables - Return values of quicki2c_encode_cmd() function which represents encoded command buffer size. - Return values of quicki2c_init_write_buf() function which represents process result: either prepared output buffer size or error code. This change improves type consistency and aligns with standard kernel practices for memory size representation, reducing potential issues with size calculations and comparisons. Signed-off-by: Even Xu --- .../intel-quicki2c/quicki2c-dev.h | 2 +- .../intel-quicki2c/quicki2c-protocol.c | 55 +++++++++---------- .../intel-quicki2c/quicki2c-protocol.h | 4 +- 3 files changed, 28 insertions(+), 33 deletions(-) diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h b/driv= ers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h index 2cb5471a8133..33a1e3db1cb2 100644 --- a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h +++ b/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h @@ -213,7 +213,7 @@ struct quicki2c_device { u8 *report_descriptor; u8 *input_buf; u8 *report_buf; - u32 report_len; + size_t report_len; =20 wait_queue_head_t reset_ack_wq; bool reset_ack; diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c b= /drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c index a63f8c833252..013cbbb39efd 100644 --- a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c +++ b/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c @@ -13,11 +13,11 @@ #include "quicki2c-hid.h" #include "quicki2c-protocol.h" =20 -static int quicki2c_init_write_buf(struct quicki2c_device *qcdev, u32 cmd,= int cmd_len, - bool append_data_reg, u8 *data, int data_len, - u8 *write_buf, int write_buf_len) +static ssize_t quicki2c_init_write_buf(struct quicki2c_device *qcdev, u32 = cmd, size_t cmd_len, + bool append_data_reg, u8 *data, size_t data_len, + u8 *write_buf, size_t write_buf_len) { - int buf_len, offset =3D 0; + size_t buf_len, offset =3D 0; =20 buf_len =3D HIDI2C_REG_LEN + cmd_len; =20 @@ -51,10 +51,10 @@ static int quicki2c_init_write_buf(struct quicki2c_devi= ce *qcdev, u32 cmd, int c return buf_len; } =20 -static int quicki2c_encode_cmd(struct quicki2c_device *qcdev, u32 *cmd_buf, - u8 opcode, u8 report_type, u8 report_id) +static size_t quicki2c_encode_cmd(struct quicki2c_device *qcdev, u32 *cmd_= buf, + u8 opcode, u8 report_type, u8 report_id) { - int cmd_len; + size_t cmd_len; =20 *cmd_buf =3D FIELD_PREP(HIDI2C_CMD_OPCODE, opcode) | FIELD_PREP(HIDI2C_CMD_REPORT_TYPE, report_type); @@ -72,22 +72,20 @@ static int quicki2c_encode_cmd(struct quicki2c_device *= qcdev, u32 *cmd_buf, } =20 static int write_cmd_to_txdma(struct quicki2c_device *qcdev, int opcode, - int report_type, int report_id, u8 *buf, int buf_len) + int report_type, int report_id, u8 *buf, size_t buf_len) { - size_t write_buf_len; - int cmd_len, ret; + size_t cmd_len; + ssize_t len; u32 cmd; =20 cmd_len =3D quicki2c_encode_cmd(qcdev, &cmd, opcode, report_type, report_= id); =20 - ret =3D quicki2c_init_write_buf(qcdev, cmd, cmd_len, buf ? true : false, = buf, + len =3D quicki2c_init_write_buf(qcdev, cmd, cmd_len, buf ? true : false, = buf, buf_len, qcdev->report_buf, qcdev->report_len); - if (ret < 0) - return ret; - - write_buf_len =3D ret; + if (len < 0) + return len; =20 - return thc_dma_write(qcdev->thc_hw, qcdev->report_buf, write_buf_len); + return thc_dma_write(qcdev->thc_hw, qcdev->report_buf, len); } =20 int quicki2c_set_power(struct quicki2c_device *qcdev, enum hidi2c_power_st= ate power_state) @@ -126,13 +124,13 @@ int quicki2c_get_report_descriptor(struct quicki2c_de= vice *qcdev) } =20 int quicki2c_get_report(struct quicki2c_device *qcdev, u8 report_type, - unsigned int reportnum, void *buf, u32 buf_len) + unsigned int reportnum, void *buf, size_t buf_len) { struct hidi2c_report_packet *rpt; - size_t write_buf_len, read_len =3D 0; - int cmd_len, rep_type; + size_t cmd_len, read_len =3D 0; + int rep_type, ret; + ssize_t len; u32 cmd; - int ret; =20 if (report_type =3D=3D HID_INPUT_REPORT) { rep_type =3D HIDI2C_INPUT; @@ -145,25 +143,22 @@ int quicki2c_get_report(struct quicki2c_device *qcdev= , u8 report_type, =20 cmd_len =3D quicki2c_encode_cmd(qcdev, &cmd, HIDI2C_GET_REPORT, rep_type,= reportnum); =20 - ret =3D quicki2c_init_write_buf(qcdev, cmd, cmd_len, true, NULL, 0, + len =3D quicki2c_init_write_buf(qcdev, cmd, cmd_len, true, NULL, 0, qcdev->report_buf, qcdev->report_len); - if (ret < 0) - return ret; - - write_buf_len =3D ret; + if (len < 0) + return len; =20 rpt =3D (struct hidi2c_report_packet *)qcdev->input_buf; =20 - ret =3D thc_swdma_read(qcdev->thc_hw, qcdev->report_buf, write_buf_len, - NULL, rpt, &read_len); + ret =3D thc_swdma_read(qcdev->thc_hw, qcdev->report_buf, len, NULL, rpt, = &read_len); if (ret) { - dev_err_once(qcdev->dev, "Get report failed, ret %d, read len (%zu vs %d= )\n", + dev_err_once(qcdev->dev, "Get report failed, ret %d, read len (%zu vs %z= u)\n", ret, read_len, buf_len); return ret; } =20 if (HIDI2C_DATA_LEN(le16_to_cpu(rpt->len)) !=3D buf_len || rpt->data[0] != =3D reportnum) { - dev_err_once(qcdev->dev, "Invalid packet, len (%d vs %d) report id (%d v= s %d)\n", + dev_err_once(qcdev->dev, "Invalid packet, len (%d vs %zu) report id (%d = vs %d)\n", le16_to_cpu(rpt->len), buf_len, rpt->data[0], reportnum); return -EINVAL; } @@ -174,7 +169,7 @@ int quicki2c_get_report(struct quicki2c_device *qcdev, = u8 report_type, } =20 int quicki2c_set_report(struct quicki2c_device *qcdev, u8 report_type, - unsigned int reportnum, void *buf, u32 buf_len) + unsigned int reportnum, void *buf, size_t buf_len) { int rep_type; int ret; diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.h b= /drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.h index bf4908cce59c..db70e08c8b1c 100644 --- a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.h +++ b/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.h @@ -10,9 +10,9 @@ struct quicki2c_device; =20 int quicki2c_set_power(struct quicki2c_device *qcdev, enum hidi2c_power_st= ate power_state); int quicki2c_get_report(struct quicki2c_device *qcdev, u8 report_type, - unsigned int reportnum, void *buf, u32 buf_len); + unsigned int reportnum, void *buf, size_t buf_len); int quicki2c_set_report(struct quicki2c_device *qcdev, u8 report_type, - unsigned int reportnum, void *buf, u32 buf_len); + unsigned int reportnum, void *buf, size_t buf_len); int quicki2c_get_device_descriptor(struct quicki2c_device *qcdev); int quicki2c_get_report_descriptor(struct quicki2c_device *qcdev); int quicki2c_reset(struct quicki2c_device *qcdev); --=20 2.40.1 From nobody Sat Feb 7 07:24:31 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CA78274B59; Tue, 9 Dec 2025 07:51:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765266680; cv=none; b=ouZsVmTzyFiwhXzF6ol35dptl2Dzmg85yUYQkiHvXL0rqdND1xjgPFVK6GDBw/PqCy1uBxmHFFjy9yORYL31zwgCw7tl0y2EZaKanS5QlpkX7SHEGuOWuO8PYyq948uD6bdLdqdsyByEsM9UAi8TSWbcHb311BZUKSpth9QE9u4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765266680; c=relaxed/simple; bh=vkCl+SoH183sKdoLe4tyyDGe0pgHxw+Cz2RDoVj2blM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R6S/V0p6nt14G9GHoIYX6yQ8JA/s7hfGe6u7EvrtME9WfWHHsEtAzbmXyFBc2tAKQaPdkOjKs2ZK4xkf3uieSCJgn0Y6xavxZCMQyZ/Wt9nAQNuBry1g+PIzbJxGJYQAVYfBWPUG5j4P5jAE049QIE6X3rWFfr0KyyeVqYMw0lM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=BYITJIUt; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BYITJIUt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765266679; x=1796802679; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vkCl+SoH183sKdoLe4tyyDGe0pgHxw+Cz2RDoVj2blM=; b=BYITJIUt2MJIpK7VYXyRmlrkqt2W21gsiwPopcfc1B8K/IgEloqNfrQh WZ1W9lioXk6NJzcL5N/ESb7WfI5+LZkHZnzSG+rQMqxm3fqKzf1JMZ2Wp 7gG+996Q+UpN1iAfNySPb7VHaXlnCebjjv8lPHAedc1kO5Zev0m3dR5zb 9WolkztNUY+mqNvMf0SawFDeXeCtuP4Gd8QvEGzBfpXa3BBiik7KzVIwP qRNr4Ot9j0ogIRgDYGNgvG0vyaPFr/TEqEyNehm1OJuud/hK6qj0y9+Nn i2vyY1WckDDkvTKx08TFTBicolnNEd+LPJya5iamg0W8sYi7ZFDBmudPK A==; X-CSE-ConnectionGUID: 3wz8eM2qSaOwbpJqaBiNzA== X-CSE-MsgGUID: vNBUT/uWSTKx1IRX5jm4tA== X-IronPort-AV: E=McAfee;i="6800,10657,11636"; a="66942716" X-IronPort-AV: E=Sophos;i="6.20,260,1758610800"; d="scan'208";a="66942716" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2025 23:51:18 -0800 X-CSE-ConnectionGUID: lVQcfihQTbKAzzl62BpKaw== X-CSE-MsgGUID: 8VE3lFBLS/ipfPSc1A00yg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,260,1758610800"; d="scan'208";a="200599868" Received: from shsensorbuild.sh.intel.com ([10.239.132.250]) by fmviesa005.fm.intel.com with ESMTP; 08 Dec 2025 23:51:16 -0800 From: Even Xu To: jikos@kernel.org, bentiss@kernel.org Cc: srinivas.pandruvada@linux.intel.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Even Xu Subject: [PATCH v2 2/4] HID: Intel-thc-hid: Intel-quicki2c: Use put_unaligned_le16 for __le16 writes Date: Tue, 9 Dec 2025 15:52:13 +0800 Message-Id: <20251209075215.1535371-3-even.xu@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20251209075215.1535371-1-even.xu@intel.com> References: <20251209075215.1535371-1-even.xu@intel.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" Replace memcpy operations with put_unaligned_le16() when writing 16-bit little-endian values to the write buffer. This change improves code clarity and ensures proper handling of unaligned memory access. Signed-off-by: Even Xu --- drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c b= /drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c index 013cbbb39efd..ab390ce79c21 100644 --- a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c +++ b/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c @@ -41,9 +41,7 @@ static ssize_t quicki2c_init_write_buf(struct quicki2c_de= vice *qcdev, u32 cmd, s } =20 if (data && data_len) { - __le16 len =3D cpu_to_le16(data_len + HIDI2C_LENGTH_LEN); - - memcpy(write_buf + offset, &len, HIDI2C_LENGTH_LEN); + put_unaligned_le16(data_len + HIDI2C_LENGTH_LEN, write_buf + offset); offset +=3D HIDI2C_LENGTH_LEN; memcpy(write_buf + offset, data, data_len); } --=20 2.40.1 From nobody Sat Feb 7 07:24:31 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AFC028D83D; Tue, 9 Dec 2025 07:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765266681; cv=none; b=NlMoHiWPt/mO1Me18o1rQ3fi/q3acHD7SaWPhzlHC7R0f/XhpH8ITmw3s5K77hZJF9rb93PfR267IeZoK8XIUE/NdoReaFiz3sQ1OFwKdWRvsRS4LHFbbdMJ6RawbtOB5rD3KUhR981j9BH3TKsdGCtX9HJvTAqTkDN+Sk3Gw+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765266681; c=relaxed/simple; bh=G898iUbe2qQBPUD3ohaw3FS8dYlUa4YTX2bWEkPQMrs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=DkJWaccY/ug96Mx/w54HEarleM37nBp6BO3PO74rwT9T5rIsNUBVWd83yOiZDhjI6J3UvDuOdR00SOmtppG8N3g11ZECwsA0Wt8XPGkHzI85Cl4/pfxxk64tZ/rCMYG21W9uKGR/I5sIGR7vP4h7zcwu3hJXeDsC9egoFqg52+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NGw/opoo; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NGw/opoo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765266681; x=1796802681; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G898iUbe2qQBPUD3ohaw3FS8dYlUa4YTX2bWEkPQMrs=; b=NGw/opoohb0Pizut8IGjaIdQZaT5vMCmONLOAYVHzjW2GYMPR1U/PuBR CA2KXiqXaylXZsfN9oW6VHRgfISDfSjrqylNsk5wbRvjmEH8g3xX79zsY CVQuqQp+R1QT9AEgwRlvn2AhiN0nLEd5vMxpq1GZSBw1WTGaMUj79OCpa SxGzR0j3AhH4DLWi8mLN8siaAznmt+wy1IMGzKzITbsG6qbREDWuCEk00 km4eXGVWgMtiNQIJiTAwfhowhIklgOO2ESCYojba1N0nQJuGQOs9R818a 8vAxyqKTTSfw7OZAiV+Lpx2Phl+MME9FGoFuJLw7PtjscFia6nEz7Ox1n Q==; X-CSE-ConnectionGUID: vPQ05OaHQdGGRI3I5qVkyw== X-CSE-MsgGUID: wD3j4qmjT/C6iAQn9dYXXw== X-IronPort-AV: E=McAfee;i="6800,10657,11636"; a="66942722" X-IronPort-AV: E=Sophos;i="6.20,260,1758610800"; d="scan'208";a="66942722" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2025 23:51:20 -0800 X-CSE-ConnectionGUID: PvMbmxZYSeebGPP/ZHUUMg== X-CSE-MsgGUID: W6OWAU2eTbWZ9ok2qmLXaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,260,1758610800"; d="scan'208";a="200599891" Received: from shsensorbuild.sh.intel.com ([10.239.132.250]) by fmviesa005.fm.intel.com with ESMTP; 08 Dec 2025 23:51:17 -0800 From: Even Xu To: jikos@kernel.org, bentiss@kernel.org Cc: srinivas.pandruvada@linux.intel.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Even Xu , Rui Zhang , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 3/4] HID: Intel-thc-hid: Intel-quicki2c: Support writing output report format Date: Tue, 9 Dec 2025 15:52:14 +0800 Message-Id: <20251209075215.1535371-4-even.xu@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20251209075215.1535371-1-even.xu@intel.com> References: <20251209075215.1535371-1-even.xu@intel.com> 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 There are two output formats requested in the HID-over-I2C specification: - Command format (set feature/set report): encoded command written to command register, followed by data written to data register - Output report format: all data written directly to output register Current quicki2c_init_write_buf() implementation only supports the command format. Extend quicki2c_init_write_buf() to automatically detect the output format based on the presence of command parameters and prepare the appropriate output buffer accordingly. Tested-by: Rui Zhang Signed-off-by: Even Xu Reviewed-by: Ilpo J=C3=A4rvinen --- .../intel-quicki2c/quicki2c-protocol.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c b= /drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c index ab390ce79c21..a287d9ee09c3 100644 --- a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c +++ b/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c @@ -30,13 +30,18 @@ static ssize_t quicki2c_init_write_buf(struct quicki2c_= device *qcdev, u32 cmd, s if (buf_len > write_buf_len) return -EINVAL; =20 - memcpy(write_buf, &qcdev->dev_desc.cmd_reg, HIDI2C_REG_LEN); - offset +=3D HIDI2C_REG_LEN; - memcpy(write_buf + offset, &cmd, cmd_len); - offset +=3D cmd_len; + if (cmd_len) { + memcpy(write_buf, &qcdev->dev_desc.cmd_reg, HIDI2C_REG_LEN); + offset +=3D HIDI2C_REG_LEN; + memcpy(write_buf + offset, &cmd, cmd_len); + offset +=3D cmd_len; =20 - if (append_data_reg) { - memcpy(write_buf + offset, &qcdev->dev_desc.data_reg, HIDI2C_REG_LEN); + if (append_data_reg) { + memcpy(write_buf + offset, &qcdev->dev_desc.data_reg, HIDI2C_REG_LEN); + offset +=3D HIDI2C_REG_LEN; + } + } else { + memcpy(write_buf, &qcdev->dev_desc.output_reg, HIDI2C_REG_LEN); offset +=3D HIDI2C_REG_LEN; } =20 --=20 2.40.1 From nobody Sat Feb 7 07:24:31 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA2982BFC9B; Tue, 9 Dec 2025 07:51:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765266683; cv=none; b=jJtuwqgFcLOgG0YcGmseGDHOp09Kh9ABfmvshk4PHUJQLSoNNHyouRIUGUWosGAIwtSDWQ3uRHrn93xReM2pQ725wQXmTL7q5nXoRIfkupjqVE1q7IV2caFFw57LcZEVqMx0OuFjI0zism6UKaDNNTvXt51pKr2KfacxfeJM4T4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765266683; c=relaxed/simple; bh=OB+grOpXq9Mxj95V30qtt0Ngvra6qeeGMujiNZOXFG8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Tu52p3cDMUVP4N8l0tiqrfesRI7VpvICxzocNG18t1Agdc2qAiPlUJOGTGpqPc251dULG9hFVzazUQAnG+12pYLugechdLDHAsCZx7AA8SOQ6uw5WecL9oZGOiMYcGVRtbSDfVXmELB7fZpoeyyqHLh7YJzAwFAzcPwq4ROtftw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=aW06MWMR; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aW06MWMR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765266682; x=1796802682; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OB+grOpXq9Mxj95V30qtt0Ngvra6qeeGMujiNZOXFG8=; b=aW06MWMRg0jRzehklzRW/Anhy3oj7jyeFJRZIUisfZMsmWZkNiQksu/A n4EbXdTN3luQpmRmVnkBpFF5cLCrtm5qTrynGdF68Wj1WykNqWTy9EwFe mXpFJfvMY9gYF5wXjLuXnqa4jqj4iZ6HxTIKv9A4dLx6AGYHmf23PBrWB TdOqtNNy77RHyd5+0LlNS9SHlsE4/8I1WKv0mzb0HtD2MpIELQBnMTWW7 xWQCc+0sbhUsdaDV6WwRw/RfXXE0sFUMKGUN/Ur/Q9WeD1I9Ww6rinqm/ LB/4OcNsgBQcpm6Ju0qbtsn/oLrMEQJ5oBPXpWdEh0NEgr6XrTcayZhwu w==; X-CSE-ConnectionGUID: OuABVViAROuOcKhZ/8GbNw== X-CSE-MsgGUID: aAMaNu61Tr6ypQ4bOQw6Dw== X-IronPort-AV: E=McAfee;i="6800,10657,11636"; a="66942726" X-IronPort-AV: E=Sophos;i="6.20,260,1758610800"; d="scan'208";a="66942726" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2025 23:51:22 -0800 X-CSE-ConnectionGUID: KUl2hELkTQ2jTCKIRRVpxw== X-CSE-MsgGUID: HmOPS4A0SLKYD4KJ15NuOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,260,1758610800"; d="scan'208";a="200599936" Received: from shsensorbuild.sh.intel.com ([10.239.132.250]) by fmviesa005.fm.intel.com with ESMTP; 08 Dec 2025 23:51:19 -0800 From: Even Xu To: jikos@kernel.org, bentiss@kernel.org Cc: srinivas.pandruvada@linux.intel.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Even Xu , Rui Zhang Subject: [PATCH v2 4/4] HID: Intel-thc-hid: Intel-quicki2c: Add output report support Date: Tue, 9 Dec 2025 15:52:15 +0800 Message-Id: <20251209075215.1535371-5-even.xu@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20251209075215.1535371-1-even.xu@intel.com> References: <20251209075215.1535371-1-even.xu@intel.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" Add support for HID output reports in the intel-quicki2c driver by implementing the output_report callback in the HID low-level driver interface. This enables proper communication with HID devices that require output report functionality, such as setting device configuration or updating device firmware. Tested-by: Rui Zhang Signed-off-by: Even Xu --- .../intel-quicki2c/quicki2c-hid.c | 8 ++++++++ .../intel-quicki2c/quicki2c-protocol.c | 19 +++++++++++++++++++ .../intel-quicki2c/quicki2c-protocol.h | 1 + 3 files changed, 28 insertions(+) diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-hid.c b/driv= ers/hid/intel-thc-hid/intel-quicki2c/quicki2c-hid.c index 5c3ec95bb3fd..580a760b3ffc 100644 --- a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-hid.c +++ b/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-hid.c @@ -83,6 +83,13 @@ static int quicki2c_hid_power(struct hid_device *hid, in= t lvl) return 0; } =20 +static int quicki2c_hid_output_report(struct hid_device *hid, u8 *buf, siz= e_t count) +{ + struct quicki2c_device *qcdev =3D hid->driver_data; + + return quicki2c_output_report(qcdev, buf, count); +} + static struct hid_ll_driver quicki2c_hid_ll_driver =3D { .parse =3D quicki2c_hid_parse, .start =3D quicki2c_hid_start, @@ -91,6 +98,7 @@ static struct hid_ll_driver quicki2c_hid_ll_driver =3D { .close =3D quicki2c_hid_close, .power =3D quicki2c_hid_power, .raw_request =3D quicki2c_hid_raw_request, + .output_report =3D quicki2c_hid_output_report, }; =20 /** diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c b= /drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c index a287d9ee09c3..41271301215a 100644 --- a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c +++ b/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c @@ -195,6 +195,25 @@ int quicki2c_set_report(struct quicki2c_device *qcdev,= u8 report_type, return buf_len; } =20 +int quicki2c_output_report(struct quicki2c_device *qcdev, void *buf, size_= t buf_len) +{ + ssize_t len; + int ret; + + len =3D quicki2c_init_write_buf(qcdev, 0, 0, false, buf, buf_len, + qcdev->report_buf, qcdev->report_len); + if (len < 0) + return -EINVAL; + + ret =3D thc_dma_write(qcdev->thc_hw, qcdev->report_buf, len); + if (ret) { + dev_err(qcdev->dev, "Output Report failed, ret %d\n", ret); + return ret; + } + + return buf_len; +} + #define HIDI2C_RESET_TIMEOUT 5 =20 int quicki2c_reset(struct quicki2c_device *qcdev) diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.h b= /drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.h index db70e08c8b1c..6642cefb8a67 100644 --- a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.h +++ b/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.h @@ -13,6 +13,7 @@ int quicki2c_get_report(struct quicki2c_device *qcdev, u8= report_type, unsigned int reportnum, void *buf, size_t buf_len); int quicki2c_set_report(struct quicki2c_device *qcdev, u8 report_type, unsigned int reportnum, void *buf, size_t buf_len); +int quicki2c_output_report(struct quicki2c_device *qcdev, void *buf, size_= t buf_len); int quicki2c_get_device_descriptor(struct quicki2c_device *qcdev); int quicki2c_get_report_descriptor(struct quicki2c_device *qcdev); int quicki2c_reset(struct quicki2c_device *qcdev); --=20 2.40.1