From nobody Sun May 24 20:35:37 2026 Received: from mx0b-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 3CF20383304; Thu, 21 May 2026 16:45:09 +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=1779381911; cv=none; b=VXyEQ6DFtPPmFzcPSGTb0Q+au4IPcQYpyj8qenLPIK9DVHZ0FM/Ye+PBs7r0whw8URLc9RljTLvebX8Y6wcvfrgHg3kS1/OGHf0lpmrkN1gIOBfP4VUtCTUqrrk6xjo2yHp3Mzk5DHYK/89u9oDSjOeH1DPmoEqHKeWFoOst/bI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779381911; c=relaxed/simple; bh=XRkWNNG5Hg7rhStGHHUc0jjdRA6wzpSLFuTGDWL4u+0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fSNUrYR0R+or3YWKOHf0NFM3tFr+9657iwf1f7/ktEXS6igs1ew95UfNF/SW/s34iIyE2fOQxf+3JlukQyyttbljHODC8SvJDLNfCCm9Rrd1OOBsSrOP//ie8HqjXVkj9XQYKSLBRt4vAsu+0UGGqP9K1oZ0CiVvtMKm0NGc/WI= 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=Dcp+jy79; 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="Dcp+jy79" Received: from pps.filterd (m0375855.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64LFM4iR263011; Thu, 21 May 2026 12:45:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=eJ9eY G8/CVKIb4mWxI/df25/ySycLq1tpIcZ3pk+wmc=; b=Dcp+jy79B6ArL5r1uX0S5 uhUW5egET5CKNMY20MJ0Sx0+etXyWy5mY6gEWEXhsBjIwYMsriarb3z1KZdRSnPy AmCJRMrYX7Tx0Chuc4m3El9a4HzLnpGCYJPqicgbKtaSbrvWC7yApy9T+Nenp2Xh gzHgk3ig7BjO4RiIKtrLryu4BJ3ehNdrcnUHc9qATW1SJiD6GIA587uDyy2AoNrP pDjlKtxdoh/vZjHllSyBA+Eq9sVJGVpADtxtvoesnPYkAsYEDc3w8WLNMC1I/Jmf Ecb+d7CAMVGy2u4KWUXW1qwn7o7LrOK9XY1rEohwHrlx/oVjHRRpnQwp2k5dwqKE g== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 4e95e2fa7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 12:45:07 -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 64LGj6rg000333 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 May 2026 12:45:06 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) 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; Thu, 21 May 2026 12:45:06 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Thu, 21 May 2026 12:45:05 -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; Thu, 21 May 2026 12:45:05 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.208]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64LGim0l024538; Thu, 21 May 2026 12:44:57 -0400 From: Liviu Stan To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Michael Hennerich , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Antoniu Miclaus" , Francesco Lavra , Liviu Stan , , , , Subject: [PATCH v3 1/8] iio: temperature: ltc2983: Fix macro parenthesization and rename Date: Thu, 21 May 2026 19:42:54 +0300 Message-ID: <20260521164323.770626-2-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521164323.770626-1-liviu.stan@analog.com> References: <20260521164323.770626-1-liviu.stan@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-Proofpoint-ORIG-GUID: jLofeNu4z8xjXjGBpSJO15NZxIZ1Ej4L X-Authority-Analysis: v=2.4 cv=Fd0HAp+6 c=1 sm=1 tr=0 ts=6a0f3693 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=N--XFCr6TIEc_64PeIT2:22 a=gAnH3GRIAAAA:8 a=OHmJ13SYX3OmEOrlRk8A:9 X-Proofpoint-GUID: jLofeNu4z8xjXjGBpSJO15NZxIZ1Ej4L X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDE2OCBTYWx0ZWRfXw64ZlyVNeg/F CSt42vkcjXT5fyTJ3u0VOGlE295mltqDn6Hvx9lpgNspIV8K45+aPHsiSvAeWkXWHVC2E6kbDxZ 3RfHphGLUVsIdf591IK/1HXbUKqvihjr0xvIRcGJZ0mP7d1jq3O2KT9vgxl5UO7i8M1xTIvFmm9 2VWsa/5xsNACdahgkPCaT0ybMNYmq4icassMu+dVoA6Dn/49ivW0PoGxoxKxud6ajIXqKrDW5G7 NAJaT37JVbWtkJI/mOb79rtuCtfqLRTeOzPsHEd1/s3LM8OTTDgLslHTyJ1oarp5CSTDZxcYLE1 UE5ftNMrBqmvtgN7LYeXr5W2nBDZGzdG9NM5RAjJXMPeWQkRg/oTQXezj7rYfOtEkV9oWi56xlX h8WlGIfEpikC8VkUVh3hNGAaB1IAMPvXu1i0cwUQol78I/CDPMrKe56m8TlDeboy8LZcALvJIse XTbehcGtguNZIrpa16w== 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-05-21_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 spamscore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210168 Content-Type: text/plain; charset="utf-8" Wrap the 'chan' parameter in LTC2983_CHAN_START_ADDR() and LTC2983_CHAN_RES_ADDR() with parentheses to prevent potential macro argument expansion issues. Also rename LTC2983_CHAN_START_ADDR to LTC2983_CHAN_ASSIGN_ADDR and LTC2983_CHAN_RES_ADDR to LTC2983_RESULT_ADDR, to better reflect the datasheet names and avoid them being confused as related. Signed-off-by: Liviu Stan Reviewed-by: Joshua Crofts --- Changes in v3: - Dropped the Fixes: tag - Removed the "base" parameter from ADT7604_RES_RES_ADDR(); the resistance result memory region is (currently) ADT7604-specific so the macro's modification belongs in the driver patch drivers/iio/temperature/ltc2983.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index 38e6f8dfd3b8..67a09934c5bd 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -56,10 +56,10 @@ #define LTC2983_EEPROM_WRITE_TIME_MS 2600 #define LTC2983_EEPROM_READ_TIME_MS 20 =20 -#define LTC2983_CHAN_START_ADDR(chan) \ - (((chan - 1) * 4) + LTC2983_CHAN_ASSIGN_START_REG) -#define LTC2983_CHAN_RES_ADDR(chan) \ - (((chan - 1) * 4) + LTC2983_TEMP_RES_START_REG) +#define LTC2983_CHAN_ASSIGN_ADDR(chan) \ + ((((chan) - 1) * 4) + LTC2983_CHAN_ASSIGN_START_REG) +#define LTC2983_RESULT_ADDR(chan) \ + ((((chan) - 1) * 4) + LTC2983_TEMP_RES_START_REG) #define LTC2983_THERMOCOUPLE_DIFF_MASK BIT(3) #define LTC2983_THERMOCOUPLE_SGL(x) \ FIELD_PREP(LTC2983_THERMOCOUPLE_DIFF_MASK, x) @@ -351,7 +351,7 @@ static int __ltc2983_chan_assign_common(struct ltc2983_= data *st, const struct ltc2983_sensor *sensor, u32 chan_val) { - u32 reg =3D LTC2983_CHAN_START_ADDR(sensor->chan); + u32 reg =3D LTC2983_CHAN_ASSIGN_ADDR(sensor->chan); =20 chan_val |=3D LTC2983_CHAN_TYPE(sensor->type); dev_dbg(&st->spi->dev, "Assign reg:0x%04X, val:0x%08X\n", reg, @@ -1197,7 +1197,7 @@ static int ltc2983_chan_read(struct ltc2983_data *st, } =20 /* read the converted data */ - ret =3D regmap_bulk_read(st->regmap, LTC2983_CHAN_RES_ADDR(sensor->chan), + ret =3D regmap_bulk_read(st->regmap, LTC2983_RESULT_ADDR(sensor->chan), &st->temp, sizeof(st->temp)); if (ret) return ret; --=20 2.43.0 From nobody Sun May 24 20:35:37 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 78B89383323; Thu, 21 May 2026 16:45:14 +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=1779381916; cv=none; b=mRA2Ztkng6OWBJHBwz/TL8f+IUvK5d/PaPDFnztNOtqLfM8vC9hVVhBxUaUJObvlZN5eQrXJ7YWDHiSIH+JOlaAM+ZAShCQfsldYeMSJ7tZtZorC91zjv9L4SJGorlL+0KJfpWPy+RJS2bew9OdPuadEmA+Rh+4TCoA0NKh3vm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779381916; c=relaxed/simple; bh=JBuDbGfSWLIIWGh//jAOEyuiLHrbagSV3SUnm7dzEwM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AeXPmqaRf77LD42DVcb5Kc8Z+jE1NFTY9+GKaicQGlBbHJ5nAhjKfzr57KigHufJrj8elGgOVWDR7IDg2/eXHoenHv9tEHtQOmFGcRS5zcBGZ6//IBfJ+alY+gKzwCp5ebSqKclEztouE09/rxbyCqaUqnMvJ3ovLa1O6O+CHNc= 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=cKRoQIsi; 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="cKRoQIsi" Received: from pps.filterd (m0516787.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64LG03MG601763; Thu, 21 May 2026 12:45:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=jQXq2 hQQLVrD5X8tqbaHK3Yl6kCACOd0kkuSSL4YMlU=; b=cKRoQIsi8d20Cid4iB5lw y2K2E6YLzuRpxVv1yYOrTYG06mM15zKDQaZ5kAkdql3tIZ3QIkN2ouNjGhURMpay 9vALZ6tfLXusEococHBvvWBsi+q1R7bHgUAvAMF46LmSfuidwlWYw7m8WH+8TMNu Cx+o4pquQM49TCdMVZdZN5d7fC3INAVAukyiiX9RvWKnUhBWPFZ9AryQXp+jJ95H Ry2c/Of/yiHEP3g34eNFzlAaNtPdoqLWNXDAzdL+q5kekANGdZTwPKuIhA1W2Rc0 qQi/mJFSDKNGSSDs0tcCr8/p9KjfHIPhMaqS/VEhZFO3/nGKXgSizWK/peIfVIu1 A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4e96sry1dn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 12:45:11 -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 64LGjAt5000337 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 May 2026 12:45:10 -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; Thu, 21 May 2026 12:45:10 -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; Thu, 21 May 2026 12:45:09 -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; Thu, 21 May 2026 12:45:09 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.208]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64LGim0m024538; Thu, 21 May 2026 12:45:01 -0400 From: Liviu Stan To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Michael Hennerich , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Antoniu Miclaus" , Francesco Lavra , Liviu Stan , , , , Subject: [PATCH v3 2/8] iio: temperature: ltc2983: Use local device pointer consistently Date: Thu, 21 May 2026 19:42:55 +0300 Message-ID: <20260521164323.770626-3-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521164323.770626-1-liviu.stan@analog.com> References: <20260521164323.770626-1-liviu.stan@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-Proofpoint-ORIG-GUID: -lX_XGfSE8_bZHYcBt3lbabGvgs4oODS X-Proofpoint-GUID: -lX_XGfSE8_bZHYcBt3lbabGvgs4oODS X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDE2OCBTYWx0ZWRfX8S8ONgCMiUYM P+89yAl1/BPtG3m5xYct+Iied0wul68HoT7Z8yOJ5QPVx3v7NbOmdIigVz98J6+lGblwKITdCBS KGa0cPaUV+EnXR1bFALOzDqGNVupLEldcgqmOi1LdDZaS5MR9LYNyYgKxbJQGSoAucWpoTsefYf sVXhcBuj+p2/i7appiSkbq/IsYq3GNxwSGuExacr+AetYEdN/LXmUMOHb+XAmvqxdSNaeAPhVi3 +s/yUxHy/6x67PpADV1AsjulrvXLX4C2X6RlcA8Jg0mdIexGgDOTu+OJ5B0IhRSTk2/Dm4CWIBZ yExgTV/EZy8hbEVCbuC1vBwyryS9hMgiYeiwN9plWZ1NW3XYFaWYIirCyqAWD5xmJ40GEfOPQvV PJMNwOY55PaT5aGdkHG7ACy2ii+aRDdSZLWl1R3959KGXv+iGnOCFOlv8ivPAMZ9lCNrunyC8hQ IS03ovoMXhl6Ni26RQQ== X-Authority-Analysis: v=2.4 cv=CZs4Irrl c=1 sm=1 tr=0 ts=6a0f3697 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=OmVn7CZJonkx5R5zMQLL:22 a=gAnH3GRIAAAA:8 a=yv4WWxIh8xz3Wh6Jmy8A:9 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-05-21_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 impostorscore=0 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210168 Content-Type: text/plain; charset="utf-8" Some functions define a local 'dev' pointer but still use bare '&st->spi->dev' in some code paths, and some don't have it at all. Replace bare references with the local pointer for consistency. Signed-off-by: Liviu Stan Reviewed-by: Joshua Crofts --- Changes in v3: - Dropped the Fixes: tag - Fixed one remaining dev_dbg() call in __ltc2983_chan_assign_common() that was still using the raw device pointer instead of the dev local variable introduced by this patch drivers/iio/temperature/ltc2983.c | 83 +++++++++++++++++-------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index 67a09934c5bd..d9dcf3e86696 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -351,10 +351,11 @@ static int __ltc2983_chan_assign_common(struct ltc298= 3_data *st, const struct ltc2983_sensor *sensor, u32 chan_val) { + struct device *dev =3D &st->spi->dev; u32 reg =3D LTC2983_CHAN_ASSIGN_ADDR(sensor->chan); =20 chan_val |=3D LTC2983_CHAN_TYPE(sensor->type); - dev_dbg(&st->spi->dev, "Assign reg:0x%04X, val:0x%08X\n", reg, + dev_dbg(dev, "Assign reg:0x%04X, val:0x%08X\n", reg, chan_val); st->chan_val =3D cpu_to_be32(chan_val); return regmap_bulk_write(st->regmap, reg, &st->chan_val, @@ -656,11 +657,12 @@ static struct ltc2983_sensor * ltc2983_thermocouple_new(const struct fwnode_handle *child, struct ltc2983= _data *st, const struct ltc2983_sensor *sensor) { + struct device *dev =3D &st->spi->dev; struct ltc2983_thermocouple *thermo; u32 oc_current; int ret; =20 - thermo =3D devm_kzalloc(&st->spi->dev, sizeof(*thermo), GFP_KERNEL); + thermo =3D devm_kzalloc(dev, sizeof(*thermo), GFP_KERNEL); if (!thermo) return ERR_PTR(-ENOMEM); =20 @@ -687,7 +689,7 @@ ltc2983_thermocouple_new(const struct fwnode_handle *ch= ild, struct ltc2983_data LTC2983_THERMOCOUPLE_OC_CURR(3); break; default: - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid open circuit current:%u\n", oc_current); } @@ -697,7 +699,7 @@ ltc2983_thermocouple_new(const struct fwnode_handle *ch= ild, struct ltc2983_data /* validate channel index */ if (!(thermo->sensor_config & LTC2983_THERMOCOUPLE_DIFF_MASK) && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chann:%d for differential thermocouple\n", sensor->chan); =20 @@ -712,7 +714,7 @@ ltc2983_thermocouple_new(const struct fwnode_handle *ch= ild, struct ltc2983_data * This would be caught later but we can just return * the error right away. */ - return dev_err_ptr_probe(&st->spi->dev, ret, + return dev_err_ptr_probe(dev, ret, "Property reg must be given\n"); } =20 @@ -823,7 +825,7 @@ ltc2983_rtd_new(const struct fwnode_handle *child, stru= ct ltc2983_data *st, } else { /* same as differential case */ if (sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chann:%d for RTD\n", sensor->chan); } @@ -873,7 +875,7 @@ ltc2983_rtd_new(const struct fwnode_handle *child, stru= ct ltc2983_data *st, rtd->excitation_current =3D 0x08; break; default: - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid value for excitation current(%u)\n", excitation_current); } @@ -922,7 +924,7 @@ ltc2983_thermistor_new(const struct fwnode_handle *chil= d, struct ltc2983_data *s /* validate channel index */ if (!(thermistor->sensor_config & LTC2983_THERMISTOR_DIFF_MASK) && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chann:%d for differential thermistor\n", sensor->chan); =20 @@ -964,7 +966,7 @@ ltc2983_thermistor_new(const struct fwnode_handle *chil= d, struct ltc2983_data *s case 0: /* auto range */ if (sensor->type >=3D LTC2983_SENSOR_THERMISTOR_STEINHART) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Auto Range not allowed for custom sensors\n"); =20 thermistor->excitation_current =3D 0x0c; @@ -1003,7 +1005,7 @@ ltc2983_thermistor_new(const struct fwnode_handle *ch= ild, struct ltc2983_data *s thermistor->excitation_current =3D 0x0b; break; default: - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid value for excitation current(%u)\n", excitation_current); } @@ -1016,11 +1018,12 @@ static struct ltc2983_sensor * ltc2983_diode_new(const struct fwnode_handle *child, const struct ltc2983_= data *st, const struct ltc2983_sensor *sensor) { + struct device *dev =3D &st->spi->dev; struct ltc2983_diode *diode; u32 temp =3D 0, excitation_current =3D 0; int ret; =20 - diode =3D devm_kzalloc(&st->spi->dev, sizeof(*diode), GFP_KERNEL); + diode =3D devm_kzalloc(dev, sizeof(*diode), GFP_KERNEL); if (!diode) return ERR_PTR(-ENOMEM); =20 @@ -1036,7 +1039,7 @@ ltc2983_diode_new(const struct fwnode_handle *child, = const struct ltc2983_data * /* validate channel index */ if (!(diode->sensor_config & LTC2983_DIODE_DIFF_MASK) && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chann:%d for differential thermistor\n", sensor->chan); =20 @@ -1061,7 +1064,7 @@ ltc2983_diode_new(const struct fwnode_handle *child, = const struct ltc2983_data * diode->excitation_current =3D 0x03; break; default: - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid value for excitation current(%u)\n", excitation_current); } @@ -1079,23 +1082,24 @@ static struct ltc2983_sensor *ltc2983_r_sense_new(s= truct fwnode_handle *child, struct ltc2983_data *st, const struct ltc2983_sensor *sensor) { + struct device *dev =3D &st->spi->dev; struct ltc2983_rsense *rsense; int ret; u32 temp; =20 - rsense =3D devm_kzalloc(&st->spi->dev, sizeof(*rsense), GFP_KERNEL); + rsense =3D devm_kzalloc(dev, sizeof(*rsense), GFP_KERNEL); if (!rsense) return ERR_PTR(-ENOMEM); =20 /* validate channel index */ if (sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chann:%d for r_sense\n", sensor->chan); =20 ret =3D fwnode_property_read_u32(child, "adi,rsense-val-milli-ohms", &tem= p); if (ret) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Property adi,rsense-val-milli-ohms missing\n"); /* * Times 1000 because we have milli-ohms and __convert_to_raw @@ -1115,9 +1119,10 @@ static struct ltc2983_sensor *ltc2983_adc_new(struct= fwnode_handle *child, struct ltc2983_data *st, const struct ltc2983_sensor *sensor) { + struct device *dev =3D &st->spi->dev; struct ltc2983_adc *adc; =20 - adc =3D devm_kzalloc(&st->spi->dev, sizeof(*adc), GFP_KERNEL); + adc =3D devm_kzalloc(dev, sizeof(*adc), GFP_KERNEL); if (!adc) return ERR_PTR(-ENOMEM); =20 @@ -1125,7 +1130,7 @@ static struct ltc2983_sensor *ltc2983_adc_new(struct = fwnode_handle *child, adc->single_ended =3D true; =20 if (!adc->single_ended && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chan:%d for differential adc\n", sensor->chan); =20 @@ -1140,9 +1145,10 @@ static struct ltc2983_sensor *ltc2983_temp_new(struc= t fwnode_handle *child, struct ltc2983_data *st, const struct ltc2983_sensor *sensor) { + struct device *dev =3D &st->spi->dev; struct ltc2983_temp *temp; =20 - temp =3D devm_kzalloc(&st->spi->dev, sizeof(*temp), GFP_KERNEL); + temp =3D devm_kzalloc(dev, sizeof(*temp), GFP_KERNEL); if (!temp) return ERR_PTR(-ENOMEM); =20 @@ -1150,7 +1156,7 @@ static struct ltc2983_sensor *ltc2983_temp_new(struct= fwnode_handle *child, temp->single_ended =3D true; =20 if (!temp->single_ended && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chan:%d for differential temp\n", sensor->chan); =20 @@ -1169,13 +1175,14 @@ static struct ltc2983_sensor *ltc2983_temp_new(stru= ct fwnode_handle *child, static int ltc2983_chan_read(struct ltc2983_data *st, const struct ltc2983_sensor *sensor, int *val) { + struct device *dev =3D &st->spi->dev; u32 start_conversion =3D 0; int ret; unsigned long time; =20 start_conversion =3D LTC2983_STATUS_START(true); start_conversion |=3D LTC2983_STATUS_CHAN_SEL(sensor->chan); - dev_dbg(&st->spi->dev, "Start conversion on chan:%d, status:%02X\n", + dev_dbg(dev, "Start conversion on chan:%d, status:%02X\n", sensor->chan, start_conversion); /* start conversion */ ret =3D regmap_write(st->regmap, LTC2983_STATUS_REG, start_conversion); @@ -1192,7 +1199,7 @@ static int ltc2983_chan_read(struct ltc2983_data *st, time =3D wait_for_completion_timeout(&st->completion, msecs_to_jiffies(300)); if (!time) { - dev_warn(&st->spi->dev, "Conversion timed out\n"); + dev_warn(dev, "Conversion timed out\n"); return -ETIMEDOUT; } =20 @@ -1205,7 +1212,7 @@ static int ltc2983_chan_read(struct ltc2983_data *st, *val =3D __be32_to_cpu(st->temp); =20 if (!(LTC2983_RES_VALID_MASK & *val)) { - dev_err(&st->spi->dev, "Invalid conversion detected\n"); + dev_err(dev, "Invalid conversion detected\n"); return -EIO; } =20 @@ -1222,11 +1229,12 @@ static int ltc2983_read_raw(struct iio_dev *indio_d= ev, int *val, int *val2, long mask) { struct ltc2983_data *st =3D iio_priv(indio_dev); + struct device *dev =3D &st->spi->dev; int ret; =20 /* sanity check */ if (chan->address >=3D st->num_channels) { - dev_err(&st->spi->dev, "Invalid chan address:%ld", + dev_err(dev, "Invalid chan address:%ld", chan->address); return -EINVAL; } @@ -1303,7 +1311,7 @@ static int ltc2983_parse_fw(struct ltc2983_data *st) =20 st->num_channels =3D device_get_child_node_count(dev); if (!st->num_channels) - return dev_err_probe(&st->spi->dev, -EINVAL, + return dev_err_probe(dev, -EINVAL, "At least one channel must be given!\n"); =20 st->sensors =3D devm_kcalloc(dev, st->num_channels, sizeof(*st->sensors), @@ -1391,6 +1399,7 @@ static int ltc2983_eeprom_cmd(struct ltc2983_data *st= , unsigned int cmd, unsigned int wait_time, unsigned int status_reg, unsigned long status_fail_mask) { + struct device *dev =3D &st->spi->dev; unsigned long time; unsigned int val; int ret; @@ -1410,7 +1419,7 @@ static int ltc2983_eeprom_cmd(struct ltc2983_data *st= , unsigned int cmd, time =3D wait_for_completion_timeout(&st->completion, msecs_to_jiffies(wait_time)); if (!time) - return dev_err_probe(&st->spi->dev, -ETIMEDOUT, + return dev_err_probe(dev, -ETIMEDOUT, "EEPROM command timed out\n"); =20 ret =3D regmap_read(st->regmap, status_reg, &val); @@ -1418,7 +1427,7 @@ static int ltc2983_eeprom_cmd(struct ltc2983_data *st= , unsigned int cmd, return ret; =20 if (val & status_fail_mask) - return dev_err_probe(&st->spi->dev, -EINVAL, + return dev_err_probe(dev, -EINVAL, "EEPROM command failed: 0x%02X\n", val); =20 return 0; @@ -1427,6 +1436,7 @@ static int ltc2983_eeprom_cmd(struct ltc2983_data *st= , unsigned int cmd, static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio) { u32 iio_chan_t =3D 0, iio_chan_v =3D 0, chan, iio_idx =3D 0, status; + struct device *dev =3D &st->spi->dev; int ret; =20 /* make sure the device is up: start bit (7) is 0 and done bit (6) is 1 */ @@ -1434,7 +1444,7 @@ static int ltc2983_setup(struct ltc2983_data *st, boo= l assign_iio) LTC2983_STATUS_UP(status) =3D=3D 1, 25000, 25000 * 10); if (ret) - return dev_err_probe(&st->spi->dev, ret, + return dev_err_probe(dev, ret, "Device startup timed out\n"); =20 ret =3D regmap_update_bits(st->regmap, LTC2983_GLOBAL_CONFIG_REG, @@ -1535,12 +1545,13 @@ static const struct iio_info ltc2983_iio_info =3D { =20 static int ltc2983_probe(struct spi_device *spi) { + struct device *dev =3D &spi->dev; struct ltc2983_data *st; struct iio_dev *indio_dev; struct gpio_desc *gpio; int ret; =20 - indio_dev =3D devm_iio_device_alloc(&spi->dev, sizeof(*st)); + indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; =20 @@ -1552,7 +1563,7 @@ static int ltc2983_probe(struct spi_device *spi) =20 st->regmap =3D devm_regmap_init_spi(spi, <c2983_regmap_config); if (IS_ERR(st->regmap)) - return dev_err_probe(&spi->dev, PTR_ERR(st->regmap), + return dev_err_probe(dev, PTR_ERR(st->regmap), "Failed to initialize regmap\n"); =20 mutex_init(&st->lock); @@ -1565,11 +1576,11 @@ static int ltc2983_probe(struct spi_device *spi) if (ret) return ret; =20 - ret =3D devm_regulator_get_enable(&spi->dev, "vdd"); + ret =3D devm_regulator_get_enable(dev, "vdd"); if (ret) return ret; =20 - gpio =3D devm_gpiod_get_optional(&st->spi->dev, "reset", GPIOD_OUT_HIGH); + gpio =3D devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(gpio)) return PTR_ERR(gpio); =20 @@ -1579,7 +1590,7 @@ static int ltc2983_probe(struct spi_device *spi) gpiod_set_value_cansleep(gpio, 0); } =20 - st->iio_chan =3D devm_kzalloc(&spi->dev, + st->iio_chan =3D devm_kzalloc(dev, st->iio_channels * sizeof(*st->iio_chan), GFP_KERNEL); if (!st->iio_chan) @@ -1589,10 +1600,10 @@ static int ltc2983_probe(struct spi_device *spi) if (ret) return ret; =20 - ret =3D devm_request_irq(&spi->dev, spi->irq, ltc2983_irq_handler, + ret =3D devm_request_irq(dev, spi->irq, ltc2983_irq_handler, IRQF_TRIGGER_RISING, st->info->name, st); if (ret) - return dev_err_probe(&spi->dev, ret, + return dev_err_probe(dev, ret, "failed to request an irq\n"); =20 if (st->info->has_eeprom) { @@ -1610,7 +1621,7 @@ static int ltc2983_probe(struct spi_device *spi) indio_dev->modes =3D INDIO_DIRECT_MODE; indio_dev->info =3D <c2983_iio_info; =20 - return devm_iio_device_register(&spi->dev, indio_dev); + return devm_iio_device_register(dev, indio_dev); } =20 static int ltc2983_resume(struct device *dev) --=20 2.43.0 From nobody Sun May 24 20:35:37 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 9294C3815DE; Thu, 21 May 2026 16:45:15 +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=1779381917; cv=none; b=VmWZfQcOJIJn9BJ0q4Glb8TL+lUMwqK1MLWTC6yw2IQfnZCgv3tRhv2KiwBJNjPuJK1CnqMf7tGzoAD6v+IXbUYhqiRhZwLrlmI9GdlCA9LPkMGc4+uzbCcz5QWw7I5yR+8nN5Ty2mTXULMfHhAySZJuKAW0rHRsDZVwjzHEMF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779381917; c=relaxed/simple; bh=+y1dMQgw5sfTwuvx9tWUOJaUdFHqEkRilOGlLWQGpZA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iYeau1JkJzgCVPDY3DkT2+Z3Ob3kG0Sw9wUR0F87JeUUqtDOiDgbL9btYEFW9NvDZAjr99gmqzfjdFlqFfOjuhTnzDLryZDXrX5E1DcLuXVEgSLiF0NcyS+YFlACCv5/mnD10azQ7LumQxt6HH6IaboqzQ7Mut6Pxq8/oB5TR3I= 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=RHJHyPG7; 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="RHJHyPG7" 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 64LFG62B1703719; Thu, 21 May 2026 12:45:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=nY11L rQtq2f66/N9uimsjAX/hAOL/4gl9n415I6n+xY=; b=RHJHyPG78ubiK5hXS7egt Qv6/SGGEUa8J88W5ryDhukViD/UFyfC0FylHd7gamyhfFZkxAmdVBDj0UGqhhsVL btte6qlmJYlI+1oHWNxDKVdSS8dMxZ2fRXg2Ty9Q2MHiC+tnQYRJ4hXzopRuSLYa Y6cmUoqDDJHQLw29lnskPYOyniSzXaWxAsuPjFoefL/lXzUt8EOUzl+agfG8Raqd bbEOC+IfBdYcucAHWYVd0H490KTGwXAlBnBLf52gMq4iyJpSO1mF6g5DeqFLliJq UXZ+hpVq5QdqU6P7rFJqOhNBi+XAjig5CDFLzN+ZJStfVmm4TgqQGdA7bMU+FUFw Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4e9701f2nh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 12:45:12 -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 64LGjBvN000348 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 May 2026 12:45:11 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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; Thu, 21 May 2026 12:45:11 -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; Thu, 21 May 2026 12:45:11 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.208]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64LGim0n024538; Thu, 21 May 2026 12:45:05 -0400 From: Liviu Stan To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Antoniu Miclaus , Liviu Stan , Francesco Lavra , , , , Subject: [PATCH v3 3/8] iio: temperature: ltc2983: Fix inconsistent channel wording in messages Date: Thu, 21 May 2026 19:42:56 +0300 Message-ID: <20260521164323.770626-4-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521164323.770626-1-liviu.stan@analog.com> References: <20260521164323.770626-1-liviu.stan@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-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDE2OCBTYWx0ZWRfX9qdx5wWNeOr3 0Lth1U3DhdNE0RWAVmVu3ZjR9coTI3gTWn+bjJor5K1Owz+z+LzjIGTmXW2cugNoM/IdXPayES2 SEbAKkuQw5WENbzFwWSB5sDmEzwin8ph9N+ge6x76Z8RaDT4LdhYc91/q/eAWfrNASo4Q1WDOa6 I+usoZ6xmyhKQH8aPjSc0nVBtaupL4qhKz6v2cbZPyaUWBPVZ6IKGVPajPHuCbsssPMv0Hl1wvf gy5mCpc1sdwxJVzhrfsvJtUJKHpg/5L+YCl43h34yGOZgUJTmH01F+cliqXfx2eBH15fXDhzWXZ K8MZdsKJJ51/kmWgoIDyxB+Uq+SsHXE+DSGJvMLD03kZrhtJMMWkctL4VLQiKBlo9ae9Q3RtXrw F6bprSgPGjL/hwyeaj+5qT6Wh356+Nl9i9tD/F3llbYnOIsNhuGfD2iQ+58FidvF9dHxd8YQTl3 C7zrKG3BotwgJQd124w== X-Authority-Analysis: v=2.4 cv=CsaPtH4D c=1 sm=1 tr=0 ts=6a0f3698 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=uXIjobp8t2wMuQ0fPvqm:22 a=gAnH3GRIAAAA:8 a=AdEO_u_nCXX3MimJr_gA:9 X-Proofpoint-ORIG-GUID: nqNynNkcuLnRDn3Uaw2e_3XXNNqwUyx5 X-Proofpoint-GUID: nqNynNkcuLnRDn3Uaw2e_3XXNNqwUyx5 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-05-21_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 clxscore=1015 priorityscore=1501 phishscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 impostorscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210168 Content-Type: text/plain; charset="utf-8" Replace occurrences of the abbreviated 'chann' and 'chan' with 'channel' in error and debug messages throughout the driver. Also changed the diode invalid channel error message from "thermistor" to "diode". Signed-off-by: Liviu Stan Reviewed-by: Joshua Crofts --- Changes in v3: - Dropped both Fixes: tags - Removed the "all" from "all occurrences" in the commit message - Fixed some missed "chan" / "chann" occurrences drivers/iio/temperature/ltc2983.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index d9dcf3e86696..0b9e5f761bd8 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -700,7 +700,7 @@ ltc2983_thermocouple_new(const struct fwnode_handle *ch= ild, struct ltc2983_data if (!(thermo->sensor_config & LTC2983_THERMOCOUPLE_DIFF_MASK) && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chann:%d for differential thermocouple\n", + "Invalid channel %d for differential thermocouple\n", sensor->chan); =20 struct fwnode_handle *ref __free(fwnode_handle) =3D @@ -798,7 +798,7 @@ ltc2983_rtd_new(const struct fwnode_handle *child, stru= ct ltc2983_data *st, /* * rtd channel indexes are a bit more complicated to validate. * For 4wire RTD with rotation, the channel selection cannot be - * >=3D19 since the chann + 1 is used in this configuration. + * >=3D19 since the channel + 1 is used in this configuration. * For 4wire RTDs with kelvin rsense, the rsense channel cannot be * <=3D1 since channel - 1 and channel - 2 are used. */ @@ -815,18 +815,18 @@ ltc2983_rtd_new(const struct fwnode_handle *child, st= ruct ltc2983_data *st, (rtd->r_sense_chan <=3D min)) /* kelvin rsense*/ return dev_err_ptr_probe(dev, -EINVAL, - "Invalid rsense chann:%d to use in kelvin rsense\n", + "Invalid channel %d for kelvin rsense\n", rtd->r_sense_chan); =20 if (sensor->chan < min || sensor->chan > max) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chann:%d for the rtd config\n", + "Invalid channel %d for RTD config\n", sensor->chan); } else { /* same as differential case */ if (sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chann:%d for RTD\n", + "Invalid channel %d for RTD\n", sensor->chan); } =20 @@ -925,7 +925,7 @@ ltc2983_thermistor_new(const struct fwnode_handle *chil= d, struct ltc2983_data *s if (!(thermistor->sensor_config & LTC2983_THERMISTOR_DIFF_MASK) && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chann:%d for differential thermistor\n", + "Invalid channel %d for differential thermistor\n", sensor->chan); =20 /* check custom sensor */ @@ -1040,7 +1040,7 @@ ltc2983_diode_new(const struct fwnode_handle *child, = const struct ltc2983_data * if (!(diode->sensor_config & LTC2983_DIODE_DIFF_MASK) && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chann:%d for differential thermistor\n", + "Invalid channel %d for differential diode\n", sensor->chan); =20 /* set common parameters */ @@ -1094,7 +1094,7 @@ static struct ltc2983_sensor *ltc2983_r_sense_new(str= uct fwnode_handle *child, /* validate channel index */ if (sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chann:%d for r_sense\n", + "Invalid channel %d for r_sense\n", sensor->chan); =20 ret =3D fwnode_property_read_u32(child, "adi,rsense-val-milli-ohms", &tem= p); @@ -1131,7 +1131,7 @@ static struct ltc2983_sensor *ltc2983_adc_new(struct = fwnode_handle *child, =20 if (!adc->single_ended && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chan:%d for differential adc\n", + "Invalid channel %d for differential ADC\n", sensor->chan); =20 /* set common parameters */ @@ -1157,7 +1157,7 @@ static struct ltc2983_sensor *ltc2983_temp_new(struct= fwnode_handle *child, =20 if (!temp->single_ended && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chan:%d for differential temp\n", + "Invalid channel %d for differential temp\n", sensor->chan); =20 temp->custom =3D __ltc2983_custom_sensor_new(st, child, "adi,custom-temp", @@ -1182,7 +1182,7 @@ static int ltc2983_chan_read(struct ltc2983_data *st, =20 start_conversion =3D LTC2983_STATUS_START(true); start_conversion |=3D LTC2983_STATUS_CHAN_SEL(sensor->chan); - dev_dbg(dev, "Start conversion on chan:%d, status:%02X\n", + dev_dbg(dev, "Start conversion on channel:%d, status:%02X\n", sensor->chan, start_conversion); /* start conversion */ ret =3D regmap_write(st->regmap, LTC2983_STATUS_REG, start_conversion); @@ -1234,7 +1234,7 @@ static int ltc2983_read_raw(struct iio_dev *indio_dev, =20 /* sanity check */ if (chan->address >=3D st->num_channels) { - dev_err(dev, "Invalid chan address:%ld", + dev_err(dev, "Invalid channel address: %ld\n", chan->address); return -EINVAL; } @@ -1332,14 +1332,14 @@ static int ltc2983_parse_fw(struct ltc2983_data *st) if (sensor.chan < LTC2983_MIN_CHANNELS_NR || sensor.chan > st->info->max_channels_nr) return dev_err_probe(dev, -EINVAL, - "chan:%d must be from %u to %u\n", + "channel:%d must be from %u to %u\n", sensor.chan, LTC2983_MIN_CHANNELS_NR, st->info->max_channels_nr); =20 if (channel_avail_mask & BIT(sensor.chan)) return dev_err_probe(dev, -EINVAL, - "chan:%d already in use\n", + "channel:%d already in use\n", sensor.chan); =20 ret =3D fwnode_property_read_u32(child, "adi,sensor-type", &sensor.type); @@ -1347,7 +1347,7 @@ static int ltc2983_parse_fw(struct ltc2983_data *st) return dev_err_probe(dev, ret, "adi,sensor-type property must given for child nodes\n"); =20 - dev_dbg(dev, "Create new sensor, type %u, chann %u", + dev_dbg(dev, "Create new sensor, type %u, channel %u", sensor.type, sensor.chan); =20 if (sensor.type >=3D LTC2983_SENSOR_THERMOCOUPLE && --=20 2.43.0 From nobody Sun May 24 20:35:37 2026 Received: from mx0b-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 65468385D75; Thu, 21 May 2026 16:45:21 +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=1779381922; cv=none; b=tVbdvnJkmGX/enuePUNiH7uMhrI/KwWZz2ICBUE1+OkTYboUV1Qu8TCVFLBh1MnRXJGDa7P9rnqCzuecbKKq3mfaw2tsxdqzh8TwcGaSzIzFd2n5beyiKM3WL3WKPHN4bOVteVxriKNTO6LlrqNZGlXWXkh7C1J0lEzT6tq2uCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779381922; c=relaxed/simple; bh=BTCcpES96/yQE4AQwScd6z+xR77a7/D5WMmasoRVL0M=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GieLHWRFR3jQEcDcCOY4kXif6Fq5dDQwhVZz5XG4EPAxxtBFrPPkJ1paQQHMYa/xuj228lBa/viwY0f40J0FGUYWWy8BSOL4CwPJbl3WJoWgypP8GnFQ0B0zAeZY2Rs5wBrlFL7DNxM10K5gePjqYEDT3PYw7I6o1NL1mEY9mJ8= 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=WuLTsX/h; 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="WuLTsX/h" Received: from pps.filterd (m0375855.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64LFM4iT263011; Thu, 21 May 2026 12:45:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=MwvXY QtkVvGtkVVVpGe2BcBcUocfh233ADnI0Xds3JU=; b=WuLTsX/hiujoZWmYRABST obgb5heuwXTZ4hQgdYj5J/gNMY8jy0oN8mV7LSrJIwNWnzLTsslqS4zWOiehvGHZ 7MPCejXoi0NYWh1ewgXq3DTUCJB2mfr+B+RjGRtlzd220Y6umvpgPkhfyTyuqneL uJvp981X7+oEMdLY0JDZ1xdiTmJEPEBGeXGSvFPPgwwm1aJLboc8wrNN7/vwvuka 5bR+8nClTiGOljwdVRxd5+GarUTo0abd13pV/+ndORa3JgJ2Ys/wMZ+Xg0RIpGzL YihHETpHk2x8PhveutwDZ+l0GNR74REOMV+BTaq5MJDst2HMqjTMqNA/jL29W6KY Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 4e95e2fa86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 12:45:18 -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 64LGjHTo000370 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 May 2026 12:45:17 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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; Thu, 21 May 2026 12:45:17 -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; Thu, 21 May 2026 12:45:17 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.208]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64LGim0o024538; Thu, 21 May 2026 12:45:09 -0400 From: Liviu Stan To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Antoniu Miclaus , Francesco Lavra , Liviu Stan , , , , Subject: [PATCH v3 4/8] iio: temperature: ltc2983: Use fwnode_property_present() for optional properties Date: Thu, 21 May 2026 19:42:57 +0300 Message-ID: <20260521164323.770626-5-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521164323.770626-1-liviu.stan@analog.com> References: <20260521164323.770626-1-liviu.stan@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-Proofpoint-ORIG-GUID: 0i9vSjOYDASaqpz6nMYyPFXaEsJS2b_J X-Authority-Analysis: v=2.4 cv=Fd0HAp+6 c=1 sm=1 tr=0 ts=6a0f369e cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=N--XFCr6TIEc_64PeIT2:22 a=gAnH3GRIAAAA:8 a=aunlEJVJ-oeNMYVCzPIA:9 X-Proofpoint-GUID: 0i9vSjOYDASaqpz6nMYyPFXaEsJS2b_J X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDE2OCBTYWx0ZWRfX7422l1Oz9zlQ BkCVBsxYR+hksc46rXcuzhz2Q3PbkDYjCN0V9UnXPn5Lxv1c9cxn2bcAKHNutuqISAHR8j44m3r 3917AeA159NR3QzAkt+xrqCJXlePK6q/k/61fspUE7FsdA4TCKfc6yPQNakqGmi/4CmdOT+pd2q m164Pwof6daNsbSK5oNhuotdjVlTaRdzrudagbaPLuL6sOUaYIjuVnusy02WStXFRUbPWcbjGvT DZCVnOg3whn/bEwN7J6euxa5ZJqUFRhz5M2fp6Jl0k+u9X2GdMZ1WCWBt9pTWcA/YJUv/saxA3E T3sKpYxw6GHChv0tLgJqGuWeD+w+gYz17QnqJePpuKvAxiIgfFgfB36Vf5OlrilsKeMBsWycCxQ DoCrxXhIpbKNbsdcjlWuCi+nLvS74C/4zmaOaLlGXRhs7LTf8EsY110VluDXElMcP1bE5yv/ZQN nRXzEmkJ8D9/cJtPKew== 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-05-21_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 spamscore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210168 Content-Type: text/plain; charset="utf-8" Checking fwnode_property_read_u32() return value with if (!ret) silently swallows meaningful error codes when a property is present but malformed. Use fwnode_property_present() first so that absence uses the default while a present but unreadable property returns a proper error. Signed-off-by: Liviu Stan --- Changes in v3: - Dropped the Fixes: tag - Fixed other occurrences brought up by sashiko drivers/iio/temperature/ltc2983.c | 84 +++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 26 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index 0b9e5f761bd8..10f423fbe9cc 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -669,8 +669,14 @@ ltc2983_thermocouple_new(const struct fwnode_handle *c= hild, struct ltc2983_data if (fwnode_property_read_bool(child, "adi,single-ended")) thermo->sensor_config =3D LTC2983_THERMOCOUPLE_SGL(1); =20 - ret =3D fwnode_property_read_u32(child, "adi,sensor-oc-current-microamp",= &oc_current); - if (!ret) { + if (fwnode_property_present(child, "adi,sensor-oc-current-microamp")) { + ret =3D fwnode_property_read_u32(child, + "adi,sensor-oc-current-microamp", + &oc_current); + if (ret) + return dev_err_ptr_probe(dev, ret, + "Failed to read adi,sensor-oc-current-microamp\n"); + switch (oc_current) { case 10: thermo->sensor_config |=3D @@ -760,8 +766,12 @@ ltc2983_rtd_new(const struct fwnode_handle *child, str= uct ltc2983_data *st, return dev_err_ptr_probe(dev, ret, "Property reg must be given\n"); =20 - ret =3D fwnode_property_read_u32(child, "adi,number-of-wires", &n_wires); - if (!ret) { + if (fwnode_property_present(child, "adi,number-of-wires")) { + ret =3D fwnode_property_read_u32(child, "adi,number-of-wires", &n_wires); + if (ret) + return dev_err_ptr_probe(dev, ret, + "Failed to read adi,number-of-wires\n"); + switch (n_wires) { case 2: rtd->sensor_config =3D LTC2983_RTD_N_WIRES(0); @@ -843,12 +853,13 @@ ltc2983_rtd_new(const struct fwnode_handle *child, st= ruct ltc2983_data *st, rtd->sensor.fault_handler =3D ltc2983_common_fault_handler; rtd->sensor.assign_chan =3D ltc2983_rtd_assign_chan; =20 - ret =3D fwnode_property_read_u32(child, "adi,excitation-current-microamp", - &excitation_current); - if (ret) { - /* default to 5uA */ - rtd->excitation_current =3D 1; - } else { + if (fwnode_property_present(child, "adi,excitation-current-microamp")) { + ret =3D fwnode_property_read_u32(child, "adi,excitation-current-microamp= ", + &excitation_current); + if (ret) + return dev_err_ptr_probe(dev, ret, + "Failed to read adi,excitation-current-microamp\n"); + switch (excitation_current) { case 5: rtd->excitation_current =3D 0x01; @@ -879,9 +890,17 @@ ltc2983_rtd_new(const struct fwnode_handle *child, str= uct ltc2983_data *st, "Invalid value for excitation current(%u)\n", excitation_current); } + } else { + /* default to 5uA */ + rtd->excitation_current =3D 1; } =20 - fwnode_property_read_u32(child, "adi,rtd-curve", &rtd->rtd_curve); + if (fwnode_property_present(child, "adi,rtd-curve")) { + ret =3D fwnode_property_read_u32(child, "adi,rtd-curve", &rtd->rtd_curve= ); + if (ret) + return dev_err_ptr_probe(dev, ret, + "Failed to read adi,rtd-curve\n"); + } =20 return &rtd->sensor; } @@ -951,17 +970,13 @@ ltc2983_thermistor_new(const struct fwnode_handle *ch= ild, struct ltc2983_data *s thermistor->sensor.fault_handler =3D ltc2983_common_fault_handler; thermistor->sensor.assign_chan =3D ltc2983_thermistor_assign_chan; =20 - ret =3D fwnode_property_read_u32(child, "adi,excitation-current-nanoamp", - &excitation_current); - if (ret) { - /* Auto range is not allowed for custom sensors */ - if (sensor->type >=3D LTC2983_SENSOR_THERMISTOR_STEINHART) - /* default to 1uA */ - thermistor->excitation_current =3D 0x03; - else - /* default to auto-range */ - thermistor->excitation_current =3D 0x0c; - } else { + if (fwnode_property_present(child, "adi,excitation-current-nanoamp")) { + ret =3D fwnode_property_read_u32(child, "adi,excitation-current-nanoamp", + &excitation_current); + if (ret) + return dev_err_ptr_probe(dev, ret, + "Failed to read adi,excitation-current-nanoamp\n"); + switch (excitation_current) { case 0: /* auto range */ @@ -1009,6 +1024,14 @@ ltc2983_thermistor_new(const struct fwnode_handle *c= hild, struct ltc2983_data *s "Invalid value for excitation current(%u)\n", excitation_current); } + } else { + /* Auto range is not allowed for custom sensors */ + if (sensor->type >=3D LTC2983_SENSOR_THERMISTOR_STEINHART) + /* default to 1uA */ + thermistor->excitation_current =3D 0x03; + else + /* default to auto-range */ + thermistor->excitation_current =3D 0x0c; } =20 return &thermistor->sensor; @@ -1047,9 +1070,13 @@ ltc2983_diode_new(const struct fwnode_handle *child,= const struct ltc2983_data * diode->sensor.fault_handler =3D ltc2983_common_fault_handler; diode->sensor.assign_chan =3D ltc2983_diode_assign_chan; =20 - ret =3D fwnode_property_read_u32(child, "adi,excitation-current-microamp", - &excitation_current); - if (!ret) { + if (fwnode_property_present(child, "adi,excitation-current-microamp")) { + ret =3D fwnode_property_read_u32(child, "adi,excitation-current-microamp= ", + &excitation_current); + if (ret) + return dev_err_ptr_probe(dev, ret, + "Failed to read adi,excitation-current-microamp\n"); + switch (excitation_current) { case 10: diode->excitation_current =3D 0x00; @@ -1070,7 +1097,12 @@ ltc2983_diode_new(const struct fwnode_handle *child,= const struct ltc2983_data * } } =20 - fwnode_property_read_u32(child, "adi,ideal-factor-value", &temp); + if (fwnode_property_present(child, "adi,ideal-factor-value")) { + ret =3D fwnode_property_read_u32(child, "adi,ideal-factor-value", &temp); + if (ret) + return dev_err_ptr_probe(dev, ret, + "Failed to read adi,ideal-factor-value\n"); + } =20 /* 2^20 resolution */ diode->ideal_factor_value =3D __convert_to_raw(temp, 1048576); --=20 2.43.0 From nobody Sun May 24 20:35:37 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 BFDF239D3FB; Thu, 21 May 2026 16:45:25 +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=1779381927; cv=none; b=CWPq5bfa7uSRm+6xQ1n73Xg+/NTTf1I02b6GWrJbFkDX2BphkwsD4340xmoMXYrPAfbiCYThEZ8Z2Yx67iOVRS2cK6/t/zhpCHAjGCFJsj1joCxvtPoZ2s5beEqUZ2ugHZyFYr+JNFBR6L8HEDgUFmdXp0wjb2NKu+c7OGDsN70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779381927; c=relaxed/simple; bh=/aud7HYs5g6J1//2Jp687TI6hEmDqmvPE4VwrLY6IQw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jpdu8wvjpNK5uxS5ZEZB9pGFXALSGkW3JoY25kXhySXtvUYwzuTl0Le3KwLPSsuyoU4CKI8Gy/12pEpwBysDP8VeZ4q+G6oBe+qnnjOqLHvGWn6N45cwBDklElJDZGeJQHhwZ1uUMUB1yMBCi+oFJTAYPZAORf06sPH29OHpt8o= 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=ZQyTCRWw; 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="ZQyTCRWw" 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 64LDjG2C416888; Thu, 21 May 2026 12:45:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=dVkkP aayLKw0QEgzDjqYDxGr9Rbba+VUBxSYXnv/TFY=; b=ZQyTCRWwqsVwCQmNUMEGI YSmuZ7DIDkzqGi3m2XEVj5CaMS8Oaj0sod6/Edp5djQtCY3AfSaFRPvLcssTJFcm ENGlstEznFovBpB5BiT3BepwW2CzcbrUQQFnRlAu7BhN3HpngqlGkylFWUo0fy4F 5+G+osme5CyoPntZABl23vW+MD8SusJqVzNz5SmbLCl3n4+3lKQ9Yg9GCYZ3caIx +cFgTNXDY4vGn0teKc6xefayiC5FQFam/jhIIbGLBMylSsS/eQhwG9yp3GdXOC3h UBcPryLHVNC0ZHcRTP3gVyxiuCrhc5jANp8eXUw8n46dlbwj3PYbYga52ceflKIz g== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4e9e6wwahw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 12:45:22 -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 64LGjLrG000392 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 May 2026 12:45:21 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) 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; Thu, 21 May 2026 12:45:21 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Thu, 21 May 2026 12:45:21 -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; Thu, 21 May 2026 12:45:21 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.208]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64LGim0p024538; Thu, 21 May 2026 12:45:12 -0400 From: Liviu Stan To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Michael Hennerich , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Antoniu Miclaus" , Francesco Lavra , Liviu Stan , , , , Subject: [PATCH v3 5/8] iio: temperature: ltc2983: Fix n_wires default bypassing rotation check Date: Thu, 21 May 2026 19:42:58 +0300 Message-ID: <20260521164323.770626-6-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521164323.770626-1-liviu.stan@analog.com> References: <20260521164323.770626-1-liviu.stan@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-Proofpoint-GUID: ehd8TAxDnkcxsJGYolQTDrYNLokUgU6y X-Proofpoint-ORIG-GUID: ehd8TAxDnkcxsJGYolQTDrYNLokUgU6y X-Authority-Analysis: v=2.4 cv=K8gS2SWI c=1 sm=1 tr=0 ts=6a0f36a3 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=Z0pTeXoby7EwIRygza74:22 a=gAnH3GRIAAAA:8 a=itsfFgpfY7t2nVq4jXIA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDE2OCBTYWx0ZWRfX7VXOrAGkbW+G XWPSWwa5QIQxBq4wji1v33BL2vXp/noTHwT9fvMQNSrImLNG0Mgo22hGh3VUUAk3NQAJy91zOOx djGNwiJPCkt7TMPkuGqi+wBP75PenFuxKPICFnzEDw3soVL3UsIH7gm7tSdX/x32th0lxVptWBV IaJ1VOD73POsARvSHUbstPFC68rXtwYhsatqwT+dMtOT1A9tuhCOc1AnqQHNI11SphfTt8iZfl7 ipgB3DKN/Kh389RwHAItZf/GWQPMb7UR6Yu/Hub/P9oDbDHVII6f73ohZQmdqa+U4DcaaSjfcWP KX9KU+dxvfRPAy7dmn4VXGwlE3xMff/lvYQe8hyMU1Wfe99NlA8TN8Szi6UV43Oit5AKSY00rzL 5R4gQwlytOr4bzzM0XEVasi/YdL0o5b0EOqJ/WgT62NyZAN4VjJ4JB83oj+RIMcWjfTlwbKw2GJ DiEwmMTXwxPi0Fn3J1Q== 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-05-21_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 phishscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 bulkscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210168 Content-Type: text/plain; charset="utf-8" When adi,number-of-wires is absent, n_wires is left at 0. The binding documents a default of 2 wires, matching the hardware default. However the current-rotate validation checks n_wires =3D=3D 2 || n_wires =3D=3D 3, = so with n_wires =3D 0 the guard is bypassed and adi,current-rotate is accepted for a 2-wire RTD. Initialize n_wires =3D 2 to match the binding default and ensure the rotation check fires correctly when the property is absent. Fixes: f110f3188e56 ("iio: temperature: Add support for LTC2983") Signed-off-by: Liviu Stan --- Changes in v3: - New patch drivers/iio/temperature/ltc2983.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index 10f423fbe9cc..326f843f4271 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -749,7 +749,7 @@ ltc2983_rtd_new(const struct fwnode_handle *child, stru= ct ltc2983_data *st, struct ltc2983_rtd *rtd; int ret =3D 0; struct device *dev =3D &st->spi->dev; - u32 excitation_current =3D 0, n_wires =3D 0; + u32 excitation_current =3D 0, n_wires =3D 2; =20 rtd =3D devm_kzalloc(dev, sizeof(*rtd), GFP_KERNEL); if (!rtd) --=20 2.43.0 From nobody Sun May 24 20:35:37 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 C11713B9DBF; Thu, 21 May 2026 16:45:27 +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=1779381929; cv=none; b=TtJcSMqrimAHg0nFdBXelz3fAYtdMqs7oXm8SoDocOfIVU/NFqndNCOVWEOTzJo+D6ECA2mdoHyB9hkDxsIrp27qF/gSkYAugiHxzXRAsDe0Op8C8QUqg5QTddjJDrE8lUBepw4a9ADYv0riVyMt8rU+TaS+jiWhi7XoLzW2B3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779381929; c=relaxed/simple; bh=pbw2XJiYNz9oNPHtRcciA2fM34IwD6GMPr8PS3ENjIw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RTbLeBJeOe7A11l4wsTN5FezoKW6coUg3WeJxSIgrpZMtEdk5IGVeAUm5iZchEP4URKqybgiEW6U7giczlc16wGbbjVaazctHQiKi/myxSA+YnQTPP6S56gki8UmCn1o11vC9cd9bNCb8lWU0LWHkse20ZpvWEw/IJePwVDClTE= 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=Hc2UYzCX; 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="Hc2UYzCX" Received: from pps.filterd (m0516787.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64LFGskK602695; Thu, 21 May 2026 12:45:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=CjvNJ wFrBzeUl2tZT4JHFxdtvmajDIm1C3As6XqkDdQ=; b=Hc2UYzCXf61rIISehj5zW xQ1mBOGtJxlzqBiYRMQ95zmfhXUKBuNMDKQUlwtIlgVHjQ1bYoZLwp8+qlVF9nAh KOF6tiGo7KmWzLDGQj7wBTKjZVclhWhmDkuJOfzgW8l3rr9g4fnNa5FhK5L6IyrU 9A19BDNFZs2rL2cBTaNo/oGQ4SntmObh7Kv5UOkajgn5aClkneSA2e6u+1ykVq4C ndXDdRn+2pnJokopFRxYW/LvLXuCwwPss/TA6WKQWy7cikazevSoiIxaB+kXBR8K dC9HsM1DIitpep9HSdFzUnFIQlpnr3fzWCAhNhxCSZomBxjLxMz24YlrN4QdN/0e w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4e96sry1ea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 12:45:25 -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 64LGjOin000401 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 May 2026 12:45:24 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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; Thu, 21 May 2026 12:45:23 -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; Thu, 21 May 2026 12:45:23 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.208]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64LGim0q024538; Thu, 21 May 2026 12:45:16 -0400 From: Liviu Stan To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Antoniu Miclaus , Francesco Lavra , Liviu Stan , , , , Subject: [PATCH v3 6/8] iio: core: Add IIO_COVERAGE channel type Date: Thu, 21 May 2026 19:42:59 +0300 Message-ID: <20260521164323.770626-7-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521164323.770626-1-liviu.stan@analog.com> References: <20260521164323.770626-1-liviu.stan@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-Proofpoint-ORIG-GUID: hBOLzu9x37xlbQzvRrPqgGOhR7aXld2H X-Proofpoint-GUID: hBOLzu9x37xlbQzvRrPqgGOhR7aXld2H X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDE2OCBTYWx0ZWRfX0+tOKx6akdFc isXArukXZn41HX/J4E668qz0gPzbMVm5ojzegKbdm4cEHI/Qazn06xCtsQ8XSlPQvsyV3KdL4v/ NspzjTYoV/UlcvIyTGxtfaSKPXO9w2gkE8k1cafDHtbNbuaDwOnw3k2XpGjT+ln0x+Pwz2A2J3R ILbbEMR6Br8NIyzIL93RjbheXATca8UssH7X7QO60YwxSjb5b+IpIE7UkerHk+wgkV3NI9QGVnG 8ZW/jZgDMpoxzSV3HS2lxHeBpP3kigeuom+n5dHpncU9Y5iHd1TuNmJD+eS1lA6TI8nOceUQsth VwK4Ldodss+7PvhWdSpuA/9D3BYZPMS4AktzX2LgCF4widjHsnf1wuseTdyX/wYNvBtpxEvgMS0 K3Ix4wP1jcbVBIIrPPNz7pPDT0tqNN60Xg14Xl2tYtqfyDOkrdw+2zlOHXrRwFHUI5hOFklurpl BU0ZzgQEiXojUOb859g== X-Authority-Analysis: v=2.4 cv=CZs4Irrl c=1 sm=1 tr=0 ts=6a0f36a5 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=OmVn7CZJonkx5R5zMQLL:22 a=gAnH3GRIAAAA:8 a=VwQbUJbxAAAA:8 a=9xQ6YJnTFPUVikIS7p4A:9 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-05-21_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 impostorscore=0 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210168 Content-Type: text/plain; charset="utf-8" Add a new channel type for sensors that report fractional coverage as a percentage. The sysfs attribute is in_coverageX_raw; after applying in_coverageX_scale the value is in percent. The first user is the ADT7604 leak detector, where the value represents the portion of the sensing element that is wetted. Signed-off-by: Liviu Stan --- Changes in v3: - Renamed the sysfs attribute from in_coveragepercentX_raw to in_coverageX_raw - Added a _scale ABI documentation entry - Corrected KernelVersion in the ABI documentation from 6.15 to 7.2 - Added IIO_COVERAGE to the event_is_known() switch in tools/iio/iio_event_monitor.c Documentation/ABI/testing/sysfs-bus-iio | 17 +++++++++++++++++ drivers/iio/industrialio-core.c | 1 + include/uapi/linux/iio/types.h | 1 + tools/iio/iio_event_monitor.c | 2 ++ 4 files changed, 21 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/te= sting/sysfs-bus-iio index 925a33fd309a..ca20ad5860dc 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1980,6 +1980,23 @@ Description: Raw (unscaled no offset etc.) resistance reading. Units after application of scale and offset are ohms. =20 +What: /sys/bus/iio/devices/iio:deviceX/in_coverageX_raw +KernelVersion: 7.2 +Contact: linux-iio@vger.kernel.org +Description: + Raw (unscaled no offset etc.) coverage reading. Used for sensors + that report fractional coverage as a percentage, such as leak + detectors where the value represents what portion of the sensing + element is wetted. Units after application of scale and offset are + percent. + +What: /sys/bus/iio/devices/iio:deviceX/in_coverageX_scale +KernelVersion: 7.2 +Contact: linux-iio@vger.kernel.org +Description: + Scale to be applied to in_coverageX_raw to obtain coverage + in percent. + What: /sys/bus/iio/devices/iio:deviceX/heater_enable KernelVersion: 4.1.0 Contact: linux-iio@vger.kernel.org diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-cor= e.c index bd6f4f9f4533..ffe0dc49c4b9 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -98,6 +98,7 @@ static const char * const iio_chan_type_name_spec[] =3D { [IIO_CHROMATICITY] =3D "chromaticity", [IIO_ATTENTION] =3D "attention", [IIO_ALTCURRENT] =3D "altcurrent", + [IIO_COVERAGE] =3D "coverage", }; =20 static const char * const iio_modifier_names[] =3D { diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h index d7c2bb223651..c9295c707041 100644 --- a/include/uapi/linux/iio/types.h +++ b/include/uapi/linux/iio/types.h @@ -53,6 +53,7 @@ enum iio_chan_type { IIO_CHROMATICITY, IIO_ATTENTION, IIO_ALTCURRENT, + IIO_COVERAGE, }; =20 enum iio_modifier { diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index df6c43d7738d..bc3ef4c77c2b 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -65,6 +65,7 @@ static const char * const iio_chan_type_name_spec[] =3D { [IIO_CHROMATICITY] =3D "chromaticity", [IIO_ATTENTION] =3D "attention", [IIO_ALTCURRENT] =3D "altcurrent", + [IIO_COVERAGE] =3D "coverage", }; =20 static const char * const iio_ev_type_text[] =3D { @@ -194,6 +195,7 @@ static bool event_is_known(struct iio_event_data *event) case IIO_CHROMATICITY: case IIO_ATTENTION: case IIO_ALTCURRENT: + case IIO_COVERAGE: break; default: return false; --=20 2.43.0 From nobody Sun May 24 20:35:37 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 3EF7D3C81B7; Thu, 21 May 2026 16:45:31 +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=1779381932; cv=none; b=bLXshUwGTM0X/GcOjiForcP5hkuZBXeRndK0uJ2eheQKRdUNRXXFDTCyoHctRlyB0ww82J+HgT2R3apz+kE/NMoLxm6/Flxf6rfRvnaKIquG5d+J8+FW18ExYi1Vtegv6cAIKZTTPs6c30nTNAJOCuqBLWpei27I2FLwC/bO1Ec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779381932; c=relaxed/simple; bh=sSdxgZR5BJKGj2mDWMjS5ITgCh5y3HwF3Xy5jRXCmvQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A/WBH9aSv3edKmnBdX9y3VhdY/Zhr9NKzo42krGq8OD5Le5z4erqngPSrsZDqLksTJH91jeypweVVRUFJwDt7dLTMj2ENlbXXZy1Frc6nz5JK+TrwNc8U7QSJP0LxNfcToEbvQhIAN+GnRZYQPZU6apbsbV3yy9VERFwU290pks= 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=yIJcICUG; 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="yIJcICUG" Received: from pps.filterd (m0516787.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64LFgYeF602532; Thu, 21 May 2026 12:45:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=VYj8z vPlf6NWOUubBRpWEGVhI/lxdXlGXS+JKG7AJfM=; b=yIJcICUG0I0Bz/7CCmOn2 AR1/zW52xZaz/14xIFPGpMmNmTAcKiFeNkiz645SIjLPLom3cnWafGc+6oQb1LA5 vXhg2+pN23s6TyEKryQaJizxxk2ER9sbfLz0sPsO0iA2X2iVHJzlQ9AbGzcmX+za w0vySkPBzFlF9Bm6ZOr2oqN117RptZ9iuwXzPpjp6dIVdI+/KrsWeFz4bJSVUxcj LwIeVtaR2/9X0FEh8uIH4ctum321qFXqNbmwaS0uGewdtZ2rdI3wQkXUBmSiaBzD 1cFEALnxNWNYVVs/xMJ5RbKdrlJGJlZgtwZk0GR7spW4Pb6ZWzqGRYjmhLIBet1V A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4e96sry1ek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 12:45:28 -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 64LGjRXI000413 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 May 2026 12:45:27 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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; Thu, 21 May 2026 12:45:27 -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; Thu, 21 May 2026 12:45:27 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.208]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64LGim0r024538; Thu, 21 May 2026 12:45:20 -0400 From: Liviu Stan To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Antoniu Miclaus , Liviu Stan , Francesco Lavra , , , , Subject: [PATCH v3 7/8] dt-bindings: iio: temperature: Add ADT7604 support to adi,ltc2983 Date: Thu, 21 May 2026 19:43:00 +0300 Message-ID: <20260521164323.770626-8-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521164323.770626-1-liviu.stan@analog.com> References: <20260521164323.770626-1-liviu.stan@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-ORIG-GUID: A9IxZtR7tD1iKPiQ4TiSkKUNZhA_H8bH X-Proofpoint-GUID: A9IxZtR7tD1iKPiQ4TiSkKUNZhA_H8bH X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDE2OCBTYWx0ZWRfX4EGfnDfrJGOO bm96FYvMKtxNLlmGbqYB9yaEUmzcEAmK93i7AwTokv3I86jBI30LXmtnskLgco0rRmkCCdQEXfA VZL2TFfT9bi025GWFlKRcXKAW5IHv2mIfLGheZZlmOONywMfFyGWg8/Z7eUcwq7UUndPnzJv1MW 1LfheDK28ffa0ch/rlPWIXd/6R8Xpdcpqj7OqgHaiwbuJlZVgoMO2mzA3t9SnTjLxt/FNZHLvmJ w5pBrLuQau5CC3cC4IaAlfUHRrDXHofqQSLVYMjwOJs8COyOhXC80OwFZZcC4jlfQCxoiVGC+Ji KFwOIZh+JFX1QLs3uv77Th6MVckJFf6ux9BC8zGVrrZmLRY4IA9g+FTeC54I1EWUmyxq3vOOtGt jBvuptKn6S8or/BFJ6VSG+xCHWq/KdRmmswRtl2cjGHARBe0qvUrWNMoKwkldXGfa5aVDwxUtnl 4Viji2otxqI4h7g+lYw== X-Authority-Analysis: v=2.4 cv=CZs4Irrl c=1 sm=1 tr=0 ts=6a0f36a8 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=OmVn7CZJonkx5R5zMQLL:22 a=gEfo2CItAAAA:8 a=gAnH3GRIAAAA:8 a=0NoqbZV6EB-ln6Q-UgwA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=sptkURWiP4Gy88Gu7hUp:22 a=t30qsMHlJzOsgWiHt2r7:22 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-05-21_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 impostorscore=0 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210168 The ADT7604 shares the same die as the LTC2984. It repurposes the custom RTD sensor type (18) as a copper trace resistance sensor and the custom thermistor type (27) as a leak detector, and removes thermocouple, diode and direct ADC sensor types. Add adi,adt7604 to the compatible list and introduce two new sensor node types specific to this device: - copper-trace@: maps to the custom RTD sensor type (18). Two variants: sub-ohm (< 1 ohm, adi,copper-trace-sub-ohm boolean, no custom table and excitation current) and standard (> 1 ohm, required adi,custom-copper-trace table, optional excitation current defaulting to the datasheet recommended value). Primary output is resistance in ohms. For > 1 ohm copper traces with a custom table, the chip also outputs temperature in millidegrees Celsius. - leak-detector@: maps to the custom thermistor sensor type (27). Takes a required adi,custom-leak-detector lookup table encoding resistance (uOhm) against coverage data (%). Two outputs: resistance in ohms and coverage in percent. Separate node types are used rather than extending the existing rtd@ and thermistor@ nodes because adi,custom-rtd is required for sensor type 18, and several properties (adi,number-of-wires, adi,rtd-curve, adi,rsense-share, adi,single-ended, adi,current-rotate) have no meaning for the new sensor types, since the configuration is hardcoded, and would need to be explicitly forbidden or ignored in the driver. allOf conditions are added to restrict thermocouple, diode, direct ADC and active temperature nodes to non-ADT7604 devices, and to restrict copper-trace and leak-detector nodes to the ADT7604 (some parts only). Signed-off-by: Liviu Stan --- Changes in v3: - Changed the custom leak detector table encoding, users now specify plain coverage percentage values (0-100) in the device tree and the driver applies the +273.15 C offset internally before writing the hardware table - Changed custom-rtd to custom-copper-trace to better represent the copper trace custom table, and made it required for > 1 ohm variants - Made custom-leak-detector required for leak detector sensors - Updated commit message to reflect the changes - Updated leak detector node description - Updated adi,custom-leak-detector description - Modified the example leak detector custom table to match the datasheet .../bindings/iio/temperature/adi,ltc2983.yaml | 207 +++++++++++++++++- 1 file changed, 204 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.= yaml b/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml index a22725f7619b..14cfa28809ed 100644 --- a/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml +++ b/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml @@ -4,14 +4,18 @@ $id: http://devicetree.org/schemas/iio/temperature/adi,ltc2983.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# =20 -title: Analog Devices LTC2983, LTC2986, LTM2985 Multi-sensor Temperature s= ystem +title: Analog Devices LTC2983 and similar Multi-sensor Temperature systems =20 maintainers: - Nuno S=C3=A1 =20 description: | - Analog Devices LTC2983, LTC2984, LTC2986, LTM2985 Multi-Sensor Digital - Temperature Measurement Systems + Analog Devices Multi-Sensor Digital Temperature Measurement Systems: + - ADT7604 + - LTC2983 + - LTC2984 + - LTC2986 + - LTM2985 =20 https://www.analog.com/media/en/technical-documentation/data-sheets/2983= fc.pdf https://www.analog.com/media/en/technical-documentation/data-sheets/2984= fb.pdf @@ -43,6 +47,7 @@ properties: compatible: oneOf: - enum: + - adi,adt7604 - adi,ltc2983 - adi,ltc2986 - adi,ltm2985 @@ -436,6 +441,121 @@ patternProperties: required: - adi,custom-temp =20 + '^copper-trace@': + $ref: '#/$defs/sensor-node' + unevaluatedProperties: false + description: | + Copper trace resistance sensor (some parts only). Two variants exist: + sub-ohm (< 1 ohm, no custom table allowed) and standard (> 1 ohm, + required custom table). + + properties: + reg: + minimum: 2 + maximum: 20 + + adi,sensor-type: + description: Sensor type for copper trace sensors. + $ref: /schemas/types.yaml#/definitions/uint32 + const: 32 + + adi,rsense-handle: + description: Associated sense resistor sensor. + $ref: /schemas/types.yaml#/definitions/phandle + + adi,copper-trace-sub-ohm: + description: + Select the sub-ohm (< 1 ohm) copper trace variant. Custom table + and excitation current are not allowed in this mode. + type: boolean + + adi,excitation-current-microamp: + description: + Excitation current applied to the copper trace. Not used in + sub-ohm mode. The datasheet recommends 1mA for copper trace + sensors due to their typically small resistance. + enum: [5, 10, 25, 50, 100, 250, 500, 1000] + default: 1000 + + adi,custom-copper-trace: + description: + Resistance-to-temperature table for copper trace sensors with + resistance > 1 ohm. Required when adi,copper-trace-sub-ohm is not + set. See Page 36 of the datasheet. + $ref: /schemas/types.yaml#/definitions/uint64-matrix + minItems: 3 + maxItems: 64 + items: + items: + - description: Resistance point in uOhms. + - description: Temperature point in uK. + + required: + - adi,rsense-handle + + allOf: + - if: + required: + - adi,copper-trace-sub-ohm + then: + properties: + adi,custom-copper-trace: false + adi,excitation-current-microamp: false + - if: + not: + required: + - adi,copper-trace-sub-ohm + then: + required: + - adi,custom-copper-trace + + '^leak-detector@': + $ref: '#/$defs/sensor-node' + unevaluatedProperties: false + description: | + Leak detector sensor (some parts only). Outputs resistance in ohms a= nd + a coverage percentage via IIO_COVERAGE (raw/1024 =3D coverage %). + + properties: + reg: + minimum: 2 + maximum: 20 + + adi,sensor-type: + description: Sensor type for leak detector sensors. + $ref: /schemas/types.yaml#/definitions/uint32 + const: 33 + + adi,rsense-handle: + description: Associated sense resistor sensor. + $ref: /schemas/types.yaml#/definitions/phandle + + adi,excitation-current-nanoamp: + description: + Excitation current applied to the leak detector. The correct val= ue + depends on the electrical characteristics of the liquid being se= nsed. + For example, 10000 (10=C2=B5A) is recommended for PG25 (see data= sheet + Table 39). + enum: [250, 500, 1000, 5000, 10000, 25000, 50000, 100000, 250000, + 500000, 1000000] + + adi,custom-leak-detector: + description: | + Lookup table mapping resistance to coverage percentage. Entries = must + be in ascending resistance order. + $ref: /schemas/types.yaml#/definitions/uint64-matrix + minItems: 3 + maxItems: 64 + items: + items: + - description: Resistance point in uOhms. + - description: Coverage data percentage (0 to 100). + + required: + - adi,rsense-handle + - adi,excitation-current-nanoamp + - adi,custom-leak-detector + '^rsense@': $ref: '#/$defs/sensor-node' unevaluatedProperties: false @@ -477,6 +597,22 @@ allOf: patternProperties: '^temp@': false =20 + - if: + properties: + compatible: + contains: + const: adi,adt7604 + then: + patternProperties: + '^thermocouple@': false + '^diode@': false + '^adc@': false + '^temp@': false + else: + patternProperties: + '^copper-trace@': false + '^leak-detector@': false + examples: - | #include @@ -556,4 +692,69 @@ examples: }; }; }; + + - | + #include + spi { + #address-cells =3D <1>; + #size-cells =3D <0>; + + temperature-sensor@0 { + compatible =3D "adi,adt7604"; + reg =3D <0>; + interrupt-parent =3D <&gpio>; + interrupts =3D <25 IRQ_TYPE_EDGE_RISING>; + + #address-cells =3D <1>; + #size-cells =3D <0>; + vdd-supply =3D <&supply>; + + trace_rsense: rsense@2 { + reg =3D <2>; + adi,sensor-type =3D <29>; + adi,rsense-val-milli-ohms =3D <100000>; // 100 ohm + }; + + copper-trace@4 { + reg =3D <4>; + adi,sensor-type =3D <32>; + adi,rsense-handle =3D <&trace_rsense>; + adi,copper-trace-sub-ohm; + }; + + r_sense: rsense@12 { + reg =3D <12>; + adi,sensor-type =3D <29>; + adi,rsense-val-milli-ohms =3D <1000000>; // 1 kohm + }; + + leak-detector@14 { + reg =3D <14>; + adi,sensor-type =3D <33>; + adi,rsense-handle =3D <&r_sense>; + adi,excitation-current-nanoamp =3D <10000>; + adi,custom-leak-detector =3D + /bits/ 64 < 0 100>, + /bits/ 64 < 202020000 99>, + /bits/ 64 < 285710000 70>, + /bits/ 64 < 333330000 60>, + /bits/ 64 < 400000000 50>, + /bits/ 64 < 500000000 40>, + /bits/ 64 < 666670000 30>, + /bits/ 64 < 1000000000 20>, + /bits/ 64 < 2000000000 10>, + /bits/ 64 <1000000000000 0>; + }; + + rtd@18 { + reg =3D <18>; + adi,sensor-type =3D <12>; // PT100 + adi,rsense-handle =3D <&r_sense>; + adi,number-of-wires =3D <2>; + adi,rsense-share; + adi,excitation-current-microamp =3D <500>; + adi,rtd-curve =3D <0>; + }; + }; + }; ... --=20 2.43.0 From nobody Sun May 24 20:35:37 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 04E91385535; Thu, 21 May 2026 16:45:35 +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=1779381938; cv=none; b=COMRXyeoZ5eYDgkrcMjRrOi6KFYGPTOapPXAZ5pZFJNHHKgXA8ADO08Z0L0Vnjf1ME+QIftlRMW/cj8CushPXPN49/6jzngf9G6hxp3x10Bqcf0N2ri6u4Df88bmboPfgdGhafYOWutJx+sZc3jsGNeNW+dtquippGBDG0OBF9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779381938; c=relaxed/simple; bh=42OC1Xa9MGIsajSY3C/7o/ptKyJohx7pCvJk/4hFBD8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EkJBMrTikwRDrh+yrzEHCvWZwm1CPeLgEqemAubngggwi1UlGY6rVJxiu66OVcRlTKlShCPzJMHpAgVi6GSZovrXcS8lBfnQKYTIUNnB4ZHtrLML8/gj2se5ZSw/yNpAbbJM4m9RL8+G5BLmbxK/epbyb38bqcIRK1IUwzo1ZNY= 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=EiruO+3m; 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="EiruO+3m" 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 64LDqFpa416979; Thu, 21 May 2026 12:45:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=4Wxxd 35DS7OslAxwdJCDYtaSy+CtvU3LAMJRpQrxjBU=; b=EiruO+3mpZkxYMUKJZhLH jAmjfFdJGfyRLGuzirMYK86bwWdTqTa9fLnb4Vw2cbTIPofn8rdSb4uSAwy96TYz 23tfnu93jiuMBmeOL9QKWSgMP9r9Hh9eHmSZKodIS/lPa4RbQBBqy8PhK2u+Nsm9 qZgT2qojmUI8zCzlX6zGKrYpvcvbwD4VTnteV1NP3vx9xIY7FVz/+o034SPElih/ 6EwZYdo8qVAxtxB2iN3PuznKPfMzQW60uqBiVq4eQswG0fnnfLPV+bXSwrf4YgIX MqvB4ZAHWYjDwMLg/LW5bA38jr9x00bLiqcCE8/93fMkgA7mpIR7CKvfBq6HtV0+ w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4e9e6wwajf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 12:45:32 -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 64LGjVn3000425 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 May 2026 12:45:31 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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; Thu, 21 May 2026 12:45:31 -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; Thu, 21 May 2026 12:45:31 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.208]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64LGim0s024538; Thu, 21 May 2026 12:45:24 -0400 From: Liviu Stan To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Antoniu Miclaus , Francesco Lavra , Liviu Stan , , , , Subject: [PATCH v3 8/8] iio: temperature: ltc2983: Add support for ADT7604 Date: Thu, 21 May 2026 19:43:01 +0300 Message-ID: <20260521164323.770626-9-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521164323.770626-1-liviu.stan@analog.com> References: <20260521164323.770626-1-liviu.stan@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: DhBcsCscVXI8FV1lDkFUNtzzjyRu94K6 X-Proofpoint-ORIG-GUID: DhBcsCscVXI8FV1lDkFUNtzzjyRu94K6 X-Authority-Analysis: v=2.4 cv=K8gS2SWI c=1 sm=1 tr=0 ts=6a0f36ac cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=Z0pTeXoby7EwIRygza74:22 a=gAnH3GRIAAAA:8 a=TlbCvaWkEPsthiUEuOIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDE2OCBTYWx0ZWRfXzoKQrg2y8/a3 hdXCvqSTXjEpiMCHUxZIQk0xzXqzFe0naXHJATrItjklhQbusCTp7Z6iNtXcmjZjpO5d/AR4+OY sXjw0FDbLt1To7yo25r1pl+dvXX5rFF4YdpDxLrNRW7u4543RhRoICeG3xKyknTC5ZCuCLwKh5+ CwqNkXB1Kba249k1twpWNsYGcRMnwUJYi9A7ZP22UohNhuiuYO4ICnKtvqMQQwfW4DMeipisLk4 UegqxXz04J5duUhT+e+D3BKxxm0xrI+uIDwLuzFifAHJmAxl2M2FxTIO9p68H+KeG1G2FFJDPb3 YvZnnn9V+NiPZPaVVv2OFAlSd18HX4ekiHT7TmXjF+mB1sDgyjC9SWBQwgaaOrpeVslS40KBWKv 3NbNFUF7AWyLOXaIDisAn6OrsXtEgi0FTtlH0196JV9ER+2o07ct2edOvrZh/rZ8OwKubKUoofv lh7lXMQKzZ4a/klLh6w== 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-05-21_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 phishscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 bulkscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210168 The ADT7604 shares the same die as the LTC2984. It repurposes the custom RTD sensor type (18) as a copper trace resistance sensor and the custom thermistor type (27) as a leak detector, and removes thermocouple, diode and direct ADC sensor types. Two new software sensor type values are introduced (LTC2983_SENSOR_COPPER_TRACE =3D 32, LTC2983_SENSOR_LEAK_DETECTOR =3D 33) that map to the hardware register values 18 and 27 respectively. Dedicated structs (ltc2983_copper_trace, ltc2983_leak_detector) and parser functions are added rather than extending the existing RTD and thermistor paths, as the hardware configuration bits are fully hardcoded and several RTD/thermistor properties would need to be explicitly forbidden or ignored. Custom RTD (type 18) becomes the copper trace sensor. Sensor configuration bits are hardcoded to 0b1001 per the datasheet. Two variants are supported via the adi,copper-trace-sub-ohm DT property: sub-ohm traces (< 1 ohm) have bits 17:0 cleared with no excitation current or custom table; standard traces (> 1 ohm) have a required resistance-to-temperature table. Custom thermistor (type 27) becomes the leak detector. Sensor configuration bits are hardcoded to 0b001. The custom table uses a resolution of 16 instead of 64, and is specified via the required adi,custom-leak-detector DT property. Both sensor types expose an IIO_RESISTANCE channel reading from the resistance result register bank (0x0060-0x00AF). Added a "base" parameter to the LTC2983_RESULT_ADDR macro and a "base_reg" parameter to the ltc2983_chan_read function so we can read from both result register banks. The resistance register encodes the measured resistance with 10 fractional bits, so dividing by 1024 gives ohms. Since the sense resistor is specified in ohms, the output is in ohms for both sensor types and a single 1/1024 scale applies to both. For > 1 ohm copper traces and for leak detectors, a secondary channel also appears: IIO_TEMP (millidegrees Celsius) for copper trace and IIO_COVERAGE (percent) for leak detector. The ltc2983_chip_info struct is extended with a u64 supported_sensors bitmask using BIT_ULL() to safely represent the new sensor type bits 32 and 33 on 32-bit builds. A LTC2983_SENSOR_NUM sentinel is added to the enum so that the bounds check uses >=3D LTC2983_SENSOR_NUM rather than hardcoding the last sensor type. Tested on EVAL-ADT7604-AZ connected to Raspberry Pi 5 via SPI. Signed-off-by: Liviu Stan --- Changes in v3: - Relocated the "base" parameter addition from patch 1 to this one since the resistance result memory region is (currently) ADT7604-specific - Updated the commit message to mention the base and base_reg parameters added to the result-bank read helpers - Stacked the IIO_RESISTANCE and IIO_COVERAGE case labels in ltc2983_read_raw() - Added LTC2983_SENSOR_NUM sentinel at the end of the sensor-type enum - Changed the sensor-type bounds check from > LTC2983_SENSOR_LEAK_DETECTOR to >=3D LTC2983_SENSOR_NUM - Reordered the ltm2985_chip_info_data struct initializer so has_eeprom doesn't look like it was added to the ltm2985 in the diff - Changed the custom leak detector table encoding, users now specify plain coverage percentage values (0-100) in the device tree and the driver applies the +273.15 C offset internally before writing the hardware table - Changed custom-rtd to custom-copper-trace to better represent the copper trace custom table, and made it required for > 1 ohm variants - Made custom-leak-detector required for leak detector sensors, _new and _assign_chan functions were updated for both sensor types - Updated commit message to reflect the changes - Removed "..." from "rsense channel must be configured" error message from ltc2983_leak_detector_new() - Removed blank line before hw_type declaration in __ltc2983_chan_assign_common drivers/iio/temperature/ltc2983.c | 413 ++++++++++++++++++++++++++++-- 1 file changed, 394 insertions(+), 19 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index 326f843f4271..e2ffeee026ee 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -28,6 +28,8 @@ #define LTC2983_STATUS_REG 0x0000 #define LTC2983_TEMP_RES_START_REG 0x0010 #define LTC2983_TEMP_RES_END_REG 0x005F +#define ADT7604_RES_RES_START_REG 0x0060 +#define ADT7604_RES_RES_END_REG 0x00AF #define LTC2983_EEPROM_KEY_REG 0x00B0 #define LTC2983_EEPROM_READ_STATUS_REG 0x00D0 #define LTC2983_GLOBAL_CONFIG_REG 0x00F0 @@ -58,8 +60,8 @@ =20 #define LTC2983_CHAN_ASSIGN_ADDR(chan) \ ((((chan) - 1) * 4) + LTC2983_CHAN_ASSIGN_START_REG) -#define LTC2983_RESULT_ADDR(chan) \ - ((((chan) - 1) * 4) + LTC2983_TEMP_RES_START_REG) +#define LTC2983_RESULT_ADDR(chan, base) \ + ((((chan) - 1) * 4) + (base)) #define LTC2983_THERMOCOUPLE_DIFF_MASK BIT(3) #define LTC2983_THERMOCOUPLE_SGL(x) \ FIELD_PREP(LTC2983_THERMOCOUPLE_DIFF_MASK, x) @@ -186,17 +188,44 @@ enum { LTC2983_SENSOR_SENSE_RESISTOR =3D 29, LTC2983_SENSOR_DIRECT_ADC =3D 30, LTC2983_SENSOR_ACTIVE_TEMP =3D 31, + /* Sensor types for some parts only; map to RTD_CUSTOM/THERMISTOR_CUSTOM = in HW */ + LTC2983_SENSOR_COPPER_TRACE =3D 32, + LTC2983_SENSOR_LEAK_DETECTOR =3D 33, + LTC2983_SENSOR_NUM, }; =20 +/* Bitmask of sensor types supported by LTC2983/LTC2984 and derivatives */ +#define LTC2983_COMMON_SENSORS \ + (GENMASK_ULL(LTC2983_SENSOR_THERMOCOUPLE_CUSTOM, LTC2983_SENSOR_THERMOCOU= PLE) | \ + GENMASK_ULL(LTC2983_SENSOR_RTD_CUSTOM, LTC2983_SENSOR_RTD) | \ + GENMASK_ULL(LTC2983_SENSOR_THERMISTOR_CUSTOM, LTC2983_SENSOR_THERMISTOR)= | \ + BIT_ULL(LTC2983_SENSOR_DIODE) | \ + BIT_ULL(LTC2983_SENSOR_SENSE_RESISTOR) | \ + BIT_ULL(LTC2983_SENSOR_DIRECT_ADC)) + +/* Bitmask of sensor types supported by ADT7604 */ +#define ADT7604_SENSORS \ + (GENMASK_ULL(LTC2983_SENSOR_RTD_CUSTOM - 1, LTC2983_SENSOR_RTD) | \ + GENMASK_ULL(LTC2983_SENSOR_THERMISTOR_CUSTOM - 1, LTC2983_SENSOR_THERMIS= TOR) | \ + BIT_ULL(LTC2983_SENSOR_SENSE_RESISTOR) | \ + BIT_ULL(LTC2983_SENSOR_COPPER_TRACE) | \ + BIT_ULL(LTC2983_SENSOR_LEAK_DETECTOR)) + #define to_thermocouple(_sensor) \ container_of(_sensor, struct ltc2983_thermocouple, sensor) =20 #define to_rtd(_sensor) \ container_of(_sensor, struct ltc2983_rtd, sensor) =20 +#define to_copper_trace(_sensor) \ + container_of(_sensor, struct ltc2983_copper_trace, sensor) + #define to_thermistor(_sensor) \ container_of(_sensor, struct ltc2983_thermistor, sensor) =20 +#define to_leak_detector(_sensor) \ + container_of(_sensor, struct ltc2983_leak_detector, sensor) + #define to_diode(_sensor) \ container_of(_sensor, struct ltc2983_diode, sensor) =20 @@ -212,7 +241,7 @@ enum { struct ltc2983_chip_info { const char *name; unsigned int max_channels_nr; - bool has_temp; + u64 supported_sensors; bool has_eeprom; }; =20 @@ -247,6 +276,8 @@ struct ltc2983_sensor { u32 chan; /* sensor type */ u32 type; + /* number of IIO channels this sensor produces */ + u8 n_iio_chan; }; =20 struct ltc2983_custom_sensor { @@ -274,6 +305,25 @@ struct ltc2983_rtd { u32 rtd_curve; }; =20 +struct ltc2983_copper_trace { + struct ltc2983_sensor sensor; + struct ltc2983_custom_sensor *custom; + u32 r_sense_chan; + u32 excitation_current; + /* selects the <1=CE=A9 variant: bits 17:0 of the channel word are zeroed, + * disabling excitation current and custom table fields (ADT7604 + * datasheet Table 26) + */ + bool is_sub_ohm; +}; + +struct ltc2983_leak_detector { + struct ltc2983_sensor sensor; + struct ltc2983_custom_sensor *custom; + u32 r_sense_chan; + u32 excitation_current; +}; + struct ltc2983_thermistor { struct ltc2983_sensor sensor; struct ltc2983_custom_sensor *custom; @@ -353,8 +403,14 @@ static int __ltc2983_chan_assign_common(struct ltc2983= _data *st, { struct device *dev =3D &st->spi->dev; u32 reg =3D LTC2983_CHAN_ASSIGN_ADDR(sensor->chan); + u32 hw_type =3D sensor->type; =20 - chan_val |=3D LTC2983_CHAN_TYPE(sensor->type); + if (hw_type =3D=3D LTC2983_SENSOR_COPPER_TRACE) + hw_type =3D LTC2983_SENSOR_RTD_CUSTOM; + else if (hw_type =3D=3D LTC2983_SENSOR_LEAK_DETECTOR) + hw_type =3D LTC2983_SENSOR_THERMISTOR_CUSTOM; + + chan_val |=3D LTC2983_CHAN_TYPE(hw_type); dev_dbg(dev, "Assign reg:0x%04X, val:0x%08X\n", reg, chan_val); st->chan_val =3D cpu_to_be32(chan_val); @@ -486,6 +542,14 @@ __ltc2983_custom_sensor_new(struct ltc2983_data *st, c= onst struct fwnode_handle for (index =3D 0; index < n_entries; index++) { u64 temp =3D ((u64 *)new_custom->table)[index]; =20 + /* + * Users specify plain coverage percentage (0-100). Convert + * to =C2=B5K so __convert_to_raw() produces the correct hardware + * encoding: P + 273.15 K. + */ + if ((index % 2) !=3D 0 && !strcmp(propname, "adi,custom-leak-detector")) + temp =3D temp * 1000000 + 273150000; + if ((index % 2) !=3D 0) temp =3D __convert_to_raw(temp, 1024); else if (has_signed && (s64)temp < 0) @@ -579,6 +643,31 @@ static int ltc2983_rtd_assign_chan(struct ltc2983_data= *st, return __ltc2983_chan_assign_common(st, sensor, chan_val); } =20 +static int ltc2983_copper_trace_assign_chan(struct ltc2983_data *st, + const struct ltc2983_sensor *sensor) +{ + struct ltc2983_copper_trace *ct =3D to_copper_trace(sensor); + u32 chan_val; + + chan_val =3D LTC2983_CHAN_ASSIGN(ct->r_sense_chan); + /* Sensor config bits 21:18 must be 0b1001 (ADT7604 datasheet Table 26) */ + chan_val |=3D LTC2983_RTD_CFG(0x9); + + if (ct->is_sub_ohm) { + chan_val &=3D ~GENMASK(17, 0); + } else { + int ret; + + chan_val |=3D LTC2983_RTD_EXC_CURRENT(ct->excitation_current); + ret =3D __ltc2983_chan_custom_sensor_assign(st, ct->custom, + &chan_val); + if (ret) + return ret; + } + + return __ltc2983_chan_assign_common(st, sensor, chan_val); +} + static int ltc2983_thermistor_assign_chan(struct ltc2983_data *st, const struct ltc2983_sensor *sensor) { @@ -602,6 +691,25 @@ static int ltc2983_thermistor_assign_chan(struct ltc29= 83_data *st, return __ltc2983_chan_assign_common(st, sensor, chan_val); } =20 +static int ltc2983_leak_detector_assign_chan(struct ltc2983_data *st, + const struct ltc2983_sensor *sensor) +{ + struct ltc2983_leak_detector *ld =3D to_leak_detector(sensor); + u32 chan_val; + int ret; + + chan_val =3D LTC2983_CHAN_ASSIGN(ld->r_sense_chan); + /* bits 21:19 must be 0b001 (ADT7604 datasheet Table 38) */ + chan_val |=3D LTC2983_THERMISTOR_CFG(1); + chan_val |=3D LTC2983_THERMISTOR_EXC_CURRENT(ld->excitation_current); + + ret =3D __ltc2983_chan_custom_sensor_assign(st, ld->custom, &chan_val); + if (ret) + return ret; + + return __ltc2983_chan_assign_common(st, sensor, chan_val); +} + static int ltc2983_diode_assign_chan(struct ltc2983_data *st, const struct ltc2983_sensor *sensor) { @@ -1037,6 +1145,195 @@ ltc2983_thermistor_new(const struct fwnode_handle *= child, struct ltc2983_data *s return &thermistor->sensor; } =20 +static struct ltc2983_sensor * +ltc2983_copper_trace_new(const struct fwnode_handle *child, struct ltc2983= _data *st, + const struct ltc2983_sensor *sensor) +{ + struct device *dev =3D &st->spi->dev; + struct ltc2983_copper_trace *ct; + int ret; + + if (sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) + return dev_err_ptr_probe(dev, -EINVAL, + "Invalid channel %d for copper trace\n", + sensor->chan); + + ct =3D devm_kzalloc(dev, sizeof(*ct), GFP_KERNEL); + if (!ct) + return ERR_PTR(-ENOMEM); + + struct fwnode_handle *ref __free(fwnode_handle) =3D + fwnode_find_reference(child, "adi,rsense-handle", 0); + if (IS_ERR(ref)) + return dev_err_cast_probe(dev, ref, + "Property adi,rsense-handle missing or invalid\n"); + + ret =3D fwnode_property_read_u32(ref, "reg", &ct->r_sense_chan); + if (ret) + return dev_err_ptr_probe(dev, ret, "Property reg must be given\n"); + + ct->is_sub_ohm =3D fwnode_property_read_bool(child, "adi,copper-trace-sub= -ohm"); + + if (ct->is_sub_ohm && fwnode_property_present(child, "adi,custom-copper-t= race")) + return dev_err_ptr_probe(dev, -EINVAL, + "sub-ohm copper trace cannot have a custom table\n"); + + if (!ct->is_sub_ohm) { + u32 excitation_current =3D 0; + + if (!fwnode_property_present(child, "adi,custom-copper-trace")) + return dev_err_ptr_probe(dev, -EINVAL, + "adi,custom-copper-trace is required for >1 ohm copper trace\n"); + + ct->custom =3D __ltc2983_custom_sensor_new(st, child, "adi,custom-copper= -trace", + false, 2048, false); + if (IS_ERR(ct->custom)) + return ERR_CAST(ct->custom); + + if (fwnode_property_present(child, "adi,excitation-current-microamp")) { + ret =3D fwnode_property_read_u32(child, "adi,excitation-current-microam= p", + &excitation_current); + if (ret) + return dev_err_ptr_probe(dev, ret, + "Failed to read adi,excitation-current-microamp\n"); + + switch (excitation_current) { + case 5: + ct->excitation_current =3D 0x01; + break; + case 10: + ct->excitation_current =3D 0x02; + break; + case 25: + ct->excitation_current =3D 0x03; + break; + case 50: + ct->excitation_current =3D 0x04; + break; + case 100: + ct->excitation_current =3D 0x05; + break; + case 250: + ct->excitation_current =3D 0x06; + break; + case 500: + ct->excitation_current =3D 0x07; + break; + case 1000: + ct->excitation_current =3D 0x08; + break; + default: + return dev_err_ptr_probe(dev, -EINVAL, + "Invalid value for excitation current(%u)\n", + excitation_current); + } + } else { + /* default to 1mA per datasheet recommendation for copper trace */ + ct->excitation_current =3D 0x08; + } + } + + ct->sensor.fault_handler =3D ltc2983_common_fault_handler; + ct->sensor.assign_chan =3D ltc2983_copper_trace_assign_chan; + if (ct->is_sub_ohm) + ct->sensor.n_iio_chan =3D 1; + else + ct->sensor.n_iio_chan =3D 2; + + return &ct->sensor; +} + +static struct ltc2983_sensor * +ltc2983_leak_detector_new(const struct fwnode_handle *child, struct ltc298= 3_data *st, + const struct ltc2983_sensor *sensor) +{ + struct device *dev =3D &st->spi->dev; + struct ltc2983_leak_detector *ld; + int ret; + u32 excitation_current =3D 0; + + if (sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) + return dev_err_ptr_probe(dev, -EINVAL, + "Invalid channel %d for leak detector\n", + sensor->chan); + + ld =3D devm_kzalloc(dev, sizeof(*ld), GFP_KERNEL); + if (!ld) + return ERR_PTR(-ENOMEM); + + struct fwnode_handle *ref __free(fwnode_handle) =3D + fwnode_find_reference(child, "adi,rsense-handle", 0); + if (IS_ERR(ref)) + return dev_err_cast_probe(dev, ref, + "Property adi,rsense-handle missing or invalid\n"); + + ret =3D fwnode_property_read_u32(ref, "reg", &ld->r_sense_chan); + if (ret) + return dev_err_ptr_probe(dev, ret, + "rsense channel must be configured\n"); + + if (!fwnode_property_present(child, "adi,custom-leak-detector")) + return dev_err_ptr_probe(dev, -EINVAL, + "adi,custom-leak-detector is required for leak detectors\n"); + + ld->custom =3D __ltc2983_custom_sensor_new(st, child, "adi,custom-leak-de= tector", + false, 16, false); + if (IS_ERR(ld->custom)) + return ERR_CAST(ld->custom); + + ret =3D fwnode_property_read_u32(child, "adi,excitation-current-nanoamp", + &excitation_current); + if (ret) + return dev_err_ptr_probe(dev, ret, + "adi,excitation-current-nanoamp is required for leak detectors\n"); + + switch (excitation_current) { + case 250: + ld->excitation_current =3D 0x01; + break; + case 500: + ld->excitation_current =3D 0x02; + break; + case 1000: + ld->excitation_current =3D 0x03; + break; + case 5000: + ld->excitation_current =3D 0x04; + break; + case 10000: + ld->excitation_current =3D 0x05; + break; + case 25000: + ld->excitation_current =3D 0x06; + break; + case 50000: + ld->excitation_current =3D 0x07; + break; + case 100000: + ld->excitation_current =3D 0x08; + break; + case 250000: + ld->excitation_current =3D 0x09; + break; + case 500000: + ld->excitation_current =3D 0x0a; + break; + case 1000000: + ld->excitation_current =3D 0x0b; + break; + default: + return dev_err_ptr_probe(dev, -EINVAL, + "Invalid value for excitation current(%u)\n", + excitation_current); + } + + ld->sensor.fault_handler =3D ltc2983_common_fault_handler; + ld->sensor.assign_chan =3D ltc2983_leak_detector_assign_chan; + ld->sensor.n_iio_chan =3D 2; + + return &ld->sensor; +} + static struct ltc2983_sensor * ltc2983_diode_new(const struct fwnode_handle *child, const struct ltc2983_= data *st, const struct ltc2983_sensor *sensor) @@ -1205,7 +1502,8 @@ static struct ltc2983_sensor *ltc2983_temp_new(struct= fwnode_handle *child, } =20 static int ltc2983_chan_read(struct ltc2983_data *st, - const struct ltc2983_sensor *sensor, int *val) + const struct ltc2983_sensor *sensor, + u32 base_reg, int *val) { struct device *dev =3D &st->spi->dev; u32 start_conversion =3D 0; @@ -1236,13 +1534,23 @@ static int ltc2983_chan_read(struct ltc2983_data *s= t, } =20 /* read the converted data */ - ret =3D regmap_bulk_read(st->regmap, LTC2983_RESULT_ADDR(sensor->chan), + ret =3D regmap_bulk_read(st->regmap, LTC2983_RESULT_ADDR(sensor->chan, ba= se_reg), &st->temp, sizeof(st->temp)); if (ret) return ret; =20 *val =3D __be32_to_cpu(st->temp); =20 + if (base_reg =3D=3D ADT7604_RES_RES_START_REG) { + /* + * Resistance result register gives a plain unsigned value, + * D31 is always 0, no valid bit, no fault bits. Read bits[30:0] + * directly =E2=80=94 the temperature result format does not apply here. + */ + *val &=3D GENMASK(30, 0); + return 0; + } + if (!(LTC2983_RES_VALID_MASK & *val)) { dev_err(dev, "Invalid conversion detected\n"); return -EIO; @@ -1274,7 +1582,16 @@ static int ltc2983_read_raw(struct iio_dev *indio_de= v, switch (mask) { case IIO_CHAN_INFO_RAW: mutex_lock(&st->lock); - ret =3D ltc2983_chan_read(st, st->sensors[chan->address], val); + switch (chan->type) { + case IIO_RESISTANCE: + ret =3D ltc2983_chan_read(st, st->sensors[chan->address], + ADT7604_RES_RES_START_REG, val); + break; + default: + ret =3D ltc2983_chan_read(st, st->sensors[chan->address], + LTC2983_TEMP_RES_START_REG, val); + break; + } mutex_unlock(&st->lock); return ret ?: IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: @@ -1291,6 +1608,13 @@ static int ltc2983_read_raw(struct iio_dev *indio_de= v, /* 2^21 */ *val2 =3D 2097152; return IIO_VAL_FRACTIONAL; + case IIO_RESISTANCE: + case IIO_COVERAGE: + /* value in ohm/percent */ + *val =3D 1; + /* 2^10 */ + *val2 =3D 1024; + return IIO_VAL_FRACTIONAL; default: return -EINVAL; } @@ -1351,7 +1675,7 @@ static int ltc2983_parse_fw(struct ltc2983_data *st) if (!st->sensors) return -ENOMEM; =20 - st->iio_channels =3D st->num_channels; + st->iio_channels =3D 0; device_for_each_child_node_scoped(dev, child) { struct ltc2983_sensor sensor; =20 @@ -1379,6 +1703,12 @@ static int ltc2983_parse_fw(struct ltc2983_data *st) return dev_err_probe(dev, ret, "adi,sensor-type property must given for child nodes\n"); =20 + if (sensor.type >=3D LTC2983_SENSOR_NUM || + !(st->info->supported_sensors & BIT_ULL(sensor.type))) + return dev_err_probe(dev, -EINVAL, + "sensor type %d not supported on %s\n", + sensor.type, st->info->name); + dev_dbg(dev, "Create new sensor, type %u, channel %u", sensor.type, sensor.chan); =20 @@ -1399,13 +1729,14 @@ static int ltc2983_parse_fw(struct ltc2983_data *st) } else if (sensor.type =3D=3D LTC2983_SENSOR_SENSE_RESISTOR) { st->sensors[chan] =3D ltc2983_r_sense_new(child, st, &sensor); - /* don't add rsense to iio */ - st->iio_channels--; } else if (sensor.type =3D=3D LTC2983_SENSOR_DIRECT_ADC) { st->sensors[chan] =3D ltc2983_adc_new(child, st, &sensor); - } else if (st->info->has_temp && - sensor.type =3D=3D LTC2983_SENSOR_ACTIVE_TEMP) { + } else if (sensor.type =3D=3D LTC2983_SENSOR_ACTIVE_TEMP) { st->sensors[chan] =3D ltc2983_temp_new(child, st, &sensor); + } else if (sensor.type =3D=3D LTC2983_SENSOR_COPPER_TRACE) { + st->sensors[chan] =3D ltc2983_copper_trace_new(child, st, &sensor); + } else if (sensor.type =3D=3D LTC2983_SENSOR_LEAK_DETECTOR) { + st->sensors[chan] =3D ltc2983_leak_detector_new(child, st, &sensor); } else { return dev_err_probe(dev, -EINVAL, "Unknown sensor type %d\n", @@ -1420,6 +1751,16 @@ static int ltc2983_parse_fw(struct ltc2983_data *st) st->sensors[chan]->chan =3D sensor.chan; st->sensors[chan]->type =3D sensor.type; =20 + /* + * Dedicated functions set n_iio_chan themselves; for all other + * sensor types rsense produces 0 channels, everything else 1. + */ + if (!st->sensors[chan]->n_iio_chan) { + if (sensor.type !=3D LTC2983_SENSOR_SENSE_RESISTOR) + st->sensors[chan]->n_iio_chan =3D 1; + } + st->iio_channels +=3D st->sensors[chan]->n_iio_chan; + channel_avail_mask |=3D BIT(sensor.chan); chan++; } @@ -1467,8 +1808,9 @@ static int ltc2983_eeprom_cmd(struct ltc2983_data *st= , unsigned int cmd, =20 static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio) { - u32 iio_chan_t =3D 0, iio_chan_v =3D 0, chan, iio_idx =3D 0, status; struct device *dev =3D &st->spi->dev; + u32 iio_chan_t =3D 0, iio_chan_v =3D 0, iio_chan_r =3D 0, iio_chan_c =3D = 0; + u32 chan, iio_idx =3D 0, status; int ret; =20 /* make sure the device is up: start bit (7) is 0 and done bit (6) is 1 */ @@ -1516,12 +1858,33 @@ static int ltc2983_setup(struct ltc2983_data *st, b= ool assign_iio) continue; =20 /* assign iio channel */ - if (st->sensors[chan]->type !=3D LTC2983_SENSOR_DIRECT_ADC) { - chan_type =3D IIO_TEMP; - iio_chan =3D &iio_chan_t; - } else { + switch (st->sensors[chan]->type) { + case LTC2983_SENSOR_COPPER_TRACE: + if (st->sensors[chan]->n_iio_chan =3D=3D 1) { + /* sub-ohm copper traces produce only a resistance result */ + st->iio_chan[iio_idx++] =3D + LTC2983_CHAN(IIO_RESISTANCE, iio_chan_r++, chan); + } else { + st->iio_chan[iio_idx++] =3D + LTC2983_CHAN(IIO_TEMP, iio_chan_t++, chan); + st->iio_chan[iio_idx++] =3D + LTC2983_CHAN(IIO_RESISTANCE, iio_chan_r++, chan); + } + continue; + case LTC2983_SENSOR_LEAK_DETECTOR: + st->iio_chan[iio_idx++] =3D + LTC2983_CHAN(IIO_COVERAGE, iio_chan_c++, chan); + st->iio_chan[iio_idx++] =3D + LTC2983_CHAN(IIO_RESISTANCE, iio_chan_r++, chan); + continue; + case LTC2983_SENSOR_DIRECT_ADC: chan_type =3D IIO_VOLTAGE; iio_chan =3D &iio_chan_v; + break; + default: + chan_type =3D IIO_TEMP; + iio_chan =3D &iio_chan_t; + break; } =20 /* @@ -1538,6 +1901,7 @@ static int ltc2983_setup(struct ltc2983_data *st, boo= l assign_iio) static const struct regmap_range ltc2983_reg_ranges[] =3D { regmap_reg_range(LTC2983_STATUS_REG, LTC2983_STATUS_REG), regmap_reg_range(LTC2983_TEMP_RES_START_REG, LTC2983_TEMP_RES_END_REG), + regmap_reg_range(ADT7604_RES_RES_START_REG, ADT7604_RES_RES_END_REG), regmap_reg_range(LTC2983_EEPROM_KEY_REG, LTC2983_EEPROM_KEY_REG), regmap_reg_range(LTC2983_EEPROM_READ_STATUS_REG, LTC2983_EEPROM_READ_STATUS_REG), @@ -1680,26 +2044,35 @@ static DEFINE_SIMPLE_DEV_PM_OPS(ltc2983_pm_ops, ltc= 2983_suspend, static const struct ltc2983_chip_info ltc2983_chip_info_data =3D { .name =3D "ltc2983", .max_channels_nr =3D 20, + .supported_sensors =3D LTC2983_COMMON_SENSORS, }; =20 static const struct ltc2983_chip_info ltc2984_chip_info_data =3D { .name =3D "ltc2984", .max_channels_nr =3D 20, .has_eeprom =3D true, + .supported_sensors =3D LTC2983_COMMON_SENSORS, }; =20 static const struct ltc2983_chip_info ltc2986_chip_info_data =3D { .name =3D "ltc2986", .max_channels_nr =3D 10, - .has_temp =3D true, .has_eeprom =3D true, + .supported_sensors =3D LTC2983_COMMON_SENSORS | BIT_ULL(LTC2983_SENSOR_AC= TIVE_TEMP), }; =20 static const struct ltc2983_chip_info ltm2985_chip_info_data =3D { .name =3D "ltm2985", .max_channels_nr =3D 10, - .has_temp =3D true, .has_eeprom =3D true, + .supported_sensors =3D LTC2983_COMMON_SENSORS | BIT_ULL(LTC2983_SENSOR_AC= TIVE_TEMP), +}; + +static const struct ltc2983_chip_info adt7604_chip_info_data =3D { + .name =3D "adt7604", + .max_channels_nr =3D 20, + .has_eeprom =3D true, + .supported_sensors =3D ADT7604_SENSORS, }; =20 static const struct spi_device_id ltc2983_id_table[] =3D { @@ -1707,6 +2080,7 @@ static const struct spi_device_id ltc2983_id_table[] = =3D { { "ltc2984", (kernel_ulong_t)<c2984_chip_info_data }, { "ltc2986", (kernel_ulong_t)<c2986_chip_info_data }, { "ltm2985", (kernel_ulong_t)<m2985_chip_info_data }, + { "adt7604", (kernel_ulong_t)&adt7604_chip_info_data }, { } }; MODULE_DEVICE_TABLE(spi, ltc2983_id_table); @@ -1716,6 +2090,7 @@ static const struct of_device_id ltc2983_of_match[] = =3D { { .compatible =3D "adi,ltc2984", .data =3D <c2984_chip_info_data }, { .compatible =3D "adi,ltc2986", .data =3D <c2986_chip_info_data }, { .compatible =3D "adi,ltm2985", .data =3D <m2985_chip_info_data }, + { .compatible =3D "adi,adt7604", .data =3D &adt7604_chip_info_data }, { } }; MODULE_DEVICE_TABLE(of, ltc2983_of_match); --=20 2.43.0