From nobody Thu Apr 2 01:11:16 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 0E13A1D5CD1; Tue, 31 Mar 2026 01:25:33 +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=1774920335; cv=none; b=e7uGhtDjVuqONGmrINTNOsOjtO9S5qyT800mBGcEZrH986Vd6BXb/DdDwHWTD1cAWKCEl3XAtcrM4REwoXWLPhIQeke3GfLSsKR6Sp+2vBtcGUEeo6oKOxbkFjfHyAqPMYMtKIPJP0R5o6TnFNPggZZddCiNN1GCHtZIyAzywss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774920335; c=relaxed/simple; bh=RZY91OMjJU28Y7liW+BhB8BHNyy+3hpc+bc9SQWyHV4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QWsa8cZOQM57ENZL/X1Xi6ttg5XVbw/4XemDAqFY7TvjQfoTl9xsZzIY51q5NpYF+BCcXdPc5gA9bQqXlIE2ciIlGSxe9sPMPQxTZlzIHwJVlgby5Pl2b5gPA9KoVMKtXLWWlqomT1b+wNay0utxRwwSjnXe6XniXgnB8AtxMUU= 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=TzYAIqsT; 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="TzYAIqsT" 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 62V0drYs3764506; Mon, 30 Mar 2026 21:25:30 -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=3a9qY G8Ob6vH+A4MposzRp3at50bEOpQJt3N/E5xu3g=; b=TzYAIqsThC3uH3r/DP1Ie YO7ABTpFEJKSnCXyv/zjifAuJH4NcolUt8FNM0Pw+uw+goplFN9vQCjjVsyhK3ze Diy8X+l/tNdKJLqeppZX3KIydnZGi0aLLfiV7NxgYsdPskqwOPYaK5zgwgjtldHD SOphmh51MvtkUcxEj/HAj7hX7ImTQRSwX/sRMON9spXnvnoNX2qcYgu+TE6jRxHt /yzynfC1E6qEeGK1AG4dP2NiounoSGCSawahnpulBQ7GY0qFo8yg/hNXOZZcAwSX ePVBjRYFAhEY/QiV6Yl330PRcCBvhgJMUOU4GRNWYyUem2EwXGrkY41oavv8/gxg Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4d6bw11w1x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Mar 2026 21:25:29 -0400 (EDT) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 62V1PS1n061178 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 30 Mar 2026 21:25:28 -0400 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Mon, 30 Mar 2026 21:25:28 -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; Mon, 30 Mar 2026 21:25:28 -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; Mon, 30 Mar 2026 21:25:28 -0400 Received: from CJONES7-T01.ad.analog.com (CJONES7-T01.ad.analog.com [10.116.223.230]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 62V1P8RT006886; Mon, 30 Mar 2026 21:25:21 -0400 From: Carlos Jones Jr To: Jonathan Cameron , David Lechner , Michael Hennerich , Liam Beguin , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Jorge Marques CC: , Subject: [PATCH v2 1/2] iio: adc: ltc2309: add read delay for ltc2305 Date: Tue, 31 Mar 2026 09:24:56 +0800 Message-ID: <20260331012457.9324-2-carlosjr.jones@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260331012457.9324-1-carlosjr.jones@analog.com> References: <20260331012457.9324-1-carlosjr.jones@analog.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 X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: ByTF7iYNgV_reMd_jnftCDhIkx80RSLF X-Authority-Analysis: v=2.4 cv=BqyQAIX5 c=1 sm=1 tr=0 ts=69cb228a 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=gAnH3GRIAAAA:8 a=pGLkceISAAAA:8 a=gHBF1_SLQoPjBxjgEcUA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: ByTF7iYNgV_reMd_jnftCDhIkx80RSLF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzMxMDAxMSBTYWx0ZWRfX7U/NiBKtyaeh tll1fqVIj2h8coRTrZdr7gKUgDItXuse2tCF3K9c4EhjVIoXqFGZ+9aoxRAiBtyq4fD845dZY6+ 0SJtuZETtNVbmh0gOpsTzKiW0o15jlGVIWaQer37SK8xBiCYJ7M5xIAvCgOXVuPV9sz/6oyxtKA iwTBmXhQkLtKofpQpwDBHSd+vblSs+lhaM40kYWnWSLKRIDejq/7l97DqCPZSc+9I1JujhFzLMY XZRhYXpUgW621dfBN08EgNKy2/1j+xi5FP6VrFm7Qt4I4hTSLCraAPpS7ceGdGIWoZ3h/Dh1N4K 6PZR10XrWMyvZop1R6ddPKJaFiMF+PRFA7r9VHqfJ66gt1NKZn+PERjOZ7muEKkeE5F70PjueJl bNMDQcK22d/w5bmkFstVUtLiKJWGOztsctVKyVlHr8SuUXDWiOOv6u0Mywqro3qWy7tYV2iEuD/ h5lwEHFeQVkpROXy1lw== 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-30_02,2026-03-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 adultscore=0 impostorscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603310011 The LTC2305 requires a minimum 1.6=CE=BCs delay between the I2C write operation (channel selection) and the subsequent read operation to allow the chip to process the command and prepare the result. While not explicitly documented in the datasheet, this timing requirement was identified by the hardware designer as necessary for reliable operation. Add a read_delay_us field to both the ltc2309_chip_info and ltc2309 device structures to support chip-specific timing requirements. Use fsleep() to implement the delay when non-zero, with LTC2305 set to 2=CE=BCs (1.6=CE=BCs requirement rounded up). LTC2309 does not require additional delay beyond inherent I2C bus timing. This extends the existing LTC2305 support added in (commit 8625d418d24b ("iio: adc: ltc2309: add support for ltc2305")) with the missing inter-transaction delay. Signed-off-by: Carlos Jones Jr Reviewed-by: Andy Shevchenko Reviewed-by: Nuno S=C3=A1 --- drivers/iio/adc/ltc2309.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/iio/adc/ltc2309.c b/drivers/iio/adc/ltc2309.c index 316256edf150..094966289922 100644 --- a/drivers/iio/adc/ltc2309.c +++ b/drivers/iio/adc/ltc2309.c @@ -9,7 +9,9 @@ * * Copyright (c) 2023, Liam Beguin */ +#include #include +#include #include #include #include @@ -34,12 +36,14 @@ * @client: I2C reference * @lock: Lock to serialize data access * @vref_mv: Internal voltage reference + * @read_delay_us: Chip-specific read delay in microseconds */ struct ltc2309 { struct device *dev; struct i2c_client *client; struct mutex lock; /* serialize data access */ int vref_mv; + unsigned int read_delay_us; }; =20 /* Order matches expected channel address, See datasheet Table 1. */ @@ -118,12 +122,14 @@ static const struct iio_chan_spec ltc2309_channels[] = =3D { struct ltc2309_chip_info { const char *name; const struct iio_chan_spec *channels; + unsigned int read_delay_us; int num_channels; }; =20 static const struct ltc2309_chip_info ltc2305_chip_info =3D { .name =3D "ltc2305", .channels =3D ltc2305_channels, + .read_delay_us =3D 2, .num_channels =3D ARRAY_SIZE(ltc2305_channels), }; =20 @@ -151,6 +157,9 @@ static int ltc2309_read_raw_channel(struct ltc2309 *ltc= 2309, return ret; } =20 + if (ltc2309->read_delay_us) + fsleep(ltc2309->read_delay_us); + ret =3D i2c_master_recv(ltc2309->client, (char *)&buf, 2); if (ret < 0) { dev_err(ltc2309->dev, "i2c read failed: %pe\n", ERR_PTR(ret)); @@ -206,6 +215,7 @@ static int ltc2309_probe(struct i2c_client *client) =20 ltc2309->dev =3D &indio_dev->dev; ltc2309->client =3D client; + ltc2309->read_delay_us =3D chip_info->read_delay_us; =20 indio_dev->name =3D chip_info->name; indio_dev->modes =3D INDIO_DIRECT_MODE; --=20 2.43.0 From nobody Thu Apr 2 01:11:16 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 4D865330B3F; Tue, 31 Mar 2026 01:25:37 +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=1774920338; cv=none; b=N7UN/tkXqtr5z98FS1maUVxW1nI67SRWb6P346vM+EnhUT4eo8Ik0Zopual2xdRhKbPl8wWkjWv2RwfmewT5kK4wHIhvEOCyHG0a2QqVLPhXDTUR4hglfhOngtHEFsysGYxxTiAj6USnldntooLLNl4tFyYKUYdSc5mM2HSCN1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774920338; c=relaxed/simple; bh=HyXpjHz/GFInnXaPhZwX0ikxua2pFD/ze7kG4bHhysk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lS5qi0GTBgmmrYMl/UumZAapDPz62dVI3RlCtEAxT1c+FrYceTKQ6dAoBFZPUSphoenrTq/LwM7z2bYORpfunYLo6lLMzNllpp2f3BE34ylPKy1NYycHCsEv7LiNrbu152KWOppVPodaNzTvG5ThvC0wfhLb4rvlWXg+J4ciJP0= 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=oqzVgR7T; 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="oqzVgR7T" Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62V0cShq1955193; Mon, 30 Mar 2026 21:25:33 -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=Hlu5b ztsUdbHdDGx2iRpQkCgxCm6Drv27KSMmfJLoXc=; b=oqzVgR7TMwoJqkI01AxNe YeOmNVSqMJ/u01Biuy/9jONd3nB4rCNJYtr/H+FQEGj/AOWi9I8i9aC05FSN7gJS XXJ4sVQ5rAN5yFV7aPDArQqdQvrPx2j2pVy6BIC9H3wijZ0CmLqyjPtlJSjtc66h eMj4jVdkephkhSUAaseWNVwN5y2P2ixDKkWZrEqOusf8efyZ27WCBXnIGQEiZOIf CziH92s5Phuuz9iQlhwAiiq5nfS2JC/594ywIKhwSQgbiWquLlw9NZrErqvPKaH/ tvu49pI8I6FhTjhwrROXH6Q80Y8Z/gJgzno2LDMbJvOFXtxWW/DMjORCt02NOzYc w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4d740yejxm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Mar 2026 21:25:33 -0400 (EDT) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 62V1PW3G061218 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 30 Mar 2026 21:25:32 -0400 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Mon, 30 Mar 2026 21:25:32 -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; Mon, 30 Mar 2026 21:25:32 -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; Mon, 30 Mar 2026 21:25:32 -0400 Received: from CJONES7-T01.ad.analog.com (CJONES7-T01.ad.analog.com [10.116.223.230]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 62V1P8RU006886; Mon, 30 Mar 2026 21:25:24 -0400 From: Carlos Jones Jr To: Jonathan Cameron , David Lechner , Michael Hennerich , Liam Beguin , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Jorge Marques CC: , Subject: [PATCH v2 2/2] iio: adc: ltc2309: Optimize chip_info structure layout Date: Tue, 31 Mar 2026 09:24:57 +0800 Message-ID: <20260331012457.9324-3-carlosjr.jones@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260331012457.9324-1-carlosjr.jones@analog.com> References: <20260331012457.9324-1-carlosjr.jones@analog.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 X-ADIRuleOP-NewSCL: Rule Triggered X-Authority-Analysis: v=2.4 cv=ANnNY0ku c=1 sm=1 tr=0 ts=69cb228d cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=uXIjobp8t2wMuQ0fPvqm:22 a=gAnH3GRIAAAA:8 a=jloxm63QuxvzzrIBTskA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzMxMDAxMSBTYWx0ZWRfX1eAycNjygVja wakFmd+Y7wO08GiGLY6sw+iYOQIgoUaGr331elI7W5foCEdJbcBcy9LiUv5c7wEUHyjWxGrFhtX c8I+vZK/Z+xudZasS2vdW8mLKN2IV5TtiAzr1FM+ip54DEc21nvSmTDysI8mbanBgjtzXv3Hlx1 2Ni4DH5cw+KzYpjDsYyzTXZ2+tLkNshAUDixfsWD35e8Y5IQxiOnOgYZBycr+ub2KVVv7aXlAZL qyiK+vub64tuFs84Ik83Ms+ed/sW3ciQhGdOu+x4c6SW8lz+tx1hZkLhlVMjevdb4nzR2kI/IK8 fNR2yhgMJPYxHv3na/xfgnoDwJ2dI+qHXU+aPacXK5fnMxF5MmYT11UtG7hCXnrr+KaAZDYnePq zRraNAzk7cBLEEjtWxPCFnjbp7SbZqghr9BOml4dPeRZnwTa9B/1Mf4vYD7SbmoOf6RCqAsA0o4 urXcYLRu8K7xB+MXfTA== X-Proofpoint-ORIG-GUID: MsPVm3PZ7orHTf2Qk_NSXABcza3FsPah X-Proofpoint-GUID: MsPVm3PZ7orHTf2Qk_NSXABcza3FsPah 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-30_02,2026-03-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 malwarescore=0 phishscore=0 priorityscore=1501 adultscore=0 suspectscore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603310011 Content-Type: text/plain; charset="utf-8" Improve the ltc2309_chip_info structure with better type safety and memory efficiency: - Add __counted_by_ptr() annotation to the channels pointer, linking it to num_channels for improved bounds checking and kernel hardening - Reorder structure fields to minimize padding: * Place read_delay_us before num_channels * This reduces struct size and eliminates internal gaps - Reorder field initialization to match the structure definition order The __counted_by_ptr() attribute enables compile-time and runtime verification that array accesses to channels[] stay within the bounds specified by num_channels, improving memory safety. Signed-off-by: Carlos Jones Jr Reviewed-by: Andy Shevchenko Reviewed-by: Nuno S=C3=A1 --- drivers/iio/adc/ltc2309.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/ltc2309.c b/drivers/iio/adc/ltc2309.c index 094966289922..87b78d0353f1 100644 --- a/drivers/iio/adc/ltc2309.c +++ b/drivers/iio/adc/ltc2309.c @@ -121,22 +121,22 @@ static const struct iio_chan_spec ltc2309_channels[] = =3D { =20 struct ltc2309_chip_info { const char *name; - const struct iio_chan_spec *channels; unsigned int read_delay_us; int num_channels; + const struct iio_chan_spec *channels __counted_by_ptr(num_channels); }; =20 static const struct ltc2309_chip_info ltc2305_chip_info =3D { .name =3D "ltc2305", - .channels =3D ltc2305_channels, .read_delay_us =3D 2, .num_channels =3D ARRAY_SIZE(ltc2305_channels), + .channels =3D ltc2305_channels, }; =20 static const struct ltc2309_chip_info ltc2309_chip_info =3D { .name =3D "ltc2309", - .channels =3D ltc2309_channels, .num_channels =3D ARRAY_SIZE(ltc2309_channels), + .channels =3D ltc2309_channels, }; =20 static int ltc2309_read_raw_channel(struct ltc2309 *ltc2309, --=20 2.43.0