From nobody Mon Jun 8 22:54:21 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 3FB3C3F166E; Mon, 25 May 2026 16:41:22 +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=1779727283; cv=none; b=LiPE4f+Xg4i9SJGoUh/fTm6jhEx4VDpnFw1pXcmPGYejE26u+O4Eb2WvW92PZMH9ZF8QTe9j0l33Y/pBX7cm9AxPdneBtNuR1VmTpI/CJbpC7ws36xuUWQzLzYeqgG7LtO6Z3G3OQtsJc3G0NJoo/wY8E/eGxnZMvgkF38IWEGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779727283; c=relaxed/simple; bh=N//smexeu78k7VZNjF9eKlSOg1vGTW525zJL46EXc6U=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u24mZI/U+D03q1fBHG7jluIvstbwJbXQizfgRx7qH7oP5y29nbyw9xlLK4+3kEjStYBC/NTj4JEqVDJ75CSASFn2yB72bT1XqCKfqhLUoKNRlYTOVw601DcqyNojbi0s+lo5spu3/WwkW2i4cAtoN9h/K5qAhGIcN8L0cMTCvHk= 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=GvmFr1hM; 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="GvmFr1hM" 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 64PAkB673473357; Mon, 25 May 2026 12:41:19 -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=udgKC 8VDB9Z4eEpgdoi5mYURlLA8Sr56G9Xh5wsuDF8=; b=GvmFr1hMhuORn+w6rLvE8 59wkeOgBsAOPQyqHzKGY1p1PAG0ody6GeQa1IptPhZKqE0GZ5pXC5SLzscxjoQFW pzNcE0KMBEPU8pFFEnBYLIiuB11UMxcCiWgjWXrDnon0+OMo4hQP+ovIk58yelPn ivAEJ3JJnE37EqjVSyDZxrylHg9/mGujfLv7mDNmDoZKrU3nI0q9zcANsY2BiWRg oU8zqOlueaXHLQCvcjFLmBRG5jNsT6kFUlgAc8jW/8Kiu9RTZ7Swv1iqRs7sXc1k X68b8TuxehdMQOGggUmjTpAe8F9yhxdB0cbwypuAQbaT9opFlzQBDmBuHujRvIsf A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4ebwje53uu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 May 2026 12:41:18 -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 64PGfHNm022268 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 25 May 2026 12:41:17 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Mon, 25 May 2026 12:41:17 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Mon, 25 May 2026 12:41:17 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com ([10.32.226.85]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64PGevH0028845; Mon, 25 May 2026 12:41:07 -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 v4 1/9] iio: temperature: ltc2983: Fix n_wires default bypassing rotation check Date: Mon, 25 May 2026 19:39:28 +0300 Message-ID: <20260525164013.118614-2-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525164013.118614-1-liviu.stan@analog.com> References: <20260525164013.118614-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: AW1haW4tMjYwNTI1MDE2OCBTYWx0ZWRfXx3s64c3LmOyL lrUjI4QEt4ViDhoaOh3I1mFNdc1zykiDoREqvKaFTYu/Xl9Fq1WxHGTyeZQA24wzD2QkzHdhpKj I8Jrh8DCy7+sZttirAFngId/zjJKWnFya04fE1tfFKAEqvigQs6zURqxScNV4w9cBV428HYG9Og FK6uMPK3969wLT8ru0uG8SKhhKCFt40eClUrTdQ7BmC/mNeDnwNM6A4AAsyXwwSmV/YEfHi17BR 9gJ0rhVrROhNUKD9PlHdaQTBiYU7CJ3L+PygJTSudGhucCZyZRaa5VoEu3RyH0AfFSTggGUqvaG AKr4YTOTNKxl+Q72nK8D3Vosm4wfV9PzDIQIvGZsiHs2zO4pXx1nbCOTcwzqFfzx4r21Cvwv3G7 CX+gy0VazPHtoyEdLOirYYWjtQ2QIIUhogRc2ZJexle6pbgGeX/yKY6btC91LmuX8BpZa+ktfwZ 9XEBaHvtYmuGvzP9oyA== X-Proofpoint-GUID: W4b3fOW9-56MJvBqmNUPcoOdWXbhQl4B X-Proofpoint-ORIG-GUID: W4b3fOW9-56MJvBqmNUPcoOdWXbhQl4B X-Authority-Analysis: v=2.4 cv=fKEJG5ae c=1 sm=1 tr=0 ts=6a147bae 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=itsfFgpfY7t2nVq4jXIA: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-25_04,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 clxscore=1015 adultscore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605250168 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 v4: - Moved to the front of the series 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 38e6f8dfd3b8..1f835e326b93 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -741,7 +741,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 Mon Jun 8 22:54:21 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 2F0E93F5BD8; Mon, 25 May 2026 16:41: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=1779727291; cv=none; b=to8cm6xrkxeaapGcKzjnZIrLkef+8Cji8AfwD+LNL/0+G0ozT8iUHk53lzCGSXYHGhl4jW2G28pcdxjUQnx9nqU6SPC0wByRGDGA0fqg/VWnlCxwwm1VxOFgZK9940ZWJP7xYeuRPzqGLSO/gLd0974O+lI0LPFagkIXTlW4sEM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779727291; c=relaxed/simple; bh=ixLEFfGMNDvcyDVn3XjAPMI5yVm/JPO3wdn6NpACwQg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ioCZ3Qc5sWgpvGnpG9YAwQQi0BKiq63Q8atXEAJv2fcIs1+b+L2dZUfzQUHI95OHXXnwTLhgzIVUdfelJX8CF0T5YF4YQWAYwiteN0fubHTGw4LyhN+nhx/2hjrC71ikzsVwQXjAxw0upZaURKCG6k9lA7d6U8+fJqrpyaFy+jo= 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=yHkKW0x6; 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="yHkKW0x6" 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 64PBi8tm3473088; Mon, 25 May 2026 12:41: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=R/eZX X/oOgktdTh4INy5g5mfQuzzHbbZojxb5GYx7bc=; b=yHkKW0x6pBrf7v6F0PB9O ixt1aG1l1X4UjFZ+iy7DJZn9gftiyFDifkiW2lnspodgM3J4JOUsJpfAgHpZ7uOq xucV39laBMcY9G4Nh6mP82woLRPzrezWmSHCEzedBXjDQaIB5hplr2S2owNFxxnL jorCmIS41sHZG9tw6UgIELxWOyk7qCH9LSXoxQD9faP5BWy+xZyQnJF2twhdB42V aMI5PuzDsf3h59O52ouxohvu8JzyR9npKiHGlUBhUWGJ/PDxDToR9vhYDgPAh/Cm rczG7ZhqQfV2H+do/doNRu/Ybc7toJe7Po7XaEcaotOKCoHaoKpFA/OnTK46FzoV w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4ebwje53v6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 May 2026 12:41:23 -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 64PGfM8v022283 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 25 May 2026 12:41:22 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) 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; Mon, 25 May 2026 12:41:22 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Mon, 25 May 2026 12:41:22 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com ([10.32.226.85]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64PGevH1028845; Mon, 25 May 2026 12:41: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 v4 2/9] iio: temperature: ltc2983: Fix reinit_completion() called after conversion start Date: Mon, 25 May 2026 19:39:29 +0300 Message-ID: <20260525164013.118614-3-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525164013.118614-1-liviu.stan@analog.com> References: <20260525164013.118614-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: AW1haW4tMjYwNTI1MDE2OCBTYWx0ZWRfX3k30pddzPDTD fJyIgMHzj3yIeTUEPd7Gp7N/ybbvzNekOfFSKas6PHKznjc6Hfe1rvoEeez0hsI+0kLML5b9Ghj 13L0GkHwAcmpecZEX7QOw13wwDWVMuftY8PvjtAWwHjEaZwQ8h+/vT6JHwHqN9w/vlpGM5NmFUz NbPMduhKbZ5YR29GTImh6U/dJhRkz0wHTrieJJfkxed2nLmQpWV3EBjUhE6DVfN8J9BOHsZK5kf YhOCu1SVU2JSidJJOieiJsMG5qQZtagN7HPGb/vKXVpEdbZzJLKXaKerEuo33s6FnlIR7x+x5Pc IvtdRwYGPeJiANdGdVM7PqIO3z1oNBFtM63er6AUKEUc1O4Q/U3dOdeSCAIT/1a77jiw9POjW90 NgWmjHNEkvjnvhybiaS3TXkg/Hvkbqtog2r4xIaeRSR050Mf+W755cziEM0Wu7UILI3j/g4Idt3 6dGltzqkJCV1XRr2tNw== X-Proofpoint-GUID: 6n_df4fYt1tONc1ukKAjxB4NMqYESNKI X-Proofpoint-ORIG-GUID: 6n_df4fYt1tONc1ukKAjxB4NMqYESNKI X-Authority-Analysis: v=2.4 cv=fKEJG5ae c=1 sm=1 tr=0 ts=6a147bb3 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=sADee9SCKmkYh09WN8oA: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-25_04,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 clxscore=1015 adultscore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605250168 Content-Type: text/plain; charset="utf-8" reinit_completion() was called after regmap_write() initiated the hardware conversion, creating a race window where the interrupt could fire and call complete() before reinit_completion() reset the completion. Move reinit_completion() before the regmap_write() to close the race. ltc2983_eeprom_cmd() already does it in the correct order. Fixes: f110f3188e56 ("iio: temperature: Add support for LTC2983") Signed-off-by: Liviu Stan --- Changes in v4: - New patch drivers/iio/temperature/ltc2983.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index 1f835e326b93..2bc5cd46a72f 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -1177,12 +1177,11 @@ static int ltc2983_chan_read(struct ltc2983_data *s= t, start_conversion |=3D LTC2983_STATUS_CHAN_SEL(sensor->chan); dev_dbg(&st->spi->dev, "Start conversion on chan:%d, status:%02X\n", sensor->chan, start_conversion); + reinit_completion(&st->completion); /* start conversion */ ret =3D regmap_write(st->regmap, LTC2983_STATUS_REG, start_conversion); if (ret) return ret; - - reinit_completion(&st->completion); /* * wait for conversion to complete. * 300 ms should be more than enough to complete the conversion. --=20 2.43.0 From nobody Mon Jun 8 22:54:21 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 1808C3F4135; Mon, 25 May 2026 16:41:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779727291; cv=none; b=U7EpO6Q1lUSWgeN0wHcWB6u39BpFrk9+RVcvq9FVHaIVCXcutZw3HkFoEeukPlzAqdrshV56pqB3Rc7nzPoPBy9pbEO+0mdyoWE6PMFPnDO3JMUg2Xuz6QCg5nefa535kDykq5hZ04I1KNJf7SSx0YIeoTGYAc9JJmE4miaXuPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779727291; c=relaxed/simple; bh=CudadbESsfPzbX+9jpFxGWvHGBZpQrm/hKaD4Z/NPp0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rKX4K9+0xXIUs3CVS4rnakyucS21zi9gNUdiHvTaKyIFeN8cabC2ljf4B1Vw/MrgGFTke0Bsg3gALPKMB4aw07dRtFrE/uzbQVAboSbn4Nf0VvwhbU4WWKrOrOrr3AlDx39FWlWSfTWR77qqq7HuRGZKL7POOTh/KkWmf/S9ZuA= 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=udWwTl6M; 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="udWwTl6M" 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 64PEf1gt367433; Mon, 25 May 2026 12:41:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=d98MD gyScq/wOgX4sBvqzz2B3F4EAaPSoGikth9OtC8=; b=udWwTl6Mml6f43R3WoRwf Bx9uWjEn0HKoW+5Q4ACmGfIGxTFiJAfiB00X4PvXzq1QniKi8KvupTVGPiAZVXmD Vw4Un6SpwHoS1CUBVEcIpV1xAH4wq7cWSGBP9JdWVEvQMI8BZk8An3nH0J/yjM2a tAmjagfulTH0G/P2Y0G3jbBggtA+cKNq4iHnLXKgtxzRGfv8ZcqRORKOWJnBc83N qIttYN+SztYeAIykHIRjeNcrPDcAN/LEQeYqQPFnn9IAxtO68uhW6JguSUlTprWl rsDCdSwHlTVVIK6igjbGpIo33AxMG9qo4LmDXdXBa+tjGWhY/Enf6J8pinf+kUkI g== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4ebwje53vb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 May 2026 12:41:26 -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 64PGfPTs022292 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 25 May 2026 12:41:25 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) 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; Mon, 25 May 2026 12:41:25 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Mon, 25 May 2026 12:41:25 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com ([10.32.226.85]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64PGevH2028845; Mon, 25 May 2026 12:41:17 -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 , , , , CC: Joshua Crofts Subject: [PATCH v4 3/9] iio: temperature: ltc2983: Fix macro parenthesization and rename Date: Mon, 25 May 2026 19:39:30 +0300 Message-ID: <20260525164013.118614-4-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525164013.118614-1-liviu.stan@analog.com> References: <20260525164013.118614-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: AW1haW4tMjYwNTI1MDE2OCBTYWx0ZWRfX3q6PjwuWJqq9 jgOAW8wCm0GDQJfmzhBU7sAXqa5N3+UXVDpix0oBYolIkinQv1Ic7Z2G8FEqfkaHlXzvF7nTbAM RMfIpPSzTjhk5muDSxiIdYsAF4jyHiOOZcr0BNq3q5q7eFActJjBa+qZFGfpkbIB+G53TyLPsN7 RkDR8P5oxal/s02CfS+hdcOYAVqwHET3IgVgGIR2cc6IMVv2jJjMzdhTPfFRuUjRe5LjDH04GGn 0vpMYuF9i1L3yHekxotX3pq2c06BkFhZLb5WByk2QNdJ0t6AGwin5lxgUPJzrapRmJZd0wh7lUo 3JUWUnSbUInCBEjajahSmMamx/VgHQ7qqbgjJSWBBQEHDSEy6aX8TTCOoIRckK1y7gtgBbd6ite QGvx6prFHb3pq+AdGsgCC5Be4mz4yK8FvfRBHMTD6pJLWLSHUJ0u97Txjg0lRw2b+g3MpKGjCCP MGhVBVN+k+h7Byt1g6g== X-Proofpoint-GUID: x9_FTFLSn-GnGwAWHLlnc0lWxkyzyIGg X-Proofpoint-ORIG-GUID: x9_FTFLSn-GnGwAWHLlnc0lWxkyzyIGg X-Authority-Analysis: v=2.4 cv=fKEJG5ae c=1 sm=1 tr=0 ts=6a147bb6 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=OmVn7CZJonkx5R5zMQLL:22 a=pGLkceISAAAA:8 a=gAnH3GRIAAAA:8 a=NK9M8l_gB6tpaUwuH9IA: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-25_04,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 clxscore=1011 adultscore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605250168 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. Reviewed-by: Joshua Crofts Signed-off-by: Liviu Stan --- Changes in v4: - Added Reviewed-by: Joshua Crofts 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 2bc5cd46a72f..4bae90f03002 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, @@ -1196,7 +1196,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 Mon Jun 8 22:54:21 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 E3B491A681E; Mon, 25 May 2026 16:41:36 +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=1779727298; cv=none; b=VYIJ1rysy6FmgqFayGaVPAlcZTMbu5QUzLoDLIqN0kWpmN6oIidS+lodqvQ53NCDvjeKhCr20nPKsZ0fs7iWel2vMu4eghaV2t7f+xMp8PRcCUugXj1xaR3JaRfijJoTYs8HwHqSANNdIBEH7hOWH3RWQoCbPXX3UpazFDWdbI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779727298; c=relaxed/simple; bh=+Ej+qb4/P6rmQ38NiqwulK1s6WEJNYNuOEWwxYKF/uE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JUDp8Pz2tRyVDtoKNKeOB4Jryng3+YJYtkkjuEcY3ZQmFUjdTrvIHbPW8MOvVfk2FmhBXC6OcmrRpY2ZoNFEyedPPK0UxIJORWZLuZNYC92J1+f8+QffzTDzva691K19wUc/CsenU4e1PXM5N5bnvx1jHXEFe+rn2rfsa4dryoo= 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=vWlLS3ev; 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="vWlLS3ev" 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 64PBQ9Ij753521; Mon, 25 May 2026 12:41:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=4u19b F15aWhMFTJbLM/nX/V+7lOgfpWfDJugEP2NT6I=; b=vWlLS3evoL4bO0q3uWCSU C6pmDz6pmQp1MBp4xBXPi3sKvERNSc73527Gv5Y0sv63zxAwAFQZ5nr3NLyeCYwn WsJUP40D5U222oZxt/Eixz/D0iFL9zspwX3bSunaBffrcXstY/iNgJE39CzACLui sqsEr9kD4bUA/UkRJoU6/NnlwWLfwy8bmh4yrLToGrRrs4MktsBv5ifi0jEkYEnL GpwGg5B5pbOh2PZbXuK+P3LSwlH1FBBpYsq9cn4Wmi3fNHSG0c8jU8zJAh1MPsGi 0hMTNsujnwLRSo7lDEtZmsUxmROen3atsp+jTODDiP15kSjts3o2EHzLGgzjlFQ7 A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 4ecbgtavay-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 May 2026 12:41:33 -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 64PGfWKQ022298 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 25 May 2026 12:41:32 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) 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; Mon, 25 May 2026 12:41:31 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) 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; Mon, 25 May 2026 12:41:31 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Mon, 25 May 2026 12:41:31 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com ([10.32.226.85]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64PGevH3028845; Mon, 25 May 2026 12:41: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" , Liviu Stan , Francesco Lavra , , , , CC: Joshua Crofts Subject: [PATCH v4 4/9] iio: temperature: ltc2983: Use local device pointer consistently Date: Mon, 25 May 2026 19:39:31 +0300 Message-ID: <20260525164013.118614-5-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525164013.118614-1-liviu.stan@analog.com> References: <20260525164013.118614-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: oUHkMCa7oA-vDfhTb96Ds9jwCMVyBwcd X-Proofpoint-ORIG-GUID: oUHkMCa7oA-vDfhTb96Ds9jwCMVyBwcd X-Authority-Analysis: v=2.4 cv=L5EtheT8 c=1 sm=1 tr=0 ts=6a147bbd cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=N--XFCr6TIEc_64PeIT2:22 a=pGLkceISAAAA:8 a=gAnH3GRIAAAA:8 a=WZ6_M-xBb7e6Z6g-aakA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTI1MDE2OCBTYWx0ZWRfX+z0ZBBq6eDyD 9vmNZMYxTnj0KI5eshHZJhKUQqkR9kTtQl7EcGyRHIushHmDLwcLnlRP4uELDoT2BcZqJqBYZPq ZMdNAHwkDfF8TiU8gGkBKtyYzaJuav/zVjN3ogmxrnIG0NGbTW8DP8n8Mo8/uPJ80Zfqb6zFoo3 lFJMXyizwTTbeoFwm/3DHtugw/QryPaiSWto391kiucL5DhhI/Xe7gorm/4OCXfDh+3Q7CUiCtq qxwwb8pBF69E7dKik4q6z1Ll8q1/1kTdHbndWEqVbFxB4wT75GiG6YulJ3iUUGbZsxeKDC0NQo6 +aAeB+vV1jLwxmco+RzX/dQC33HZux2nl/085+E9H0/0q25GYhpwT1nwwg8HJPXvWApOEkemkzY TpX1viOy5u/uMomVjVL7W7bnhmDZLb2QTFVQ+Onv5ARqDZdhn9S7tgrHBPyTVKrSp0o6Dpk8ALd qtJB+6bCvtGvbcPHO4g== 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-25_04,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1011 lowpriorityscore=0 malwarescore=0 suspectscore=0 bulkscore=0 impostorscore=0 phishscore=0 priorityscore=1501 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605250168 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 and collapse some wrapped lines that now fit within 80 characters. Reviewed-by: Joshua Crofts Signed-off-by: Liviu Stan --- Changes in v4: - Collapsed some wrapped lines that now fit within 80 characters - Decided to leave lines that would slightly pass 80 characters wrapped since they looked more readable - Updated commit message to reflect the line consolidation - Added Reviewed-by: Joshua Crofts drivers/iio/temperature/ltc2983.c | 87 +++++++++++++++++-------------- 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index 4bae90f03002..8b0b6b4884f6 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -351,11 +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, - chan_val); + 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, sizeof(st->chan_val)); @@ -656,11 +656,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 +688,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 +698,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 +713,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 +824,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 +874,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 +923,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 +965,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 +1004,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 +1017,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 +1038,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 +1063,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 +1081,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 +1118,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 +1129,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 +1144,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 +1155,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 +1174,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); reinit_completion(&st->completion); /* start conversion */ @@ -1191,7 +1197,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 @@ -1204,7 +1210,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 @@ -1221,12 +1227,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", - chan->address); + dev_err(dev, "Invalid chan address:%ld", chan->address); return -EINVAL; } =20 @@ -1302,7 +1308,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), @@ -1390,6 +1396,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; @@ -1409,7 +1416,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); @@ -1417,7 +1424,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; @@ -1426,6 +1433,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 */ @@ -1433,8 +1441,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, - "Device startup timed out\n"); + return dev_err_probe(dev, ret, "Device startup timed out\n"); =20 ret =3D regmap_update_bits(st->regmap, LTC2983_GLOBAL_CONFIG_REG, LTC2983_NOTCH_FREQ_MASK, @@ -1534,12 +1541,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 @@ -1551,7 +1559,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); @@ -1564,11 +1572,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 @@ -1578,7 +1586,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) @@ -1588,11 +1596,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, - "failed to request an irq\n"); + return dev_err_probe(dev, ret, "failed to request an irq\n"); =20 if (st->info->has_eeprom) { ret =3D ltc2983_eeprom_cmd(st, LTC2983_EEPROM_WRITE_CMD, @@ -1609,7 +1616,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 Mon Jun 8 22:54:21 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 1BA9F3F54CC; Mon, 25 May 2026 16:41:40 +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=1779727302; cv=none; b=qCZqa8AXkac2A9YppWk0bED8szRZRiVBzw8+aEOd2+hRRjT8HvZO1coUD73miaRgrVUW1hHbn2SRKJ+TZZ/VZUMnyffVvBR/AVzpfQR/M7bgRvmQVf3HRzWlOGPhhrZpS7/jTjWgPI4o+ACjIu6zIxwNEZs6unP5F6/SGf0pHDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779727302; c=relaxed/simple; bh=jVRk4v/HEYaMRwQzQJdbJXitSJIzy2V79PnAvS73wcI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bL45IoCP0601eQmNrFo5GlguINKsLt+pyjyXIWkwHgIMBo6zIByxQEaIA/bigD9RGtRoJQsOgVU/q3G2YOUsgcIUXJkYDF6KOtR6H2Xy1ZB4w0n7Bd37diHCsg5x+wt6DUF71JIzABJAyWBeBiP8sqfH/MwWcCtOW+BCiIAXmZo= 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=e23yUl64; 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="e23yUl64" 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 64PAiY0C2477671; Mon, 25 May 2026 12:41:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=140iH kuUvVj0oOJXbJo0HxFLGcdbV/GVziW5p2fkL7s=; b=e23yUl64aEKNmC1gTy9iR 6uxacWhXKu2B515+Ug8zta9abQKfrU3W/suiqLEGxx8toIA4Y3aEk6GP4Mdv4LNw na9v7Sgp5LZ7tEUA9U8qN6NmyYAVzpjtqorBaEeF7+B3uX3YFrpHTPL6v66gQNSC xX9lzcGTvA9N1WwKVLayHPvgiaKCpzoTVXpKV/epfEzC1se4krz4RudSOmZgWYZO AdEvvJQAjoWV5iVhmYsrWw4Yk6WHgpnr7G+oKmGXa5tqYAZuRu0h/Coiagu48Ha+ mKYwJ/PRtDwY2NDE7HJX8kHBzmXtIyPTRKCvDrF18e3D9XJTpvACs1zHn/cBGYC1 w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4ecbgqawh1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 May 2026 12:41:37 -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 64PGfa6J022301 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 25 May 2026 12:41:36 -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; Mon, 25 May 2026 12:41:36 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Mon, 25 May 2026 12:41:36 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Mon, 25 May 2026 12:41:36 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com ([10.32.226.85]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64PGevH4028845; Mon, 25 May 2026 12:41:31 -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 , , , , CC: Joshua Crofts Subject: [PATCH v4 5/9] iio: temperature: ltc2983: Fix inconsistent channel wording in messages Date: Mon, 25 May 2026 19:39:32 +0300 Message-ID: <20260525164013.118614-6-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525164013.118614-1-liviu.stan@analog.com> References: <20260525164013.118614-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: ZkzHj8A3TdH6tsyIaDgs8JEuE8PK6Ciq X-Authority-Analysis: v=2.4 cv=N5cZ0W9B c=1 sm=1 tr=0 ts=6a147bc1 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=uXIjobp8t2wMuQ0fPvqm:22 a=pGLkceISAAAA:8 a=gAnH3GRIAAAA:8 a=AdEO_u_nCXX3MimJr_gA:9 X-Proofpoint-ORIG-GUID: ZkzHj8A3TdH6tsyIaDgs8JEuE8PK6Ciq X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTI1MDE2OCBTYWx0ZWRfX6AQN7sVWbXRa ttHfpYWFXQdmwvPF2266cEJqUdsJDihSWS/TUK0GHuO7iPN/lBvfHjOn7jlvMO5om6HU9m1d0/1 dCYH6RZeaLXb9g6vs1WejUj5UIx6iqpLsEDHS+QHYhjhvvaZJXYX4S4z7WRWOAJVJN6u28IuY8l rZHnCtZ1pFCT3xlKWO0jwBvb8mgTvw/M+czM3/zvbiB2106x/EfVRDJjoGq3Q5tyiEfqQcMJwNH U113/RQnk+7FaAopWIJXWzYpe/KArtkgYTyYhArn91JrjpfTH0GUFuRJ+XTi8SfHmim6lsnzfma 6Tyv20vm5qBAfXNPDUsQjbhtC3h8gt+sXJEbDPhzXdo0NuwrvglxGpd1LbAxzrux6cADTFZE24q Uc0kLKfpNNhwDw4Jj3ZJt6T4XTC1/2qjfU97M5QLQiJ5cA6qit6DdlwXLm/rxaU6agR4IRt+iFe Jcpo1HwvHcnH8C/1imQ== 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-25_04,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1011 impostorscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605250168 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". Reviewed-by: Joshua Crofts Signed-off-by: Liviu Stan --- Changes in v4: - Added Reviewed-by: Joshua Crofts 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 8b0b6b4884f6..fc904c0a42b4 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -699,7 +699,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 @@ -797,7 +797,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. */ @@ -814,18 +814,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 @@ -924,7 +924,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 */ @@ -1039,7 +1039,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 */ @@ -1093,7 +1093,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); @@ -1130,7 +1130,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 */ @@ -1156,7 +1156,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", @@ -1181,7 +1181,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); reinit_completion(&st->completion); /* start conversion */ @@ -1232,7 +1232,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", chan->address); + dev_err(dev, "Invalid channel address: %ld\n", chan->address); return -EINVAL; } =20 @@ -1329,14 +1329,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); @@ -1344,7 +1344,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 Mon Jun 8 22:54:21 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 E0C093F5BC5; Mon, 25 May 2026 16:41:45 +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=1779727307; cv=none; b=fIFnvF1Us6cL+VhJ+XsbiN1AmZwNOJLXEFG3szx8iYNIIwmhkDAGGSdQ7Q6QLI0C8hvbcEV3L4v//vbrgearO7JUFE4VsmOAcbkMm6dWlkc/evcnv6lZHizgWXDQevs/u6hO+nOiYRg3+Bhl85JpiQx0nH9tR/gCBLkHggF7R+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779727307; c=relaxed/simple; bh=JIst4o0j7wuo6h/TJXHXlAPZjkaV78ADFvWAcjzE230=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Tcxl+K+r9ZrIavVSBmMfD17o//FJN2tcIGWxzfmL9kne816ykK9He7fVjg72iEmmMxqBAqTZfzMxBeeK1QjVNDav6Utxsx/fc18P33L3d05SKJ14UxDm6pDQE+RN9ehtt+3/aMR0ycFmRx6FI8jI1aEOunG8ybeI56Lq0FPFczg= 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=E1UCox9o; 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="E1UCox9o" 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 64PC2MBc753613; Mon, 25 May 2026 12:41:43 -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=qJcYK cgNTZxUFnt3e2bi2jnmaNa99UL+Xti+u6X9DZA=; b=E1UCox9og0K7iFBjHlX2V fT1W8d/kX1nMQsZiQkSUMpV4VkqclE2iSYh+enjmIli50ulTQRd9RYMJr0fdKmm3 qgC1bgTpzBKqA48UdsbDYMDq/7Mn33F6pi1HikzxeAsUekTwCxVIlcpl2lY9U5AB q/1xxmC35+IVSRT/wX9dsPwx0/8hyvlXuQ4n0m0aIQEnZOk8CtADPRV5g8TAxSkh MyW8tBo6mtKetSXekIRpOWglyF1ukgK/6UXrCyhBKqVEYMquqctjTq9A9WTDGa7C zpmyoZGIObuKn9jmutIyIQJeBir8Iv5uJHLF85OrNq2yxe0TTwwSdQ3unhg33+AR Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 4ecbgtavb9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 May 2026 12:41:43 -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 64PGfgBh022304 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 25 May 2026 12:41:42 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Mon, 25 May 2026 12:41:42 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Mon, 25 May 2026 12:41:42 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com ([10.32.226.85]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64PGevH5028845; Mon, 25 May 2026 12:41:36 -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 v4 6/9] iio: temperature: ltc2983: Use fwnode_property_present() for optional properties Date: Mon, 25 May 2026 19:39:33 +0300 Message-ID: <20260525164013.118614-7-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525164013.118614-1-liviu.stan@analog.com> References: <20260525164013.118614-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: xuHN--WU8TcNTFglrYGpqIXrqNaaKb5a X-Proofpoint-ORIG-GUID: xuHN--WU8TcNTFglrYGpqIXrqNaaKb5a X-Authority-Analysis: v=2.4 cv=L5EtheT8 c=1 sm=1 tr=0 ts=6a147bc7 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=jYDum2LILOQkPmL8thgA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTI1MDE2OCBTYWx0ZWRfX0d97XjI8RbFG J35YbyP2Vd0Nf397XRl6F2dbGlCdPDAiH6ZDjwVuytCn7Dnzn8vGqnA3BCfFKdBQajX5L+h3Bkp Qx6hUtqJZ2XJwg+n3+PfQOfpe8kT9UOixKSIfMcoJGaFUkTVL5RWqPYpkRIOCEroFQ1R4aZW3MB 6Lt2kvXhRhXl2bKg64s7+hZFEqUVedkeFl34hnhZr+UGR88RG8ZxcycmO2a4AH4Aivd8JOJzLh3 umD8/+WozrmDKIpbzuUHhACdvJa1vSL6BXxK2ra33hVIUGpH+lb5rzCOsrQdB37Ng0YZ4GjRncq MyY8EsEPyZ5rVAmyeWP98KnUdu5idV0cfvVdUeKtMSLNVHJXMn5/XIJmG0WphJ7oCG9at5/B9R4 4987IMe5hdH5IL88Ob5jyybwhqk9mfx+IToTRL/E1tc+6JtBffE3xIncAgPwsYyXCLZ6P+NBAJy v5o1eSLuTVLtVTY32Bg== 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-25_04,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 suspectscore=0 bulkscore=0 impostorscore=0 phishscore=0 priorityscore=1501 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605250168 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 v4: - No changes 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 fc904c0a42b4..130ab7fddc2f 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -668,8 +668,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 @@ -759,8 +765,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); @@ -842,12 +852,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; @@ -878,9 +889,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; } @@ -950,17 +969,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 */ @@ -1008,6 +1023,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; @@ -1046,9 +1069,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; @@ -1069,7 +1096,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 Mon Jun 8 22:54:21 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 64DCE38228F; Mon, 25 May 2026 16:41:53 +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=1779727314; cv=none; b=e1SGvdv0rAwETz4jln8q3LdWevu6zs6Ruwy0gueAWgl0L3W0VtEZGTqO81/OwzrQWKktCIGEXyN0Oe9G/zJOqDu3CPomJvCwd3NBPQXLBchycgEhczP8qx7ta19RaR2FA5oYfXThMU7blOyb+BvaqEAt/NnEIBWLm8n9e+arj78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779727314; c=relaxed/simple; bh=cXCVjnbyfXe4ZS+Ubw3tfsLBFGAEFG5/iaWWs1CzHtM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DosndvvD0AgVMjzgny07kcwS8Ho1b8BfSg74339zUl8mEhLQjWfY8LHmYI1XTSe7ie6H9A0vmpCr/HowcTW+Qi69pgm4bxjhvMWXjbmm6c/ezMSjOFNStDm2N+bwkeEBiBiKHUqt5wEjtTov5MFvZWg5ai2iL7JkG9oZtKOrMsg= 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=QXElbpTl; 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="QXElbpTl" 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 64PB1VUB753445; Mon, 25 May 2026 12:41:50 -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=PwlEi ASrwofKlu79R8sVCzOC6cnBY3mIKS/uaMJQwZw=; b=QXElbpTlp+5GGk469AhO0 fpO/mRFVT00Gkz4nTCgWqh5tItwT4LJPPHSuSymt3K6vSMjRzQ4/TNJNXyet40Vg dUd+nm3M+sAzbqoH0nn5BrwUUappxElLyTJThrddd7WO3AJNS/MnG5wd6BziQR16 4dGSpHfYNWRfx8aJ8Jbt2D2xTYqNe8v9s/u8byv2x6MlK2IjhfLjqr37eqCeBZ18 jWYEIDz7mqNrtay0p/x3O638BkL6+8JvsxZ1KM3LYaqMM7Ap5cs4PBqjvbt4B3Mk eIMX2M59eNngxnvQwrFRFrSiZMEhq4j9vijeZuEnbAK8gmMzmyUhsqRIMySqM1z7 A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 4ecbgtavbr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 May 2026 12:41:50 -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 64PGfnLY022310 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 25 May 2026 12:41:49 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Mon, 25 May 2026 12:41:49 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Mon, 25 May 2026 12:41:49 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com ([10.32.226.85]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64PGevH6028845; Mon, 25 May 2026 12:41:41 -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 v4 7/9] iio: core: Add IIO_COVERAGE channel type Date: Mon, 25 May 2026 19:39:34 +0300 Message-ID: <20260525164013.118614-8-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525164013.118614-1-liviu.stan@analog.com> References: <20260525164013.118614-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: rYwTW4T7LklD1MCAP4vuJmV5Vmc4mvoV X-Proofpoint-ORIG-GUID: rYwTW4T7LklD1MCAP4vuJmV5Vmc4mvoV X-Authority-Analysis: v=2.4 cv=L5EtheT8 c=1 sm=1 tr=0 ts=6a147bce 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=VwQbUJbxAAAA:8 a=GHF1qUwFPqcx3V-e3LwA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTI1MDE2OCBTYWx0ZWRfX5aFCBCUiTqRb 7jVeZ/UH7Thga7JbrHwH0p2JQrBxn6tdJvt4Hkj2wPUyBiNDhbxYFuZuK6sKAZCiXLVgwaJy8Jq nBqJ3h7USq4rqm7A05sUcZwyXZ5zL2XrRYo/2VTKpU6gw+w9r/2kIkkxrzQd9iX9oXWh8bG+zIC 1IMMEvpLQ6qavXEjbaV62I2eXjZ5rEBwgC+BCFCyzMHPsnVMAcH4FcAPffuMVnh366GF2NV9y8b SsDmqejT0VmxUHazrSwAL10/DxpIowM+7PAQvEOQrtpVFtxq5g8w1FXy4wbfs++NjBUhlmcBNh8 jbxL5t7LgwZ1zCwu1ZwaFuh5ntpkHuk/GzkJizn5AInkK84y5rYN0CJIgTE3x8DwZXGa2UvALb7 eI7V+ZlJh7I+fj3zGIG72xeZEQR7irTWFQUfHCwvdlIm0h1IHIY0ZeInDlXdjRb+U6Y/ZirdVCm lWwA9QsWObWr8gufNIQ== 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-25_04,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 suspectscore=0 bulkscore=0 impostorscore=0 phishscore=0 priorityscore=1501 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605250168 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_coverageY_raw; after applying in_coverageY_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 v4: - Renamed the sysfs attribute from in_coverageX_raw to in_coverageY_raw and in_coverageX_scale to in_coverageY_scale to follow ABI convention - Updated commit message to reflect the rename 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..d8d6d85235b0 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_coverageY_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_coverageY_scale +KernelVersion: 7.2 +Contact: linux-iio@vger.kernel.org +Description: + Scale to be applied to in_coverageY_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 Mon Jun 8 22:54:21 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 317A838228F; Mon, 25 May 2026 16:41:58 +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=1779727320; cv=none; b=pJzkoWYeyJ3/Ht9m2cSesk1b/ouIU4AIu5SFrGtTS0U6U9dqVzRoj/bTPCqWIHk54ffOOzV4CEqDKauICPFNo+YYM2DclMP4764wiDvS1+pDXTAbOWXeYcjxcdsj7GGrjFNTF7veScUlephZS5RPIdt6ulr3zXyZFcX5M0FUYPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779727320; c=relaxed/simple; bh=SD+0oYnm52k4t0AIvhHHP8/nJEZ5ILKaYlXDfBjuquw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YEaOtWoQ9Dp/HX7w0nPnVpZeiWxEb/Ivolyn1dSp8f4Q4s4PTMqdX8N+pF+e8Zaxb7gDXllSF7RSqgYm/QQA4w+OksLg6riuhzvd2nlinv2SF3rk79W3RgIeEHe2OU9FbIVR3pWNb/W7szQLHTx0J4DYC8q27FLifTmIXYsrI+4= 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=u6Rr/p3P; 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="u6Rr/p3P" 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 64PEKAs93930346; Mon, 25 May 2026 12:41:56 -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=/3oSR MauE6ODmk+4ojttATSGNRuNeC+hV9G9mX9NMZE=; b=u6Rr/p3PAM8iNaJnpLYCc 5n7hbp9Tw7sN72xpPps/p4Tq0t5oi3SBBIp8/XOJSaHxNO+ecgs97Jr/srdwLlK7 a9t3OI9P+dWbpYZ8AHK0kdY0GlpG0a+vUd8BrUBQMQ4ZgiFsl5nRDotPXyA4K4c5 vEXkNCbyc3B7YmjNTFFwp2UTykzkEkL/M4u9Pl7/DMeykaJqw5pCzc2pS9QxfTfj PQCpmPBglrYKZYQLs9ckqBGk+tABx+XmkrYzdbJHrGXK/VisyBijrCSiTlI3BDmW fvdKBYvSvj9bYBuAG+9TW44QRNiTTiIQHNe47C5m8bklPm7fSF147vrPl8kBq1ho Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4eb950f9h5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 May 2026 12:41:56 -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 64PGftlJ022316 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 25 May 2026 12:41:55 -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; Mon, 25 May 2026 12:41:55 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) 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; Mon, 25 May 2026 12:41:54 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Mon, 25 May 2026 12:41:54 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com ([10.32.226.85]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64PGevH7028845; Mon, 25 May 2026 12:41:47 -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 v4 8/9] dt-bindings: iio: temperature: Add ADT7604 support to adi,ltc2983 Date: Mon, 25 May 2026 19:39:35 +0300 Message-ID: <20260525164013.118614-9-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525164013.118614-1-liviu.stan@analog.com> References: <20260525164013.118614-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: fkdaG9Zgl7KEY7QjaeHGoDtx0w6a-Tep X-Proofpoint-GUID: fkdaG9Zgl7KEY7QjaeHGoDtx0w6a-Tep X-Authority-Analysis: v=2.4 cv=TOh1jVla c=1 sm=1 tr=0 ts=6a147bd4 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=gEfo2CItAAAA:8 a=gAnH3GRIAAAA:8 a=uasTv1xkDq79D4XcAZoA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=sptkURWiP4Gy88Gu7hUp:22 a=t30qsMHlJzOsgWiHt2r7:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTI1MDE2OCBTYWx0ZWRfX10Zgk/1AC06V yjRjpGQO0WUKSt4k+KH0bAXiDCKQV/Cu3K9pb6WtWbZxwepRkGsKUbW3dr+/KGQKvWZrFuEOJnE lmE2EWu1XsvTykpA4UEa+m5nYN+dQp3n2jFIE50UBesbKJBhztP/JHzYLFj9q2IfEkJj0TeKw76 6WwVisQqQ62wbOeSkBFXLyPMqzp3H8Tk0A36U7QvF3M+4Hp1qYHOfgBxrLhR4vCQSuCK96EEGk8 O//e2sZAj4Ihpdwx4mowJNiRmX8I7UjjieF/VeK/nyXYCN0pQ/mvDo1vsQS6Z6bglpbMNwyjPqx jvyOrzfT5vYAfAWuQJ1KgC2vqPrXqHpOmQq9yKmOv21a7vEuS8FLhVJi8Q2/K74lM+W2Tcjp+xm SoV5mo5Ytvkl+QxSZfsYVI4BvTaanHRtTtF/Oy+b3pAr6Vkt2jlPq0kq3KUSWYUIQOJj1mvOgyu JUUrBiMISPtl10Prcbg== 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-25_04,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 priorityscore=1501 spamscore=0 clxscore=1015 bulkscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605250168 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 Acked-by: Conor Dooley --- Changes in v4: - Added restrictions for adi,sensor-type =3D <18> in ^rtd@ nodes and adi,sensor-type =3D <27> in ^thermistor@ nodes for adi,adt7604 .../bindings/iio/temperature/adi,ltc2983.yaml | 217 +++++++++++++++++- 1 file changed, 214 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..ab77f987ee02 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,32 @@ allOf: patternProperties: '^temp@': false =20 + - if: + properties: + compatible: + contains: + const: adi,adt7604 + then: + patternProperties: + '^thermocouple@': false + '^diode@': false + '^adc@': false + '^temp@': false + '^rtd@': + properties: + adi,sensor-type: + not: + const: 18 + '^thermistor@': + properties: + adi,sensor-type: + not: + const: 27 + else: + patternProperties: + '^copper-trace@': false + '^leak-detector@': false + examples: - | #include @@ -556,4 +702,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 Mon Jun 8 22:54:21 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 3E8E4332918; Mon, 25 May 2026 16:42:07 +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=1779727329; cv=none; b=Wd3wqckPrOJH3yIJWeq95hptI1NNLAE139lTiT/p09zPQB9pzKgmo3ktKAbmik/tVRzh6ebQvoKXCF3RjBBVbYvSqesK+L7ZpWvgCClPRUTReWFmssNMh+XaV2YdYEhxQLiYrtWW+h99BQNAw/Nh/K+Ruo6dT2FT1iaHwvrBOMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779727329; c=relaxed/simple; bh=3H1RknxvrOIot1CKc1tviDyCZOov6KvZ0AY1x6peNBI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lmXmKVAWNCeKEzrR/Hy+9tnbHjWbMnaYMs3Sp4Q67xPWhPWEgLpTXfHw8gP7IKcMAksHQ9rJ5Fb7LeGxjVBydTTJq67Nm9HkO8K4aEQ8JT0pT1hC07eMwwCUgp60tT9+Clyd9ho1qQQL4f9UCrNLzeT66oCRvgejOeBqe6q9mbc= 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=PVlBF2DO; 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="PVlBF2DO" 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 64PBKTMI753610; Mon, 25 May 2026 12:42:04 -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=1tCiH 51/oigbhPuCIb5/QtGE7Or4wLRd/7CF15yItko=; b=PVlBF2DOa6RYzjSnzBYZF EsgeFpIYkN1pI1iPpU703VNddJSsBllTbDKnrnBlGX0dAPC1CACwLlnRPE1macLS IrQQ7QNlZ6GGQOUIhwVaRTdzvuK5aAcz8c+wZ9I1RpB5OPGfLQvuzA6oll33hZ7n rQdgiu24GCL+APZTMksxJe3ZcU6l34Gm7MSBvyDQf/qbfYz5ogUWtei6TEol/PJd FgQM3bIOSP41IY0VHrIUkjeeX/Akg111g58Z4ofVyI4ArJOxA3FK/0T3uO9EB07J EreWpqJjOygXm3HDfWDG0xg9gAbSGnymjCfLGmI0i6YeNrKTudKtuECzG/8oTo5t A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 4ecbgtavc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 May 2026 12:42:03 -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 64PGg2vS022331 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 25 May 2026 12:42:02 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) 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; Mon, 25 May 2026 12:42:02 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Mon, 25 May 2026 12:42:02 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com ([10.32.226.85]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64PGevH8028845; Mon, 25 May 2026 12:41:53 -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 v4 9/9] iio: temperature: ltc2983: Add support for ADT7604 Date: Mon, 25 May 2026 19:39:36 +0300 Message-ID: <20260525164013.118614-10-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260525164013.118614-1-liviu.stan@analog.com> References: <20260525164013.118614-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: YiLnNOAJNyw3RjHe_8pj-KbXJ4Iw5f5Z X-Proofpoint-ORIG-GUID: YiLnNOAJNyw3RjHe_8pj-KbXJ4Iw5f5Z X-Authority-Analysis: v=2.4 cv=L5EtheT8 c=1 sm=1 tr=0 ts=6a147bdb cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=N--XFCr6TIEc_64PeIT2:22 a=gAnH3GRIAAAA:8 a=V-zkGJa_HyAft6zrp6AA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTI1MDE2OCBTYWx0ZWRfX5olmJNDqFmZ5 p8MxOqhB4MoLjfotRBZMquGG3m4AM31wEYsbb3HsNVyffNc8H6MArGQeJxBf9VaxT4D/tCCeddD aAxhiYAm/u3ayO1BUym2pklWqolG0SKhYEcydGymCvbxB8uHh+K2LC6ygZ3ACwi5DV9qDgxI4a7 dMSgoOmoGM7qZkGkgEUdiTAGpcT/NJRtvV84NcKsGU5ek3KQvX+3Mb7dmlov9x8H7iUsr0hlOIH /aY9a0+OLom92bBI+QYWEa3OA6kD2b97fLwU5lpxbn+bmyk+MafZzV/DlKEN2FyEnrVavBXR3Wc 8i1Fb0G3B1DFL7ZbU3MhhvSyExpIi3hzBnAQxBRfUCRFoBQkyCEmjbN59R6b632QhRMjB/xqPYc FCqLsICg44DasF7bhmzCKUSP3Ipl1dL5SvEEKXauvXoE3m9NihCkLvKI4ujc/uy069EiNdxOoWH HPsv1bkz/EPDMpzbnhg== 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-25_04,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 suspectscore=0 bulkscore=0 impostorscore=0 phishscore=0 priorityscore=1501 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605250168 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 v4: - Removed trailing comma from LTC2983_SENSOR_NUM enum sentinel - Sorted id_table, of_match, and chip_info_data structs alphabetically 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 130ab7fddc2f..fc65d8352d12 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); return regmap_bulk_write(st->regmap, reg, &st->chan_val, @@ -485,6 +541,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) @@ -578,6 +642,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) { @@ -601,6 +690,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) { @@ -1036,6 +1144,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) @@ -1204,7 +1501,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; @@ -1234,13 +1532,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; @@ -1271,7 +1579,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: @@ -1288,6 +1605,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; } @@ -1348,7 +1672,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 @@ -1376,6 +1700,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 @@ -1396,13 +1726,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", @@ -1417,6 +1748,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++; } @@ -1464,8 +1805,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 */ @@ -1512,12 +1854,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 /* @@ -1534,6 +1897,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), @@ -1672,32 +2036,42 @@ static int ltc2983_suspend(struct device *dev) static DEFINE_SIMPLE_DEV_PM_OPS(ltc2983_pm_ops, ltc2983_suspend, ltc2983_resume); =20 +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, +}; + 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), }; =20 static const struct spi_device_id ltc2983_id_table[] =3D { + { "adt7604", (kernel_ulong_t)&adt7604_chip_info_data }, { "ltc2983", (kernel_ulong_t)<c2983_chip_info_data }, { "ltc2984", (kernel_ulong_t)<c2984_chip_info_data }, { "ltc2986", (kernel_ulong_t)<c2986_chip_info_data }, @@ -1707,6 +2081,7 @@ static const struct spi_device_id ltc2983_id_table[] = =3D { MODULE_DEVICE_TABLE(spi, ltc2983_id_table); =20 static const struct of_device_id ltc2983_of_match[] =3D { + { .compatible =3D "adi,adt7604", .data =3D &adt7604_chip_info_data }, { .compatible =3D "adi,ltc2983", .data =3D <c2983_chip_info_data }, { .compatible =3D "adi,ltc2984", .data =3D <c2984_chip_info_data }, { .compatible =3D "adi,ltc2986", .data =3D <c2986_chip_info_data }, --=20 2.43.0