From nobody Thu Apr 9 15:00:54 2026 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (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 B7463346FB7 for ; Sun, 8 Mar 2026 16:48:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772988511; cv=none; b=ZgUUop65LGI1T/1eNDvZeDJ7ileXHMXrC9jFMspf33wpqbnCHgNwvIhXM0DFfsZj6CE7T6Z40El8bOk+Sm87fu+O1C1CQtwbT5k9fk6BT58WuzPl4b45ca+G6LWMFXcRmPXYDwzrzIGjg1ByXyIp5uyz9O08IpVOE8pyxf5yNGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772988511; c=relaxed/simple; bh=2L8F3wEbrWmn5r13QlXUSMAL+xNCy5F6Ta86TY5QAos=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=GTLfYgS4dChzc76cQQIlN9C7HuD0umnQeyx75mRo0JeQkcYktips/eDcaLYz1oORIVBPetO42ndcN5e6AqKEVL7h9XR5Pkabqel7M77QH8vmf98c3lVuZgGuRfNmfUGGZNTyB+Fp0abzQD5m4Cl5I+l3vYg0W0jv6/6OWwuc+xc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=Up2HFq/5; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="Up2HFq/5" Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 628AqRTl1897330; Sun, 8 Mar 2026 12:48:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=DY+XR 2dLMIlBMKlpuqtcDIGI/m3CPs5jGqtHsBq67vE=; b=Up2HFq/5zbDvYHsggoQPl hfE0wu+LO8xPkElw9vriOOI2VztL5rAq2qis0zJFo5b80VO8itvmYpXTEeMxiCvt L46KzXXmUOxRtOhkF6OOQnbDjl0FX3Vf4mmh/8IJagxj7qi67Om+DzOB5U8LSyOa udWRIqS5wIptRJia3/qpy6VYrSHYgNhOSYYI+jGOFCX8OL6en+8IJoP7tP0z1P0P 2NdVSzeW9ma2BvWQYNvi5ULYcIzcLK+RCqtKJTG1QgvCM9ey34oKj40v0/+vTqNp CWNF8HOPeiX4aDbgFmVX3Z3WZodaMJJo9ATVbWxxzAMYUn3BZMoMBULsNKS4qGz/ w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4crht6ud1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 08 Mar 2026 12:48:08 -0400 (EDT) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 628Gm76r014372 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 8 Mar 2026 12:48:07 -0400 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Sun, 8 Mar 2026 12:48:07 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Sun, 8 Mar 2026 12:48:07 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Sun, 8 Mar 2026 12:48:07 -0400 Received: from HYB-DlYm71t3hSl.ad.analog.com ([10.66.6.192]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 628GlhfK003692; Sun, 8 Mar 2026 12:48:01 -0400 From: Jorge Marques Date: Sun, 8 Mar 2026 17:47:40 +0100 Subject: [PATCH 4/5] i3c: master: Negative error codes at send_ccc_cmd 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 Message-ID: <20260308-ad4062-positive-error-fix-v1-4-72d3c5290b4a@analog.com> References: <20260308-ad4062-positive-error-fix-v1-0-72d3c5290b4a@analog.com> In-Reply-To: <20260308-ad4062-positive-error-fix-v1-0-72d3c5290b4a@analog.com> To: Alexandre Belloni , Frank Li , =?utf-8?q?Przemys=C5=82aw_Gaj?= CC: , , "Dan Carpenter" , Jonathan Cameron , Jorge Marques X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1772988463; l=3512; i=jorge.marques@analog.com; s=20250303; h=from:subject:message-id; bh=2L8F3wEbrWmn5r13QlXUSMAL+xNCy5F6Ta86TY5QAos=; b=M9Cim7N9Y6clbylfoXxetgc0TTyb5GaZ3aKvnk7zW8zOHMUxt4a0EbOFFkglqNUCr4L7dl8gS iO8psT+R4i3Agnvjq63Teh2YLULnFKbNGdWL67Z5OwSa9Xdvc32iHeI X-Developer-Key: i=jorge.marques@analog.com; a=ed25519; pk=NUR1IZZMH0Da3QbJ2tBSznSPVfRpuoWdhBzKGSpAdbg= X-ADIRuleOP-NewSCL: Rule Triggered X-Authority-Analysis: v=2.4 cv=f5RFxeyM c=1 sm=1 tr=0 ts=69ada848 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=Z0pTeXoby7EwIRygza74:22 a=VwQbUJbxAAAA:8 a=KKAkSRfTAAAA:8 a=gAnH3GRIAAAA:8 a=Eqnk1nJrLcZiEtcKfW8A:9 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: WEhgZdLpURoIQZBl9IgYH1GVXqvpPU1- X-Proofpoint-GUID: WEhgZdLpURoIQZBl9IgYH1GVXqvpPU1- X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA4MDE1NCBTYWx0ZWRfX7ETloNQ+2emd 0FT7i3ddU2FqpQRv7KPYPSYxWjYehlOnos5XSXTktWFimVZxgkIAmNGITALKx2tSjK0Z9Wk5AVs EOKEra/iJp23LtoFEKxqQNk89Gx2zSwSz/PNMpcqM8OwZGvyO1dZ0tJ/OqYJff25rkPNp/5oL+U cqY80t2s3qRNFBLZ/oY+6u/WnNc2grZxtmlmY4cBHfBMO2PQgaP33URRGYatjsAyZmCPyF4wwnE OivKK52PYjEidDJ1eHP/vO+ad/jqmrCVkEeCqapFz8s00qklQo0NYw5kZL2DL44DhsHBP0E4/GN YilApiu4NBCXGLrNcElLaSPv1ymx97kNFokesUSqhEbgKh2BXLSgClUcMQUL1U6KOXnapfVapDt GSBOXpncfJq/n+ORVTS+bb8yAa7KC3Vowi5oyvuRpxeLjmUJKhXLLfFbJZ8812h/HjaRfBr1B9b 12wQVZyYnxZxPHqKZ4w== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-08_04,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 phishscore=0 adultscore=0 priorityscore=1501 spamscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603080154 i3c_master_send_ccc_cmd_locked would propagate cmd->err (positive, Mx codes) to the ret variable, cascading down multiple methods until reaching methods that explicitly stated they would return 0 on success or negative error code. For example, the call chain: i3c_device_enable_ibi <- i3c_dev_enable_ibi_locked <- master->ops.enable_ibi <- i3c_master_enec_locked <- i3c_master_enec_disec_locked <- i3c_master_send_ccc_cmd_locked Fix this by returning the ret value, callers can still read the cmd->err value if ret is negative. Reported-by: Dan Carpenter Closes: https://lore.kernel.org/linux-iio/aYXvT5FW0hXQwhm_@stanley.mountain/ Signed-off-by: Jorge Marques --- drivers/i3c/master.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 3e465587c9c7..8459fffbdebb 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -898,11 +898,17 @@ static void i3c_ccc_cmd_init(struct i3c_ccc_cmd *cmd,= bool rnw, u8 id, cmd->err =3D I3C_ERROR_UNKNOWN; } =20 +/** + * i3c_master_send_ccc_cmd_locked() - send a CCC (Common Command Codes) + * @master: master used to send frames on the bus + * @cmd: command to send + * + * Return: 0 in case of success, or a negative error code otherwise. + * I3C Mx error codes are stored in cmd->err. + */ static int i3c_master_send_ccc_cmd_locked(struct i3c_master_controller *ma= ster, struct i3c_ccc_cmd *cmd) { - int ret; - if (!cmd || !master) return -EINVAL; =20 @@ -920,15 +926,7 @@ static int i3c_master_send_ccc_cmd_locked(struct i3c_m= aster_controller *master, !master->ops->supports_ccc_cmd(master, cmd)) return -EOPNOTSUPP; =20 - ret =3D master->ops->send_ccc_cmd(master, cmd); - if (ret) { - if (cmd->err !=3D I3C_ERROR_UNKNOWN) - return cmd->err; - - return ret; - } - - return 0; + return master->ops->send_ccc_cmd(master, cmd); } =20 static struct i2c_dev_desc * @@ -1101,8 +1099,7 @@ static int i3c_master_enec_disec_locked(struct i3c_ma= ster_controller *master, * * This function must be called with the bus lock held in write mode. * - * Return: 0 in case of success, a positive I3C error code if the error is - * one of the official Mx error codes, and a negative error code otherwise. + * Return: 0 in case of success, or a negative error code otherwise. */ int i3c_master_disec_locked(struct i3c_master_controller *master, u8 addr, u8 evts) @@ -1122,8 +1119,7 @@ EXPORT_SYMBOL_GPL(i3c_master_disec_locked); * * This function must be called with the bus lock held in write mode. * - * Return: 0 in case of success, a positive I3C error code if the error is - * one of the official Mx error codes, and a negative error code otherwise. + * Return: 0 in case of success, or a negative error code otherwise. */ int i3c_master_enec_locked(struct i3c_master_controller *master, u8 addr, u8 evts) @@ -1148,8 +1144,7 @@ EXPORT_SYMBOL_GPL(i3c_master_enec_locked); * * This function must be called with the bus lock held in write mode. * - * Return: 0 in case of success, a positive I3C error code if the error is - * one of the official Mx error codes, and a negative error code otherwise. + * Return: 0 in case of success, or a negative error code otherwise. */ int i3c_master_defslvs_locked(struct i3c_master_controller *master) { --=20 2.51.1