From nobody Mon Dec 1 21:30:51 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 E70B62C029C; Mon, 1 Dec 2025 07:30:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764574215; cv=none; b=VInOyucU157cQ4hvy9Hu/ikAIyPUT5Qk6tFnGd/RIE5XoeWODxzbYxBcOow9u9wcEKLNOZ/n7MGFyKO6FEGBn9nljeadSRSiMj6DE2Pf9IjXZmthvo2AjRg5boA3Dr23nWhSdbJGsdjTCU6D4CIU5LFjwEedO/DMEGgODhecyz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764574215; c=relaxed/simple; bh=X7gzcrK0aAd5Kpru55vWr3x3CCst6tZRCsKUzGkpRcg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q/Yn1rttTamaE05bzxJQ3AlwWXdtIqJ5XtytFQdg+4Mcj5Pi9YMZ9KyB8IvbjgGUj/ajq2l6luKaLxzFacZazEButWb8I0yI7fprfPtJGlkzAa5nqzmD4WWGh6wHevwiE2LvmOATuHwzosAiWfsu7X+n6c+CJvEOdZm4Z6/EihU= 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=AwradLVx; arc=none smtp.client-ip=192.198.163.13 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="AwradLVx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764574214; x=1796110214; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X7gzcrK0aAd5Kpru55vWr3x3CCst6tZRCsKUzGkpRcg=; b=AwradLVxXYtFim9MSkmHlUVFeRcV3RsRdgyahlbOwHvhaY3JNNoo+GUv tMLimva3Y9XDoYg6+u5lVfE6D4krNM5sf04tkocSCsDWjoY093T1AbTgn CmAwXf9yBdQYex2nFU8gCViWfLs34BTEnxLKNHpWDA2p9BcVvJMCtNFBQ tVUhAGPmO2YPXY130DJCuW/5vOxHHLRWuC0jBPy03sBX/F8Rh9cr6/Tg7 si8SoVlLwUgKaw81qdbbuTqm8c2jingQ56DxVdHhT7H++L1BbaF9ZMpnD SDP2S72ntg4JvcNsA41XbIBra7QCTtEjEen+2iMgLnG7X/RRCckdq1iwA Q==; X-CSE-ConnectionGUID: r6HyPHa+Qlu/LMFz9Kktaw== X-CSE-MsgGUID: 0q2Zlxw+RfSCqgCyhzSNew== X-IronPort-AV: E=McAfee;i="6800,10657,11629"; a="69097626" X-IronPort-AV: E=Sophos;i="6.20,240,1758610800"; d="scan'208";a="69097626" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2025 23:30:13 -0800 X-CSE-ConnectionGUID: m0xsXCZfRNaZiOePrd2Zww== X-CSE-MsgGUID: otvsgnzfRcCOBAO2FBXEjQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,240,1758610800"; d="scan'208";a="193886735" Received: from shsensorbuild.sh.intel.com ([10.239.132.250]) by fmviesa006.fm.intel.com with ESMTP; 30 Nov 2025 23:30:11 -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 v1 1/4] HID: Intel-thc-hid: Intel-quicki2c: Use size_t for all length variables Date: Mon, 1 Dec 2025 15:30:44 +0800 Message-Id: <20251201073047.3313824-2-even.xu@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20251201073047.3313824-1-even.xu@intel.com> References: <20251201073047.3313824-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 Mon Dec 1 21:30:51 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 D58D42BE7D9; Mon, 1 Dec 2025 07:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764574224; cv=none; b=WPxxRvzprWAHQFrhsv4pMfjvtVgyeFMQEJrZIW0STJh28OgqCBlj/nafaPqc3BRWcb3kqyW3H5QUyC0tBmjFVmZBidxDqzLxhY9nBBME4njCusRlZRvJmpOpYi3D3eBJTA5GvNiMLwXemKyBqxfywazF4f8e7p+cPuvuaI/rlbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764574224; c=relaxed/simple; bh=vkCl+SoH183sKdoLe4tyyDGe0pgHxw+Cz2RDoVj2blM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ka0UDQ2hAjHVP9z5UkFnrvEs0vrQ9HVC+RkFerp1ny/Dcw+JmCajHa7iwTm4/8EQSWCzdGPl0BeeOpjv+Vqn8h+7da5KXmGOLXs147wnNmY+Sqjgr8s/H6/aNqnoLeszB6Vy8ziG67uln4ibO2sjT+me7dj0eZ5OkaipXaHLrSQ= 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=TrNurtPK; arc=none smtp.client-ip=192.198.163.13 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="TrNurtPK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764574223; x=1796110223; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vkCl+SoH183sKdoLe4tyyDGe0pgHxw+Cz2RDoVj2blM=; b=TrNurtPKnLSz5xOSVmkvWnyTYGj+OJOnlWYTy6km9jyZpnL66p8kIWeI WpBOBEp0/zvQzeQ4zlMMgyArPf8T9JLmJA9DBhVNbdJaUALsbo66OQviq pKT0vqt0VCXltOVHWMwebBDOdlZIYXMI4jTjpFVf0n3rH3nOl/pvXqyTD NYltcO4zLBLg0MnMnvAtiiaPqxhm8PfWVzga9kaRMe8NezB9DVu8fURdI GjoCSNGwnVBL4gAV3/+b1AlDzC4z4cGMhrl5qPRmnlCJ8K//BKcTwzmhw tu2yQMyEJWqTeW/nrdUynVoGVL4l5/NinhqbETcaOKVDTkqxog0ItbYlR Q==; X-CSE-ConnectionGUID: QMVJxvFhQiOQcAm2l9tbBQ== X-CSE-MsgGUID: bTheBPdMQYGkkRYSM0v1ZQ== X-IronPort-AV: E=McAfee;i="6800,10657,11629"; a="69097653" X-IronPort-AV: E=Sophos;i="6.20,240,1758610800"; d="scan'208";a="69097653" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2025 23:30:21 -0800 X-CSE-ConnectionGUID: fQDbG0p/S/GQOih+hHdPoQ== X-CSE-MsgGUID: Hieg8sToS4+J3zrZQ5qT9w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,240,1758610800"; d="scan'208";a="193886784" Received: from shsensorbuild.sh.intel.com ([10.239.132.250]) by fmviesa006.fm.intel.com with ESMTP; 30 Nov 2025 23:30:20 -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 v1 2/4] HID: Intel-thc-hid: Intel-quicki2c: Use put_unaligned_le16 for __le16 writes Date: Mon, 1 Dec 2025 15:30:45 +0800 Message-Id: <20251201073047.3313824-3-even.xu@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20251201073047.3313824-1-even.xu@intel.com> References: <20251201073047.3313824-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 Mon Dec 1 21:30:51 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 A5B462BF3CA; Mon, 1 Dec 2025 07:30:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764574227; cv=none; b=T0KCmmrRwrt0mA0cQexgglnpkclpQIaW4hh8I2/EfVBmzUIDo3JO7YZOoc5X9XGFlWPVDO9O7lRq8pPip1XzeKdGciAhNEr/Fvs8QBQuPH+PnCP2s3bO0UzYzG1Ami2v9dNu5FX8at9iZ+p8mSSxYRsJiabxzdk7NyDK/casojA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764574227; c=relaxed/simple; bh=G898iUbe2qQBPUD3ohaw3FS8dYlUa4YTX2bWEkPQMrs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=WO0tLH/2/3MDg1Hp+RDX9fQ/6TBX3MCODx+vhdJafiN+PC+mpPLowHficMijlQ4v7dB9wwsgvZfgvIs8AlK1mGhB1N34Kjs13DV21QFNtXKZrOci3p0vWNnJR1LarWWhCafvgTIJwGUYMW7OdK9nFbAyEp5E+QEkORGr7JID48o= 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=fWoV/tZd; arc=none smtp.client-ip=192.198.163.13 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="fWoV/tZd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764574225; x=1796110225; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G898iUbe2qQBPUD3ohaw3FS8dYlUa4YTX2bWEkPQMrs=; b=fWoV/tZdEKTQpC2wOtm95CWOZd1ThyyLuihsJfmYfjCQzgTwUuGpd/hj 460Al2Jwbecdf0w1H1+dqXMujczysuGsFToexHf4zPBU7LWW4CnnnITkn UCnm8tqu1tQbZrDdC84gwHJVO87r3U435kp/nf06OumOSzPuwVaezrhZO bPB3ZHmmoKgAQv7P7ucYJiCh3rSnrpFc4JgOaPN57GpXxZ1W9WVhfFgp5 gBsAsfLi6PVhpMrkcGJtrPuChLeYWOaG0kzAkssZq/dA2zVPsMfrh2H0E 7VhM9FKRedidtiGj+rLT6Rvhr/spErfkDpcqQwIyYmYKcPYlZwfYcQqdM g==; X-CSE-ConnectionGUID: pvlg4eGnQHCEhVW6WoIViw== X-CSE-MsgGUID: UKmNkNLETRiCMa1KztnV8w== X-IronPort-AV: E=McAfee;i="6800,10657,11629"; a="69097656" X-IronPort-AV: E=Sophos;i="6.20,240,1758610800"; d="scan'208";a="69097656" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2025 23:30:25 -0800 X-CSE-ConnectionGUID: YieI7aCtTkmUP1Kl7rzHeA== X-CSE-MsgGUID: ABAZSBDeRxyZ3uCkqhBrqw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,240,1758610800"; d="scan'208";a="193886823" Received: from shsensorbuild.sh.intel.com ([10.239.132.250]) by fmviesa006.fm.intel.com with ESMTP; 30 Nov 2025 23:30:24 -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 v1 3/4] HID: Intel-thc-hid: Intel-quicki2c: Support writing output report format Date: Mon, 1 Dec 2025 15:30:46 +0800 Message-Id: <20251201073047.3313824-4-even.xu@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20251201073047.3313824-1-even.xu@intel.com> References: <20251201073047.3313824-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 Mon Dec 1 21:30:51 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 E70F32C15BB; Mon, 1 Dec 2025 07:30:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764574230; cv=none; b=e0pfs4o5B1+eBT4Lk4WqN2djxZO0p/ooDcmX09gJUTVJKmqoBJp8f4v+eYX1nmboqfbU6oJw13+tq1Z7lAmtAhL9hkItDz6fDhtirHj+hTDrx1CC7ywhr5orXjb7cemgWTKPP6CBM6TrQaz7aqobf4ONoGWhPk80bCXuKOA0zJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764574230; c=relaxed/simple; bh=cQf8kKARSTeUHlo1HHrVBItRsCEzadaHyp7VxsKktT8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CZh3qAPtQEXekpJC3KNbfaZRyzs6fuGI1d5ca+ulzJ4oH+9fXA5r6z6Xh8app76epjGr4+WtNPVbXNyhQHkJNWfmMUbiOHAXaae8e11D1Z6oSmXcY8yeZfKSwbHgZDGDPzLjGB0Of1I5/bySWfzulERDNMxYIcp7M8ek7wep8WQ= 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=jDhPLpQh; arc=none smtp.client-ip=192.198.163.13 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="jDhPLpQh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764574229; x=1796110229; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cQf8kKARSTeUHlo1HHrVBItRsCEzadaHyp7VxsKktT8=; b=jDhPLpQhaclqcW3FaGSyc4QFUC9VBpoK0KD4T+IFeNuUgKZC2X1gNiws wPk1j/MM8Th/xSoiNhW1wdv/nrMjydEN1oTiRPvoKhsnYb+kd5YJuoK9f Ymkt0xFaYhguZN8NzYS9PBqqVL2EqSUHrAEeJlLq8imWIjDU0zYQyk2N8 Dm5o2urMq/UbDWpf5SvaifH0ikDZSnYvrblXl0P1QgUoUgLdRQWHWDgmO L8LfafKXe2gB5x9taxnHCJQGXb4WjU0rHbvBenyvUY6nURbGUsPDkIoJH Uh7oSNcKtm2/BGWPdpYtc+Jx4Q+xTDUaI+hnPd/ZbPXVWc8nHi+fdyjCF g==; X-CSE-ConnectionGUID: tUnHWnGtQdWD467P9AiiTQ== X-CSE-MsgGUID: 4on3xuRcTHWFaUw591pd4g== X-IronPort-AV: E=McAfee;i="6800,10657,11629"; a="69097659" X-IronPort-AV: E=Sophos;i="6.20,240,1758610800"; d="scan'208";a="69097659" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2025 23:30:28 -0800 X-CSE-ConnectionGUID: 20/XBXMFQoOC3spPqkk3jQ== X-CSE-MsgGUID: 57qKvULpR3OLw9wtN1QotQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,240,1758610800"; d="scan'208";a="193886851" Received: from shsensorbuild.sh.intel.com ([10.239.132.250]) by fmviesa006.fm.intel.com with ESMTP; 30 Nov 2025 23:30:27 -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 v1 4/4] HID: Intel-thc-hid: Intel-quicki2c: Add output report support Date: Mon, 1 Dec 2025 15:30:47 +0800 Message-Id: <20251201073047.3313824-5-even.xu@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20251201073047.3313824-1-even.xu@intel.com> References: <20251201073047.3313824-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..4030337dd6f5 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) +{ + size_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) + 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