From nobody Fri Jun 12 13:58:28 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 C18684219E8; Thu, 14 May 2026 14:49:20 +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=1778770162; cv=none; b=NZZ4cDWdAWo6EgPJ1+j6IRCUPffiti76nsmLbGPswN8635rW4m/Lin7F/iqU45VKFgOQIae4WGjbYGBNYR6HaNVg/dJs33ugj4p1vtZL0xWwPi4w8THNvFfO6UcMg5Myr/nOWCDFLxnYUi2txgy9IqBFtDmQ/tt7Lo7RMYonAS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778770162; c=relaxed/simple; bh=Qz/boMORxlZ1KI3Pvg8gYe0+8w5uPjM0visgSbDRGWo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KY9cDZkdf5GtajqFmOKLPq/gGZjQl0edHPgnIHafemHs01IPiK0aD7IwwmhiNHoWCZT1+jSX0ZaGPAv/ug+lG6PeufEhKfeNblGXe1pWiP2e519f3S7MC4rKXKXArabxUsSNiGyFIpzDMLcenN3BKAuZcY/J6SbcnjGyP8xs3qc= 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=ihpussna; 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="ihpussna" 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 64EDgIHk2904955; Thu, 14 May 2026 10:49:17 -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=sljiz F/u5WC++Xy6pey5/xnDlH9UMAj//KiFC4SdRcs=; b=ihpussnapkceBGCSEOe7l MSIfiXiOrvhYNf/H4KmUf991yb1BYl6LQGk3I0we7zLai2Wd/5zqEn9iYa/jVyU5 gCXWQ4Nw2Ab+23xu1Fynp2W2ht+xjFb5KKSLNJiDazKQw1fI73ptfU2SLwJh4uCL u/a2+7RnY79E3Zu1p7ukkAs/0XbiqVJ+JeV+boW5VyAzTBg+3TXEhRkImQoha+H5 TsrVV1hPGGLbHfn4Vp9ZnuVAoAqxRSgCf3LOFqWqHmMFAxp0uWTae/e4KFbp1Bh4 k7/e8LLFSYAnEdFRV/F8Wtp73BVNfRRcpVrUZw6JpAgVbewsBKENZOSf/PiH86gV w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 4e4t1xvwap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 10:49:17 -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 64EEnGmE041713 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 14 May 2026 10:49:16 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Thu, 14 May 2026 10:49:16 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Thu, 14 May 2026 10:49:16 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.202]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64EEmjAY014051; Thu, 14 May 2026 10:49:09 -0400 From: Liviu Stan To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Antoniu Miclaus , Francesco Lavra , Liviu Stan , , , , Subject: [PATCH v2 1/7] iio: temperature: ltc2983: Fix macro parenthesization and rename Date: Thu, 14 May 2026 17:46:48 +0300 Message-ID: <20260514144712.64374-2-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514144712.64374-1-liviu.stan@analog.com> References: <20260514144712.64374-1-liviu.stan@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: hHbn1pxAxIwxrdjcqdeVLKpfTJGnyBi5 X-Authority-Analysis: v=2.4 cv=Wbo8rUhX c=1 sm=1 tr=0 ts=6a05e0ed 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=NK9M8l_gB6tpaUwuH9IA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE1MCBTYWx0ZWRfX7Tdd6cqd+dN3 1VLHfoA6vurbNQfEWwrtXhIpMg+e5slsJERRP6f7NQJhkOaoNFQvBGvuXrY2QNOGlVDkjTjboRS wxSzoXPsdREut0K9+qxaJOWFuDwx+9l3DXjtYy/NmfgJUciVm8R4S8oTSuTzF3YiAcGTNkmfyzu /JtrkwAGQqm0B1YKYqu6t9Jniu2UddJ8KI4XL8Wpdc6zKl02geuIsgfMoXOccOaBNItvUAH8zSH 4qhNLHTDnvRd1y2lIYN8l6H8F9AWi98vJb7hTcHLwDDhjKMCJUK8sswY1ahr3LFL+I9DNIPBjfD J7sEblTi5yseZRX1qxZmAGMZTS3sf4F5pvgNmdpM/U2JEHMeW1WTXpVE5gQn8/saEvuftY2pTcP wWk6z982SgRaaa1jbk50fPiB+yMCE5x2DD85OQGalOLIiYrk5AHnW254LiPR7Rxkv1py5wvIzgX VYVbqXrxRp4efCMsgaQ== X-Proofpoint-GUID: hHbn1pxAxIwxrdjcqdeVLKpfTJGnyBi5 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-14_03,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 spamscore=0 impostorscore=0 phishscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140150 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. Fixes: f110f3188e5639c81c457b2b831d40dfe3891bdb ("iio: temperature: Add sup= port for LTC2983") Signed-off-by: Liviu Stan --- Changes in v2: - New patch. drivers/iio/temperature/ltc2983.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index 38e6f8dfd3b8..a292274e6ff0 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, base) \ + ((((chan) - 1) * 4) + (base)) #define LTC2983_THERMOCOUPLE_DIFF_MASK BIT(3) #define LTC2983_THERMOCOUPLE_SGL(x) \ FIELD_PREP(LTC2983_THERMOCOUPLE_DIFF_MASK, x) @@ -351,7 +351,7 @@ static int __ltc2983_chan_assign_common(struct ltc2983_= data *st, const struct ltc2983_sensor *sensor, u32 chan_val) { - u32 reg =3D LTC2983_CHAN_START_ADDR(sensor->chan); + u32 reg =3D LTC2983_CHAN_ASSIGN_ADDR(sensor->chan); =20 chan_val |=3D LTC2983_CHAN_TYPE(sensor->type); dev_dbg(&st->spi->dev, "Assign reg:0x%04X, val:0x%08X\n", reg, @@ -1197,7 +1197,7 @@ static int ltc2983_chan_read(struct ltc2983_data *st, } =20 /* read the converted data */ - ret =3D regmap_bulk_read(st->regmap, LTC2983_CHAN_RES_ADDR(sensor->chan), + ret =3D regmap_bulk_read(st->regmap, LTC2983_RESULT_ADDR(sensor->chan, ba= se_reg), &st->temp, sizeof(st->temp)); if (ret) return ret; --=20 2.43.0 From nobody Fri Jun 12 13:58:28 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 25CF3410D23; Thu, 14 May 2026 14:49:26 +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=1778770169; cv=none; b=lJyrH5JYeRkcjVboStiKH4kUR/CQsTb0BHE4WPYLpooYA/grWevuCRUZelxkghcBQ4JIuIBi0ik6p1GGRxsSBjBip2Sy7ACVHbFhouJtjq6uFIx8CNXkwZaCeNdd/HO2Mom0ADMqJADaxG278cXSy9wpMHPFR2YRzoVFCVBeDeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778770169; c=relaxed/simple; bh=duDgURhAN5oYYVXUrhfRVinD8NPfPQY0Y6yQ8n4x5f4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YILewbt/R+yHiJik5qlEGLyjmo5dQ14dnjviGmoEgmKM0Drgqhy4eyOfFwhTTzQ51EbQRa76E7bE420RbVj9fU05bCtrOMXoYNb+Bx1wsl9haoJQRM2muLce89jIi8qUI8Y9AZMmctWQgeHfJ9TRet6bEANUtwDS8JoSdA8pMsg= 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=kbSRf13f; 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="kbSRf13f" 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 64ECGVbM1715006; Thu, 14 May 2026 10:49: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=74tKB mROut+RkvXALnxp1TLYvm/iDa0vljBZ6eq/b2Y=; b=kbSRf13fg3uXERaT2lj7D QvdD8h6AkTJqfPOvn+xle5DcjQuIgYWm3XyJvQLPA0hnCweAHUqBYWnVEWMpwycF nxIaAV3pVJriaczdYcPjDRG9TKZWM0IkXM4bVRhS8DjjG+K0oNarTMt29mMh1C7u 5spoOZ0EWLtZdvMxoK9a9zqywGJKrK8Ncg33Mkm0/DranYN3MaMFNjLbwa2GPrva hCb+S2xO4O30cCa5GDyq9tPK7mMymmfUqxoQYqaMu97elECPwUF0zcIqhEjE6rej 9Mz8TChnN/bx2AX3EnkqIuVps03EKUMswbI1PcK77vP8eU3oLcVmZ9VzlFknuUYg A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4e54xgtj3d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 10:49: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 64EEnMaM041725 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 14 May 2026 10:49:22 -0400 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Thu, 14 May 2026 10:49:22 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Thu, 14 May 2026 10:49:22 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Thu, 14 May 2026 10:49:22 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.202]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64EEmjAZ014051; Thu, 14 May 2026 10:49:13 -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 v2 2/7] iio: temperature: ltc2983: Use local device pointer consistently Date: Thu, 14 May 2026 17:46:49 +0300 Message-ID: <20260514144712.64374-3-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514144712.64374-1-liviu.stan@analog.com> References: <20260514144712.64374-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: AW1haW4tMjYwNTE0MDE1MCBTYWx0ZWRfX5mg6ER8c8QMp r/7ZPu378u0hM+RUHT14nSG3GeCbO4RhWTZR4xsJbM8Z25TvuME9UMnGnCLyC11AxPsISxGkJnv /PEvaP7j35AsqdmTIFB2Qa8QZIZWvDI0xKfJFI6FGpvudqjA1TWX5ePsHYAjiZ+NSKfH8PpOId1 GfTvyBu6aED03cEjSTt9ceUzyG86LERQPbX5nZovVxV9zgZZ/jZiBxfJKhGr9Nrvmo2hBVgowoR uutFMezw0GeKrzZ2aAuLvI7iHxuO0w5YkKy47IUGRqDPma6sAxsa6Gyvc6c+b83p/DlAGaDJbHT 8tTWc24O+53lQzogknHonAGydtISqgnX5wt6c+S9qEkcD6Jhf5/lbGLWE/F9hcH2MSsPkEudFmm yuOFpXgRxQGneiU9dQHwwqyPz6g97A9I9Zvsgey/f7DqfMShCYPnMcWYWxYNcj6QdZ2WcGCeoDW crGc+KcLuWsQB1aJUJw== X-Proofpoint-GUID: 4K-92xfRaS2XruBbJ6hYatoQxJf-DVL5 X-Proofpoint-ORIG-GUID: 4K-92xfRaS2XruBbJ6hYatoQxJf-DVL5 X-Authority-Analysis: v=2.4 cv=MMFQXsZl c=1 sm=1 tr=0 ts=6a05e0f3 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=uXIjobp8t2wMuQ0fPvqm:22 a=gAnH3GRIAAAA:8 a=yv4WWxIh8xz3Wh6Jmy8A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-14_03,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 spamscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 suspectscore=0 bulkscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140150 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 all bare references with the local pointer for consistency. Fixes: f110f3188e5639c81c457b2b831d40dfe3891bdb ("iio: temperature: Add sup= port for LTC2983") Signed-off-by: Liviu Stan --- Changes in v2: - New patch. drivers/iio/temperature/ltc2983.c | 81 ++++++++++++++++++------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index a292274e6ff0..e74ea4f87ec9 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -351,6 +351,7 @@ static int __ltc2983_chan_assign_common(struct ltc2983_= 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); @@ -656,11 +657,12 @@ static struct ltc2983_sensor * ltc2983_thermocouple_new(const struct fwnode_handle *child, struct ltc2983= _data *st, const struct ltc2983_sensor *sensor) { + struct device *dev =3D &st->spi->dev; struct ltc2983_thermocouple *thermo; u32 oc_current; int ret; =20 - thermo =3D devm_kzalloc(&st->spi->dev, sizeof(*thermo), GFP_KERNEL); + thermo =3D devm_kzalloc(dev, sizeof(*thermo), GFP_KERNEL); if (!thermo) return ERR_PTR(-ENOMEM); =20 @@ -687,7 +689,7 @@ ltc2983_thermocouple_new(const struct fwnode_handle *ch= ild, struct ltc2983_data LTC2983_THERMOCOUPLE_OC_CURR(3); break; default: - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid open circuit current:%u\n", oc_current); } @@ -697,7 +699,7 @@ ltc2983_thermocouple_new(const struct fwnode_handle *ch= ild, struct ltc2983_data /* validate channel index */ if (!(thermo->sensor_config & LTC2983_THERMOCOUPLE_DIFF_MASK) && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chann:%d for differential thermocouple\n", sensor->chan); =20 @@ -712,7 +714,7 @@ ltc2983_thermocouple_new(const struct fwnode_handle *ch= ild, struct ltc2983_data * This would be caught later but we can just return * the error right away. */ - return dev_err_ptr_probe(&st->spi->dev, ret, + return dev_err_ptr_probe(dev, ret, "Property reg must be given\n"); } =20 @@ -823,7 +825,7 @@ ltc2983_rtd_new(const struct fwnode_handle *child, stru= ct ltc2983_data *st, } else { /* same as differential case */ if (sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chann:%d for RTD\n", sensor->chan); } @@ -873,7 +875,7 @@ ltc2983_rtd_new(const struct fwnode_handle *child, stru= ct ltc2983_data *st, rtd->excitation_current =3D 0x08; break; default: - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid value for excitation current(%u)\n", excitation_current); } @@ -922,7 +924,7 @@ ltc2983_thermistor_new(const struct fwnode_handle *chil= d, struct ltc2983_data *s /* validate channel index */ if (!(thermistor->sensor_config & LTC2983_THERMISTOR_DIFF_MASK) && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chann:%d for differential thermistor\n", sensor->chan); =20 @@ -964,7 +966,7 @@ ltc2983_thermistor_new(const struct fwnode_handle *chil= d, struct ltc2983_data *s case 0: /* auto range */ if (sensor->type >=3D LTC2983_SENSOR_THERMISTOR_STEINHART) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Auto Range not allowed for custom sensors\n"); =20 thermistor->excitation_current =3D 0x0c; @@ -1003,7 +1005,7 @@ ltc2983_thermistor_new(const struct fwnode_handle *ch= ild, struct ltc2983_data *s thermistor->excitation_current =3D 0x0b; break; default: - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid value for excitation current(%u)\n", excitation_current); } @@ -1016,11 +1018,12 @@ static struct ltc2983_sensor * ltc2983_diode_new(const struct fwnode_handle *child, const struct ltc2983_= data *st, const struct ltc2983_sensor *sensor) { + struct device *dev =3D &st->spi->dev; struct ltc2983_diode *diode; u32 temp =3D 0, excitation_current =3D 0; int ret; =20 - diode =3D devm_kzalloc(&st->spi->dev, sizeof(*diode), GFP_KERNEL); + diode =3D devm_kzalloc(dev, sizeof(*diode), GFP_KERNEL); if (!diode) return ERR_PTR(-ENOMEM); =20 @@ -1036,7 +1039,7 @@ ltc2983_diode_new(const struct fwnode_handle *child, = const struct ltc2983_data * /* validate channel index */ if (!(diode->sensor_config & LTC2983_DIODE_DIFF_MASK) && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chann:%d for differential thermistor\n", sensor->chan); =20 @@ -1061,7 +1064,7 @@ ltc2983_diode_new(const struct fwnode_handle *child, = const struct ltc2983_data * diode->excitation_current =3D 0x03; break; default: - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid value for excitation current(%u)\n", excitation_current); } @@ -1079,23 +1082,24 @@ static struct ltc2983_sensor *ltc2983_r_sense_new(s= truct fwnode_handle *child, struct ltc2983_data *st, const struct ltc2983_sensor *sensor) { + struct device *dev =3D &st->spi->dev; struct ltc2983_rsense *rsense; int ret; u32 temp; =20 - rsense =3D devm_kzalloc(&st->spi->dev, sizeof(*rsense), GFP_KERNEL); + rsense =3D devm_kzalloc(dev, sizeof(*rsense), GFP_KERNEL); if (!rsense) return ERR_PTR(-ENOMEM); =20 /* validate channel index */ if (sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chann:%d for r_sense\n", sensor->chan); =20 ret =3D fwnode_property_read_u32(child, "adi,rsense-val-milli-ohms", &tem= p); if (ret) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Property adi,rsense-val-milli-ohms missing\n"); /* * Times 1000 because we have milli-ohms and __convert_to_raw @@ -1115,9 +1119,10 @@ static struct ltc2983_sensor *ltc2983_adc_new(struct= fwnode_handle *child, struct ltc2983_data *st, const struct ltc2983_sensor *sensor) { + struct device *dev =3D &st->spi->dev; struct ltc2983_adc *adc; =20 - adc =3D devm_kzalloc(&st->spi->dev, sizeof(*adc), GFP_KERNEL); + adc =3D devm_kzalloc(dev, sizeof(*adc), GFP_KERNEL); if (!adc) return ERR_PTR(-ENOMEM); =20 @@ -1125,7 +1130,7 @@ static struct ltc2983_sensor *ltc2983_adc_new(struct = fwnode_handle *child, adc->single_ended =3D true; =20 if (!adc->single_ended && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chan:%d for differential adc\n", sensor->chan); =20 @@ -1140,9 +1145,10 @@ static struct ltc2983_sensor *ltc2983_temp_new(struc= t fwnode_handle *child, struct ltc2983_data *st, const struct ltc2983_sensor *sensor) { + struct device *dev =3D &st->spi->dev; struct ltc2983_temp *temp; =20 - temp =3D devm_kzalloc(&st->spi->dev, sizeof(*temp), GFP_KERNEL); + temp =3D devm_kzalloc(dev, sizeof(*temp), GFP_KERNEL); if (!temp) return ERR_PTR(-ENOMEM); =20 @@ -1150,7 +1156,7 @@ static struct ltc2983_sensor *ltc2983_temp_new(struct= fwnode_handle *child, temp->single_ended =3D true; =20 if (!temp->single_ended && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) - return dev_err_ptr_probe(&st->spi->dev, -EINVAL, + return dev_err_ptr_probe(dev, -EINVAL, "Invalid chan:%d for differential temp\n", sensor->chan); =20 @@ -1169,13 +1175,14 @@ static struct ltc2983_sensor *ltc2983_temp_new(stru= ct fwnode_handle *child, static int ltc2983_chan_read(struct ltc2983_data *st, const struct ltc2983_sensor *sensor, int *val) { + struct device *dev =3D &st->spi->dev; u32 start_conversion =3D 0; int ret; unsigned long time; =20 start_conversion =3D LTC2983_STATUS_START(true); start_conversion |=3D LTC2983_STATUS_CHAN_SEL(sensor->chan); - dev_dbg(&st->spi->dev, "Start conversion on chan:%d, status:%02X\n", + dev_dbg(dev, "Start conversion on chan:%d, status:%02X\n", sensor->chan, start_conversion); /* start conversion */ ret =3D regmap_write(st->regmap, LTC2983_STATUS_REG, start_conversion); @@ -1192,7 +1199,7 @@ static int ltc2983_chan_read(struct ltc2983_data *st, time =3D wait_for_completion_timeout(&st->completion, msecs_to_jiffies(300)); if (!time) { - dev_warn(&st->spi->dev, "Conversion timed out\n"); + dev_warn(dev, "Conversion timed out\n"); return -ETIMEDOUT; } =20 @@ -1205,7 +1212,7 @@ static int ltc2983_chan_read(struct ltc2983_data *st, *val =3D __be32_to_cpu(st->temp); =20 if (!(LTC2983_RES_VALID_MASK & *val)) { - dev_err(&st->spi->dev, "Invalid conversion detected\n"); + dev_err(dev, "Invalid conversion detected\n"); return -EIO; } =20 @@ -1222,11 +1229,12 @@ static int ltc2983_read_raw(struct iio_dev *indio_d= ev, int *val, int *val2, long mask) { struct ltc2983_data *st =3D iio_priv(indio_dev); + struct device *dev =3D &st->spi->dev; int ret; =20 /* sanity check */ if (chan->address >=3D st->num_channels) { - dev_err(&st->spi->dev, "Invalid chan address:%ld", + dev_err(dev, "Invalid chan address:%ld", chan->address); return -EINVAL; } @@ -1303,7 +1311,7 @@ static int ltc2983_parse_fw(struct ltc2983_data *st) =20 st->num_channels =3D device_get_child_node_count(dev); if (!st->num_channels) - return dev_err_probe(&st->spi->dev, -EINVAL, + return dev_err_probe(dev, -EINVAL, "At least one channel must be given!\n"); =20 st->sensors =3D devm_kcalloc(dev, st->num_channels, sizeof(*st->sensors), @@ -1391,6 +1399,7 @@ static int ltc2983_eeprom_cmd(struct ltc2983_data *st= , unsigned int cmd, unsigned int wait_time, unsigned int status_reg, unsigned long status_fail_mask) { + struct device *dev =3D &st->spi->dev; unsigned long time; unsigned int val; int ret; @@ -1410,7 +1419,7 @@ static int ltc2983_eeprom_cmd(struct ltc2983_data *st= , unsigned int cmd, time =3D wait_for_completion_timeout(&st->completion, msecs_to_jiffies(wait_time)); if (!time) - return dev_err_probe(&st->spi->dev, -ETIMEDOUT, + return dev_err_probe(dev, -ETIMEDOUT, "EEPROM command timed out\n"); =20 ret =3D regmap_read(st->regmap, status_reg, &val); @@ -1418,7 +1427,7 @@ static int ltc2983_eeprom_cmd(struct ltc2983_data *st= , unsigned int cmd, return ret; =20 if (val & status_fail_mask) - return dev_err_probe(&st->spi->dev, -EINVAL, + return dev_err_probe(dev, -EINVAL, "EEPROM command failed: 0x%02X\n", val); =20 return 0; @@ -1427,6 +1436,7 @@ static int ltc2983_eeprom_cmd(struct ltc2983_data *st= , unsigned int cmd, static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio) { u32 iio_chan_t =3D 0, iio_chan_v =3D 0, chan, iio_idx =3D 0, status; + struct device *dev =3D &st->spi->dev; int ret; =20 /* make sure the device is up: start bit (7) is 0 and done bit (6) is 1 */ @@ -1434,7 +1444,7 @@ static int ltc2983_setup(struct ltc2983_data *st, boo= l assign_iio) LTC2983_STATUS_UP(status) =3D=3D 1, 25000, 25000 * 10); if (ret) - return dev_err_probe(&st->spi->dev, ret, + return dev_err_probe(dev, ret, "Device startup timed out\n"); =20 ret =3D regmap_update_bits(st->regmap, LTC2983_GLOBAL_CONFIG_REG, @@ -1535,12 +1545,13 @@ static const struct iio_info ltc2983_iio_info =3D { =20 static int ltc2983_probe(struct spi_device *spi) { + struct device *dev =3D &spi->dev; struct ltc2983_data *st; struct iio_dev *indio_dev; struct gpio_desc *gpio; int ret; =20 - indio_dev =3D devm_iio_device_alloc(&spi->dev, sizeof(*st)); + indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; =20 @@ -1552,7 +1563,7 @@ static int ltc2983_probe(struct spi_device *spi) =20 st->regmap =3D devm_regmap_init_spi(spi, <c2983_regmap_config); if (IS_ERR(st->regmap)) - return dev_err_probe(&spi->dev, PTR_ERR(st->regmap), + return dev_err_probe(dev, PTR_ERR(st->regmap), "Failed to initialize regmap\n"); =20 mutex_init(&st->lock); @@ -1565,11 +1576,11 @@ static int ltc2983_probe(struct spi_device *spi) if (ret) return ret; =20 - ret =3D devm_regulator_get_enable(&spi->dev, "vdd"); + ret =3D devm_regulator_get_enable(dev, "vdd"); if (ret) return ret; =20 - gpio =3D devm_gpiod_get_optional(&st->spi->dev, "reset", GPIOD_OUT_HIGH); + gpio =3D devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(gpio)) return PTR_ERR(gpio); =20 @@ -1579,7 +1590,7 @@ static int ltc2983_probe(struct spi_device *spi) gpiod_set_value_cansleep(gpio, 0); } =20 - st->iio_chan =3D devm_kzalloc(&spi->dev, + st->iio_chan =3D devm_kzalloc(dev, st->iio_channels * sizeof(*st->iio_chan), GFP_KERNEL); if (!st->iio_chan) @@ -1589,10 +1600,10 @@ static int ltc2983_probe(struct spi_device *spi) if (ret) return ret; =20 - ret =3D devm_request_irq(&spi->dev, spi->irq, ltc2983_irq_handler, + ret =3D devm_request_irq(dev, spi->irq, ltc2983_irq_handler, IRQF_TRIGGER_RISING, st->info->name, st); if (ret) - return dev_err_probe(&spi->dev, ret, + return dev_err_probe(dev, ret, "failed to request an irq\n"); =20 if (st->info->has_eeprom) { @@ -1610,7 +1621,7 @@ static int ltc2983_probe(struct spi_device *spi) indio_dev->modes =3D INDIO_DIRECT_MODE; indio_dev->info =3D <c2983_iio_info; =20 - return devm_iio_device_register(&spi->dev, indio_dev); + return devm_iio_device_register(dev, indio_dev); } =20 static int ltc2983_resume(struct device *dev) --=20 2.43.0 From nobody Fri Jun 12 13:58:28 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 7259C3955F4; Thu, 14 May 2026 14:49:30 +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=1778770172; cv=none; b=X4dZ5GTPcj3iJema5iY89nBS6jhdSReh9XQiieoFyYlNsu5ApeHv4Y61HhCQq0TPcEY+R+uWeYXiOtNJ+aOt5dbCyzCjmk21dZ262x/XQaKmGi/auhzilWbcn48SbVNoT4sVU4/P2wcpZgqNHHD4KHsb807HfFqS+9qDM3TfcUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778770172; c=relaxed/simple; bh=dIGR54g+j/9yoCqVw2BlXyFlQd0JBTGgLT5LEFMHCCs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mZKRtFBS57B7WKfMcvodlU0ZvnkmUHrry3vXmrcKuNCDgsaXpRQ1gNxjUXSZmPS1km9OpF5/aO0ZK7kORUJ6WwLRvxqp/qp3TfNscVNzRjD6DSG81dXrNAs7xtbXaT/B72u2VHEwhp+IQBg/XlNOe6t1w9MbqnF2XvpxEKVWCO4= 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=nR8wzgMN; 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="nR8wzgMN" 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 64EE2VrN2905295; Thu, 14 May 2026 10:49:27 -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=IYoon QSyJ+0IlGtHVpgFXc+0gu5zJqKJ93oSnh/aYLs=; b=nR8wzgMNq328zAF33A3MN 44KK+U/jtv9hrWG7lgCB06JModNBwRMFYDIM5PFE/zSdpSQx54rS7CN77pPRW2KN royuu51TugkL5UKLcK+IDERcmYyvyJ/bhVp3vub4qc6UMTRDZKyPrVXEq31jKr4D cjZDH0jIzv2uZxFapWvU050S91p02Hj6WrIbkqadoPwM2nr6g/2frOCnzmRcrkvI Z34PKK86EbwZjEZWxii9fi44PZHUS4mgzFHVAqtH3HjCEXXT0s1aAMRNVPWRyP+Y NQ64wZeIbB5W558Xf74hkaF1do9L/jc42Mi0ITIYjR4HjJ44o8o9QslL/t3R+hZY A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 4e4t1xvwbb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 10:49:27 -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 64EEnQbm041731 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 14 May 2026 10:49:26 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Thu, 14 May 2026 10:49:26 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Thu, 14 May 2026 10:49:26 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.202]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64EEmjAa014051; Thu, 14 May 2026 10:49: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 , Liviu Stan , Francesco Lavra , , , , Subject: [PATCH v2 3/7] iio: temperature: ltc2983: Fix inconsistent channel wording in messages Date: Thu, 14 May 2026 17:46:50 +0300 Message-ID: <20260514144712.64374-4-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514144712.64374-1-liviu.stan@analog.com> References: <20260514144712.64374-1-liviu.stan@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: ie4FAFkXJBVlzenKnbOmK5Nh5CJBFrJn X-Authority-Analysis: v=2.4 cv=Wbo8rUhX c=1 sm=1 tr=0 ts=6a05e0f7 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=ns7QdhbT8QDaN8w0EOgA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE1MCBTYWx0ZWRfXyFNwQ2afk3Co GZr3V580ZudqjCWrw9HiBl7Ojvb5s2wYt1DL7K3JJ0SpjldJcvdTc9b2uGXmfK2pjMmlkgf7PrJ Kb4oWPSQ20XpFazNCKp7wpENQa90IxJokUD0UhI9Qz9zdrGrwOO0M9vuSfd8Pkwxl8DYBDkLrPh fM7tOaPMaBWoGrjXhtRHHk4Xyg61uOv8fehjWxzoerMIVg+V9Oe1kGomPcJj1z8fUcRrxR9zSLJ xrpk0g15PrKsrfMFmT3SvzWSTfJ9htaqCviCJqJBO+QOIAiutL8CJT/2HvMh16J9FmhFsHdECUX CeF5Ye6tdNuTf4q+efQHAOHnYEGqXZB4VxOeAN+NfskT+rvLfnRG2lVKJiLL5iD6n4r/xU4icfV aUbA+01l96ihBZOY5WV5LB+Rswa7IuySiGIjpsJ4Q4DB9OZZcJKvwPa59JqNAYWD6NCtZlQQBVF GVDsX8mnjCjABuDi1cg== X-Proofpoint-GUID: ie4FAFkXJBVlzenKnbOmK5Nh5CJBFrJn 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-14_03,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 spamscore=0 impostorscore=0 phishscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140150 Content-Type: text/plain; charset="utf-8" Replace all occurrences of the abbreviated 'chann' and 'chan' with 'channel' in error and debug messages throughout the driver. Fixes: f110f3188e5639c81c457b2b831d40dfe3891bdb ("iio: temperature: Add sup= port for LTC2983") Fixes: a00838cae079b9b9b90969c2b7b031b1bfd9ab3a ("iio: temperature: ltc2983= : convert to dev_err_probe()") Signed-off-by: Liviu Stan --- Changes in v2: - New patch. drivers/iio/temperature/ltc2983.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index e74ea4f87ec9..f42777c1f3c2 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -700,7 +700,7 @@ ltc2983_thermocouple_new(const struct fwnode_handle *ch= ild, struct ltc2983_data if (!(thermo->sensor_config & LTC2983_THERMOCOUPLE_DIFF_MASK) && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chann:%d for differential thermocouple\n", + "Invalid channel %d for differential thermocouple\n", sensor->chan); =20 struct fwnode_handle *ref __free(fwnode_handle) =3D @@ -798,7 +798,7 @@ ltc2983_rtd_new(const struct fwnode_handle *child, stru= ct ltc2983_data *st, /* * rtd channel indexes are a bit more complicated to validate. * For 4wire RTD with rotation, the channel selection cannot be - * >=3D19 since the chann + 1 is used in this configuration. + * >=3D19 since the channel + 1 is used in this configuration. * For 4wire RTDs with kelvin rsense, the rsense channel cannot be * <=3D1 since channel - 1 and channel - 2 are used. */ @@ -815,18 +815,18 @@ ltc2983_rtd_new(const struct fwnode_handle *child, st= ruct ltc2983_data *st, (rtd->r_sense_chan <=3D min)) /* kelvin rsense*/ return dev_err_ptr_probe(dev, -EINVAL, - "Invalid rsense chann:%d to use in kelvin rsense\n", + "Invalid channel %d for kelvin rsense\n", rtd->r_sense_chan); =20 if (sensor->chan < min || sensor->chan > max) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chann:%d for the rtd config\n", + "Invalid channel %d for RTD config\n", sensor->chan); } else { /* same as differential case */ if (sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chann:%d for RTD\n", + "Invalid channel %d for RTD\n", sensor->chan); } =20 @@ -925,7 +925,7 @@ ltc2983_thermistor_new(const struct fwnode_handle *chil= d, struct ltc2983_data *s if (!(thermistor->sensor_config & LTC2983_THERMISTOR_DIFF_MASK) && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chann:%d for differential thermistor\n", + "Invalid channel %d for differential thermistor\n", sensor->chan); =20 /* check custom sensor */ @@ -1040,7 +1040,7 @@ ltc2983_diode_new(const struct fwnode_handle *child, = const struct ltc2983_data * if (!(diode->sensor_config & LTC2983_DIODE_DIFF_MASK) && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chann:%d for differential thermistor\n", + "Invalid channel %d for differential thermistor\n", sensor->chan); =20 /* set common parameters */ @@ -1094,7 +1094,7 @@ static struct ltc2983_sensor *ltc2983_r_sense_new(str= uct fwnode_handle *child, /* validate channel index */ if (sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chann:%d for r_sense\n", + "Invalid channel %d for r_sense\n", sensor->chan); =20 ret =3D fwnode_property_read_u32(child, "adi,rsense-val-milli-ohms", &tem= p); @@ -1131,7 +1131,7 @@ static struct ltc2983_sensor *ltc2983_adc_new(struct = fwnode_handle *child, =20 if (!adc->single_ended && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chan:%d for differential adc\n", + "Invalid channel %d for differential ADC\n", sensor->chan); =20 /* set common parameters */ @@ -1157,7 +1157,7 @@ static struct ltc2983_sensor *ltc2983_temp_new(struct= fwnode_handle *child, =20 if (!temp->single_ended && sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN) return dev_err_ptr_probe(dev, -EINVAL, - "Invalid chan:%d for differential temp\n", + "Invalid channel %d for differential temp\n", sensor->chan); =20 temp->custom =3D __ltc2983_custom_sensor_new(st, child, "adi,custom-temp", @@ -1182,7 +1182,7 @@ static int ltc2983_chan_read(struct ltc2983_data *st, =20 start_conversion =3D LTC2983_STATUS_START(true); start_conversion |=3D LTC2983_STATUS_CHAN_SEL(sensor->chan); - dev_dbg(dev, "Start conversion on chan:%d, status:%02X\n", + dev_dbg(dev, "Start conversion on channel:%d, status:%02X\n", sensor->chan, start_conversion); /* start conversion */ ret =3D regmap_write(st->regmap, LTC2983_STATUS_REG, start_conversion); @@ -1234,7 +1234,7 @@ static int ltc2983_read_raw(struct iio_dev *indio_dev, =20 /* sanity check */ if (chan->address >=3D st->num_channels) { - dev_err(dev, "Invalid chan address:%ld", + dev_err(dev, "Invalid channel address: %ld\n", chan->address); return -EINVAL; } --=20 2.43.0 From nobody Fri Jun 12 13:58:28 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 0AE0E423165; Thu, 14 May 2026 14:49:32 +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=1778770174; cv=none; b=EluK9c1T6DhbaJMMbUQg5p6CZY8tDc+34kVyy9JQTmqxam63HRFqEktoVlaPLuqxcitwq4RoCTYqp852jrRt0n2ftFzRwSn0/28BDfsgPEv4iFN1aylSkiLncGy+aFnH53r5nsuQSYcKj79Tf7UCuZlbCN/XBEr1v5x/m2wqHa8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778770174; c=relaxed/simple; bh=CmySF8OIktTFikW7ESRHWnlGhBvyzZUhf3Nml0FqDaE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Fic5Vr4ckY+BXOm17/9wi2BUHSn5hv7TpCUvmlyAuI0Futt29W3bCacuR+Pk9jy8YZvpx49I16evoEzNo/dvbjzJU7nl8Pdk7Zf4++XK5XhNhOWT58D68mROCFg3nlBQywFrsbz56mdwZg1rMKe6120svXNjc2dIN2Ol6FtlMgk= 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=LKywOuQ5; 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="LKywOuQ5" 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 64ED0aeZ1714990; Thu, 14 May 2026 10:49:30 -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=uL2Xs S9P02fsmG4qiSfp1w8XJbwFYe73+oRLPk88/pU=; b=LKywOuQ5hJvEG4h2KiNTl eEQxmgt0gjKAyeiMuMdKhwAgfVFFgnSbJSdOvT8vcGAoH79PuM0szXlkt1R+mGWa AyzCoYZhWouoyFrGINRTk+G8866+j6RD0cUqoY9xyTw5uywYO3A0XQVeT3yV/HIy OG2fzLN8CN0rumcgKT+961qMiGjS5dhgpKbDfujgoloOcUWP0w3VlDFYX5MY+VNw mO9J+dDUblZOuRO5yKYFuUgOoSDbH4SAmMxE+xxFzTvNGSMGpuM8roELDzODOZEM 4pZ25/AC1H9lJoKmCF9QrxHEqscgRUygczxOdsI5VvAqKQSmgWmPkzOD1O7kzV6Z A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4e54xgtj3u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 10:49:29 -0400 (EDT) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 64EEnSwc041737 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 14 May 2026 10:49:28 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Thu, 14 May 2026 10:49:28 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Thu, 14 May 2026 10:49:28 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Thu, 14 May 2026 10:49:28 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.202]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64EEmjAb014051; Thu, 14 May 2026 10:49:21 -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 v2 4/7] iio: temperature: ltc2983: Use fwnode_property_present() for optional properties Date: Thu, 14 May 2026 17:46:51 +0300 Message-ID: <20260514144712.64374-5-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514144712.64374-1-liviu.stan@analog.com> References: <20260514144712.64374-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: AW1haW4tMjYwNTE0MDE1MCBTYWx0ZWRfX3jVY58Rv7lUP d4MaglooeIilaZNigsgSUjiS09nNXX8aWEprgYoFeTJaxpDz2hMAYpIAb8kF9ySm0N91xt3P6Rz LfdjAVVGYr/SHHOpNjbIzb97JMr9qUTv9YAWWvna38qPqUD9yTWuYmGZ9BBcntquu7V2vv4YMMB Djr82g+sPZ4jEGuztvElv8ZXVVaLMaxoI8iF44rMZS7F6N+91w4AOQVWefDMki09ruLACrPsWUb z0Mna5cv7Sx4o4VOnPQgkmB93kNeuIG4gViAT6CO0huDpqodvEv6cWkbuAmPkAUO9Yns8qy3th+ KHETC0DpesxzjttbtZF5I8XS2ZuoaPb4w1kKjsrA3i734xsqrXJiuvFfS1abPCK/pI1pLd2YQsH HTcCa/k4KyeplVcBh3KJlXH5Fu5QYxMDJQF2jU4m16scfJL2jzvqLuLNQB9b0MIRiCIWexqYXVt 0DY6S+HyY9oneuGbbWA== X-Proofpoint-GUID: DKhB2dHvskD5AA1gNShxDjxRjOTx3o-S X-Proofpoint-ORIG-GUID: DKhB2dHvskD5AA1gNShxDjxRjOTx3o-S X-Authority-Analysis: v=2.4 cv=MMFQXsZl c=1 sm=1 tr=0 ts=6a05e0f9 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=uXIjobp8t2wMuQ0fPvqm:22 a=gAnH3GRIAAAA:8 a=anXMOi7fFe8hw7OE3YUA: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-14_03,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 spamscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 suspectscore=0 bulkscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140150 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. Fixes: f110f3188e5639c81c457b2b831d40dfe3891bdb ("iio: temperature: Add sup= port for LTC2983") Signed-off-by: Liviu Stan --- Changes in v2: - New patch. drivers/iio/temperature/ltc2983.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index f42777c1f3c2..bf435e965c6d 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -669,8 +669,14 @@ ltc2983_thermocouple_new(const struct fwnode_handle *c= hild, struct ltc2983_data if (fwnode_property_read_bool(child, "adi,single-ended")) thermo->sensor_config =3D LTC2983_THERMOCOUPLE_SGL(1); =20 - ret =3D fwnode_property_read_u32(child, "adi,sensor-oc-current-microamp",= &oc_current); - if (!ret) { + if (fwnode_property_present(child, "adi,sensor-oc-current-microamp")) { + ret =3D fwnode_property_read_u32(child, + "adi,sensor-oc-current-microamp", + &oc_current); + if (ret) + return dev_err_ptr_probe(dev, ret, + "Failed to read adi,sensor-oc-current-microamp\n"); + switch (oc_current) { case 10: thermo->sensor_config |=3D @@ -760,8 +766,12 @@ ltc2983_rtd_new(const struct fwnode_handle *child, str= uct ltc2983_data *st, return dev_err_ptr_probe(dev, ret, "Property reg must be given\n"); =20 - ret =3D fwnode_property_read_u32(child, "adi,number-of-wires", &n_wires); - if (!ret) { + if (fwnode_property_present(child, "adi,number-of-wires")) { + ret =3D fwnode_property_read_u32(child, "adi,number-of-wires", &n_wires); + if (ret) + return dev_err_ptr_probe(dev, ret, + "Failed to read adi,number-of-wires\n"); + switch (n_wires) { case 2: rtd->sensor_config =3D LTC2983_RTD_N_WIRES(0); --=20 2.43.0 From nobody Fri Jun 12 13:58:28 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 A2A69428466; Thu, 14 May 2026 14:49: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=1778770178; cv=none; b=VhGWERFhudeDOzh12OQzSnEUu1B4fxnBfWf906Ea9wmJVR3P3TXJFBXJlzoWChNq9HkiFqOh1FlV3VU7tBd86R9JQfvk9Ij1/XAY7I96EHqgiZwu4k4uh6aQDdjTelBh9gOegnlJguPggIAlw8gW+50ivrwEFIUd77YkJEboOCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778770178; c=relaxed/simple; bh=0TuhVxB7/xPmMhg1SqRR9zFlXJBycwAnu6/HE8v3rwc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g3m7iy9ajGgUzABXCkUeq2TbW6f2ZdLGRCuO3HU+hYB8aD20e5L+Yak8kG4VGofnqge3/I69tqJUroilMzufzA8oSG2GgiukIqg3AAjofMBw3gafBaMagnhIo5PrWUBO6KCPWMIjMBw+rjaE7JocGuQgS+gBqV9ttfa5AwXHuiU= 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=GnFMo0wa; 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="GnFMo0wa" 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 64EDgIHn2904955; Thu, 14 May 2026 10:49:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=qD8kP qKi7OObWJCQ1wBXR9VmgTR0BQr5v6X54K070lI=; b=GnFMo0waU4pIc8IEoyH1T iWNAx1YIIN4O0CD00nMu1BjdS41m67bVYDphrr69gRPgvM+IfBDrbo4ovvTdP4mK m3UdC0oAqrvamhsSY0inDP79NWvW6cYgOqTfvdJezCYOIZFxKGo395lmWSljP9Jf a1qVUWmOetdUxW9E7cJSja/10G1ISTCW3RLvBQGlNIeZBWYq1bMlk5s7iP8qA7zy Xo9ix7mvdXvLZg/UebaBBew9zOnziaticLW6m8B9uhIOjuRDFcnaGNjlwf7Z3Trv oeLTab0OdwL8aEgaUebhNO3V2bwKXfBfdhiYxByPOWYpD5/H4XcntJm1M1lFadq3 A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 4e4t1xvwbs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 10:49: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 64EEnWMv041749 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 14 May 2026 10:49:32 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Thu, 14 May 2026 10:49:32 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Thu, 14 May 2026 10:49:32 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.202]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64EEmjAc014051; Thu, 14 May 2026 10:49:25 -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 v2 5/7] iio: core: Add IIO_COVERAGE_PERCENT channel type Date: Thu, 14 May 2026 17:46:52 +0300 Message-ID: <20260514144712.64374-6-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514144712.64374-1-liviu.stan@analog.com> References: <20260514144712.64374-1-liviu.stan@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: TtXMEw6UOW4lPRD_hTty5jnp5VGjRlWh X-Authority-Analysis: v=2.4 cv=Wbo8rUhX c=1 sm=1 tr=0 ts=6a05e0fd 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=_UJtBQoUge9VAAk3jXkA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE1MCBTYWx0ZWRfX2Jg1JyTbI2kc F0SCnMZbEaHanKImj6Wr1CdlGG9gzIKC3JIOY1FVxlMjkYdL8/+D18ULw9lUZ2O28Uv5SCSdPLJ JRgt5epSW2g5KTLCKtlGOaGWW7qq9Zit+R6DFvTEyZ/LjbMVoSb4eDqKs4gAiWYCPT/v6XuUu9k 8k5fjcwGWLwqkAcRFO9LJVJEb+hM5MG0ax4Wb91ZXxhMtRM9ms48Hn3j0Jd9JM2W6ibebMx5sJW LK10grAl+V3nfLdcenB5fGc+9191qDTRrppYhfr2HoE+BlETdLYHAcKCj+FUOP4uk6OtSWJ2OI9 JkXwKu6dQiNOmeIcQAzQZYAabDdvQ6dJrFpmtW+T+HMebhH+K5ktXl8mX2L49BIgz51Rtv1xFCv nLF1eVkPDFV32ywDsPdtiSIoRYIWiFLS35qJ4ZBFuNrXfIvGUju2sBb+M/W39qNmW8qAeGAtkaS ILj5W5I604N91Wyu+Cw== X-Proofpoint-GUID: TtXMEw6UOW4lPRD_hTty5jnp5VGjRlWh 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-14_03,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 spamscore=0 impostorscore=0 phishscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140150 Content-Type: text/plain; charset="utf-8" Add a new channel type for sensors that report fractional coverage as a percentage. 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 v2: - New patch. Documentation/ABI/testing/sysfs-bus-iio | 10 ++++++++++ drivers/iio/industrialio-core.c | 1 + include/uapi/linux/iio/types.h | 1 + tools/iio/iio_event_monitor.c | 1 + 4 files changed, 13 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/te= sting/sysfs-bus-iio index 925a33fd309a..0570e8b8f5e5 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1980,6 +1980,16 @@ 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_coveragepercentX_raw +KernelVersion: 6.15 +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/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..ee8ffa2cfbc5 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_PERCENT] =3D "coveragepercent", }; =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..39830dc0cfb1 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_PERCENT, }; =20 enum iio_modifier { diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index df6c43d7738d..3339be7fe32c 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_PERCENT] =3D "coveragepercent", }; =20 static const char * const iio_ev_type_text[] =3D { --=20 2.43.0 From nobody Fri Jun 12 13:58:28 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 BA548421EFF; Thu, 14 May 2026 14:49: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=1778770182; cv=none; b=OZP5xFFNxFP6XdqUQPqX/n93Bn+dSoH+0zzYuQj1GqxG6IG9iyXoC7Ax/PePauF+t3oA0woTmkZcXTwr8hiCulVp7qNq1Dipd3+KqEn/P3DEbcbCNinMNpb+4zFb1bI+3nZ/HAjQdZW7K5zfHVKS6YLn8LTIZFCU+3LSmwqGUg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778770182; c=relaxed/simple; bh=GrgjQLPF6kol8DW0EJqPQG7+YFh6AS5SQjgSO4z0eAY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D/tQzdniDSllaJjKgeX/BD9XQkiqzts/pbKnojDbopg850SfPx3mwzVMgtRjhhys3iPBWBzx0XE3w9ldqZRBUMEibAF4kXagkOHeTmJNIaYurbsHLX8MVSsV1rMt5V/NGxSeUHL5aF5v6DLRQRtomqdxvlBviB8qmFdl+2MrduE= 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=S2+62LcO; 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="S2+62LcO" 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 64EDUTkQ1714697; Thu, 14 May 2026 10:49:37 -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=X6wRN pgTO9hy2kZY6CC9RzaemtqODAxEXckJ8ygDxQM=; b=S2+62LcOZ+Uq/ttj5q/iJ YVhh26+5vUSGx/wEDSP/ibAHDEhosXUrmmUOgxlNFiQdAKSigmo2QywEwCY+5RLL jQS7HriQJ8J9bD6I9FkkHP8GiKTfRJ5t6g/wvINpQy53c506dd3nzXxUt70szdYG IF9EEbS6BdJbaxde4RujDqNNbdITEDJ2E+j/e7ukeC+WffgukTVb/S1WARm3j3If QJi3kNKUfrfOG6BVIeuPpAdSPzrxjgZp/gynxOQ2EftLk6oG8S7Y5JZqAVk+Ad1D YCVsHtuqvsAsvHxwkg4YgNC4rmWZaBNdBrR6IUClerbXow8H90tvwJczNkE69qQ3 Q== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4e54xgtj53-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 10:49: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 64EEnaF3041761 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 14 May 2026 10:49:36 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Thu, 14 May 2026 10:49:36 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Thu, 14 May 2026 10:49:36 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.202]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64EEmjAd014051; Thu, 14 May 2026 10:49:29 -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 v2 6/7] dt-bindings: iio: temperature: Add ADT7604 support to adi,ltc2983 Date: Thu, 14 May 2026 17:46:53 +0300 Message-ID: <20260514144712.64374-7-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514144712.64374-1-liviu.stan@analog.com> References: <20260514144712.64374-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-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE1MCBTYWx0ZWRfXwymexMHA94YH 1X98DQXPEQ1TZT0wqKYBK5HedpF0aOYWdfQsLViz9nHsxsiWftydeNr0NlDuoWRC9obNH2dO1EB i2r10wMd3ASyb84Km8VjVZLYXOiTtjPIEQQXmtx5pcYNxXLNgDPWR5VZwNpR1NSicmOAn8I9X1W yXZyWez54R/+xNw40zDPcmw6Zzagdb05q0UFB/cyqJ/jIPz06/xg6l35V0Y72BXSHOZyEXraGXh 6ZAjPH8hkk28hn/q63ZDee7X8YfwsLvL2EZACjYLddYkjQDpD2PxSJILb245JgnQDf5h0inqu4K 59o8jDLxM1avEGgdh7IwRQR5W/FZSRyxfzyK74UXcP8VoiXLjUCmRV7T534UklcmPMowjS/KUN9 F7aHmuxaH3vt4siYJoaZk7JM+cYsvUgliLa/UKFCHvp0Mwz4t8BmFAhShyUXDaAaG+nwjRAAzCg FBScpXXWNIR+NZuMrNA== X-Proofpoint-GUID: pQLC7G6DNE5pQ0aKEa_er2evbzThK79p X-Proofpoint-ORIG-GUID: pQLC7G6DNE5pQ0aKEa_er2evbzThK79p X-Authority-Analysis: v=2.4 cv=MMFQXsZl c=1 sm=1 tr=0 ts=6a05e101 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=uXIjobp8t2wMuQ0fPvqm:22 a=gEfo2CItAAAA:8 a=gAnH3GRIAAAA:8 a=lI58tbVODBnYFgKiwwAA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=sptkURWiP4Gy88Gu7hUp:22 a=t30qsMHlJzOsgWiHt2r7:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-14_03,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 spamscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 suspectscore=0 bulkscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140150 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, optional adi,custom-rtd table, optional excitation current defaulting to the datasheet recommended value). Primary output is resistance in ohms. When a custom table is provided, the chip also outputs temperature in millidegrees Celsius. - leak-detector@: maps to the custom thermistor sensor type (27). Takes an optional adi,custom-leak-detector lookup table encoding resistance (uOhm) against coverage data. Primary output is resistance in ohms. When a custom table is provided, the chip also outputs coverage in percent. Separate node types are used rather than extending the existing rtd@ and thermistor@ nodes because adi,custom-rtd and adi,custom-thermistor are currently required for types 18 and 27, and several properties (adi,number-of-wires, adi,rtd-curve, adi,rsense-share) have no meaning for copper trace and would need to be explicitly forbidden or ignored in the driver. allOf conditions are added to restrict thermocouple, diode, direct ADC and active temperature nodes to non-ADT7604 devices, and to restrict copper-trace and leak-detector nodes to the ADT7604 (some parts only). Signed-off-by: Liviu Stan --- Changes in v2: - Shortened title to "LTC2983 and similar". - Converted device description list to bullet list in alphabetical order. - Retained separate copper-trace@ and leak-detector@ node types rather than extending rtd@/thermistor@; rationale added to commit message. - Replaced "ADT7604 only" with "some parts only". .../bindings/iio/temperature/adi,ltc2983.yaml | 194 +++++++++++++++++- 1 file changed, 191 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..c63b69bd9504 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,115 @@ 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, + optional 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-rtd: + description: + Optional resistance-to-temperature table for copper trace sensors + with resistance > 1 ohm. See Page 62 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-rtd: false + adi,excitation-current-microamp: false + + '^leak-detector@': + $ref: '#/$defs/sensor-node' + unevaluatedProperties: false + description: | + Leak detector sensor (some parts only). Outputs resistance in ohms a= nd, + when a custom table is provided, a coverage percentage via + IIO_COVERAGE_PERCENT (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 data. Entries must be + in ascending resistance order. The coverage data field encodes t= he + coverage percentage P as (P + 273.15) expressed in uK, i.e. + (P * 1000000 + 273150000). + $ref: /schemas/types.yaml#/definitions/uint64-matrix + minItems: 3 + maxItems: 64 + items: + items: + - description: Resistance point in uOhms. + - description: Coverage data point (P + 273150000) in uK. + + required: + - adi,rsense-handle + - adi,excitation-current-nanoamp + '^rsense@': $ref: '#/$defs/sensor-node' unevaluatedProperties: false @@ -477,6 +591,22 @@ allOf: patternProperties: '^temp@': false =20 + - if: + properties: + compatible: + contains: + const: adi,adt7604 + then: + patternProperties: + '^thermocouple@': false + '^diode@': false + '^adc@': false + '^temp@': false + else: + patternProperties: + '^copper-trace@': false + '^leak-detector@': false + examples: - | #include @@ -556,4 +686,62 @@ 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 373150000>, + /bits/ 64 < 202020000 372150000>, + /bits/ 64 < 1000000000 293150000>; + }; + + 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 Fri Jun 12 13:58:28 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 A832F423163; Thu, 14 May 2026 14:49: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=1778770187; cv=none; b=T5av+a0ZlficRHfUG/5kyM4o0iKukFQSrwYGKygHwR1wrsDc7v6njbOo1w2CmzG70fLpv+GCcSrp9HlXqsntJ3b7kYXBCuLs47dtosiHwl12BZrVfCV25PNebmGVckaqtFtSOwUeaVGeWhT7t2FXJ6SmfysrvoKK28hfMEzbL44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778770187; c=relaxed/simple; bh=SdKfnvDu9O1sScGHVDV6sgkWtshqWHLpT+q5N5cYaHg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kR9vZI64PfqrXwUTLnuGCHfwJAcnNB5Xw95IdZHMdPmttcC4vFz0IC9WH22K6cmDG/yuqc01CP6Sj4f8mc5SOPR42Eub89CJhorBJiWpMi5aauDBLCC/rCjT1uKjGKb82htqas9/PcownwycYt6RzsBvHPZdGwrnXXGfGeAIGko= 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=WHX2AN0t; 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="WHX2AN0t" 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 64ECXCn31715259; Thu, 14 May 2026 10:49:42 -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=3F5Gq Dgf4iCteKE8Ey1g5zl7GZ6N+TrukPmImTE2VEI=; b=WHX2AN0t8SjHcCDQHrTiG tEEnIoX2aYFC5qABGZrwldS1W7zb+Ji5TBYqDPqJnw315ODH/TRWHmvfP0XBfgAy UccH7MidQqV807kjCLAByzlAjio027w+Y5BbWkumLgQWsyRZv2S04J7mEEA5ztaX CiZuaVLLugAhA68NvtPTv0Tu9sfVmKmKcAzWdJXlrbLG07lwnSzPMviKmh38/HRi GalWElzG+m0bKIrFKn51rqi7UP2WbFmdXo1hC+AxOo6KzY5br7bmgWcWn1ECNTML nwxpalM39TmitgRaWSYTUiuPKPP4J7eKo7Bsjqu6PKlvgdYFObaNzg0uLp8zFSKz A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 4e54xgtj5g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 10:49:41 -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 64EEneDf041764 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 14 May 2026 10:49:40 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.37; Thu, 14 May 2026 10:49:40 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.1748.37 via Frontend Transport; Thu, 14 May 2026 10:49:40 -0400 Received: from HYB-MkYHBcJRSnh.ad.analog.com (HYB-MkYHBcJRSnh.ad.analog.com [10.48.65.202]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 64EEmjAe014051; Thu, 14 May 2026 10:49:33 -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 v2 7/7] iio: temperature: ltc2983: Add support for ADT7604 Date: Thu, 14 May 2026 17:46:54 +0300 Message-ID: <20260514144712.64374-8-liviu.stan@analog.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514144712.64374-1-liviu.stan@analog.com> References: <20260514144712.64374-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-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE1MCBTYWx0ZWRfX16CJ+woh0CL2 +EVI+5YZwvI6UeNr4dGEiEzezZjTcBJPu1/MSw3Z9sY90IJtaDRC6n/ZH291EuQkRcJ6fga6kLF XyHR3VZQqcuWdHo/pfMZtk5wBJO934hGhBVl+D5VZHTbAjS8z2HY+HiZ3MZd+SXrsDWNyC3Tu// eCjkGedS+UQt4eSo6GHYe3DO15j6s7d0j3UeVkrQ0x/XcFzwGB+xoipPns5QWWgTllJ4HCCTJ2+ Z+dI8LqancwG46ZTu043R9ETU2u1dYkOfpNTguE/dThzCiN4NqUnz6dYQv8aQSbecwynx27bMZl irBJhJEurrVud9o2eqQxTzNTUBXxui1dPn9iC1MpkbMhUt29UNwZiWA4sMLaCwUHE4PCHoTvDSc 8J91rjkmpbFjO9qg2SVVkVp7mYfaCZ5Fe21+M89R60VJJ8FBwNuQK0LKVXjm8EuVmXuhCEH8XtJ lzYMXWjcwtrbIgmHSRQ== X-Proofpoint-GUID: nEZOub8HetdM0-yo81oRv34HJZUePLTL X-Proofpoint-ORIG-GUID: nEZOub8HetdM0-yo81oRv34HJZUePLTL X-Authority-Analysis: v=2.4 cv=MMFQXsZl c=1 sm=1 tr=0 ts=6a05e106 cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0sLvza09kfJOxVLZPwjg:22 a=uXIjobp8t2wMuQ0fPvqm:22 a=gAnH3GRIAAAA:8 a=TvmM-eMmwrNWMyJAHKIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 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-14_03,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 spamscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 suspectscore=0 bulkscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140150 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) accept an optional 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 adi,custom-leak-detector DT property. Both sensor types expose an IIO_RESISTANCE channel reading from the resistance result register bank (0x0060-0x00AF). The 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. When a custom table is provided, a secondary channel also appears: IIO_TEMP (millidegrees Celsius) for copper trace and IIO_COVERAGE_PERCENT (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. Tested on EVAL-ADT7604-AZ connected to Raspberry Pi 5 via SPI. Signed-off-by: Liviu Stan --- Changes in v2: - New software sensor type values LTC2983_SENSOR_COPPER_TRACE =3D 32 and LTC2983_SENSOR_LEAK_DETECTOR =3D 33 map to hardware register values 18 and 27 internally; v1 exposed 18 and 27 directly as adi,sensor-type values. - Added n_iio_chan to struct ltc2983_sensor; set in the dedicated parser functions and used in ltc2983_parse_fw() and ltc2983_setup() to count and assign IIO channels, removing to_rtd()/to_thermistor() casts from the common path. - Replaced has_copper_trace guards in ltc2983_rtd_new() and ltc2983_thermistor_new() with dedicated structs and functions for the new sensor types. - Replaced has_copper_trace bool with u64 supported_sensors bitmask in ltc2983_chip_info. - Fixed IIO_RESISTANCE scale: both sensor types now use 1/1024 (ohms); v1 used 1/1,024,000 for copper trace. But since the sense resistor value is written in ohms to the register, the output will also be in ohms for a scale of 1/1024. - Replaced IIO_TEMP with IIO_COVERAGE_PERCENT for the leak detector coverage output. - Renamed sub_ohm to is_sub_ohm. - Used switch() for IIO_CHAN_INFO_RAW base register selection. - Used BIT_ULL() checks against supported_sensors for sensor type validation. drivers/iio/temperature/ltc2983.c | 401 ++++++++++++++++++++++++++++-- 1 file changed, 386 insertions(+), 15 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/lt= c2983.c index bf435e965c6d..acd043ed62f5 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 @@ -186,17 +188,43 @@ 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, }; =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 +240,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 +275,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 +304,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; @@ -354,8 +403,15 @@ 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); =20 - chan_val |=3D LTC2983_CHAN_TYPE(sensor->type); - dev_dbg(&st->spi->dev, "Assign reg:0x%04X, val:0x%08X\n", reg, + u32 hw_type =3D 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, @@ -579,6 +635,32 @@ 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); + chan_val |=3D LTC2983_RTD_EXC_CURRENT(ct->excitation_current); + + if (ct->custom) { + int ret; + + ret =3D __ltc2983_chan_custom_sensor_assign(st, ct->custom, + &chan_val); + if (ret) + return ret; + } + + if (ct->is_sub_ohm) + chan_val &=3D ~GENMASK(17, 0); + + return __ltc2983_chan_assign_common(st, sensor, chan_val); +} + static int ltc2983_thermistor_assign_chan(struct ltc2983_data *st, const struct ltc2983_sensor *sensor) { @@ -602,6 +684,29 @@ 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; + + 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); + + if (ld->custom) { + int ret; + + 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) { @@ -1024,6 +1129,191 @@ 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 (fwnode_property_present(child, "adi,custom-rtd")) { + if (ct->is_sub_ohm) + return dev_err_ptr_probe(dev, -EINVAL, + "sub-ohm copper trace cannot have a custom table\n"); + ct->custom =3D __ltc2983_custom_sensor_new(st, child, "adi,custom-rtd", + false, 2048, false); + if (IS_ERR(ct->custom)) + return ERR_CAST(ct->custom); + } + + if (!ct->is_sub_ohm) { + u32 excitation_current =3D 0; + + ret =3D fwnode_property_read_u32(child, + "adi,excitation-current-microamp", + &excitation_current); + if (ret) { + /* default to 1mA per datasheet recommendation for copper trace */ + ct->excitation_current =3D 0x08; + } else { + 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); + } + } + } + + ct->sensor.fault_handler =3D ltc2983_common_fault_handler; + ct->sensor.assign_chan =3D ltc2983_copper_trace_assign_chan; + if (ct->custom) + ct->sensor.n_iio_chan =3D 2; + else + ct->sensor.n_iio_chan =3D 1; + + 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")) { + ld->custom =3D __ltc2983_custom_sensor_new(st, child, + "adi,custom-leak-detector", + 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; + if (ld->custom) + ld->sensor.n_iio_chan =3D 2; + else + ld->sensor.n_iio_chan =3D 1; + + 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) @@ -1183,7 +1473,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; @@ -1221,6 +1512,16 @@ static int ltc2983_chan_read(struct ltc2983_data *st, =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; @@ -1252,7 +1553,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: @@ -1269,6 +1579,16 @@ static int ltc2983_read_raw(struct iio_dev *indio_de= v, /* 2^21 */ *val2 =3D 2097152; return IIO_VAL_FRACTIONAL; + case IIO_RESISTANCE: + /* value in ohm, 10 fractional bits: divide by 2^10 */ + *val =3D 1; + *val2 =3D 1024; + return IIO_VAL_FRACTIONAL; + case IIO_COVERAGE_PERCENT: + /* value in percent, 10 fractional bits: divide by 2^10 */ + *val =3D 1; + *val2 =3D 1024; + return IIO_VAL_FRACTIONAL; default: return -EINVAL; } @@ -1329,7 +1649,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 @@ -1357,7 +1677,13 @@ 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", + if (sensor.type > LTC2983_SENSOR_LEAK_DETECTOR || + !(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 if (sensor.type >=3D LTC2983_SENSOR_THERMOCOUPLE && @@ -1377,13 +1703,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", @@ -1398,6 +1725,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++; } @@ -1445,8 +1782,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 */ @@ -1493,8 +1831,26 @@ static int ltc2983_setup(struct ltc2983_data *st, bo= ol assign_iio) !assign_iio) continue; =20 + /* + * Copper trace and leak detector sensors without a custom table + * produce only a resistance result; the chip does not populate + * the temperature result register. Emit only an IIO_RESISTANCE + * channel in this case. + */ + if (st->sensors[chan]->type =3D=3D LTC2983_SENSOR_COPPER_TRACE || + st->sensors[chan]->type =3D=3D LTC2983_SENSOR_LEAK_DETECTOR) { + if (st->sensors[chan]->n_iio_chan =3D=3D 1) { + st->iio_chan[iio_idx++] =3D + LTC2983_CHAN(IIO_RESISTANCE, iio_chan_r++, chan); + continue; + } + } + /* assign iio channel */ - if (st->sensors[chan]->type !=3D LTC2983_SENSOR_DIRECT_ADC) { + if (st->sensors[chan]->type =3D=3D LTC2983_SENSOR_LEAK_DETECTOR) { + chan_type =3D IIO_COVERAGE_PERCENT; + iio_chan =3D &iio_chan_c; + } else if (st->sensors[chan]->type !=3D LTC2983_SENSOR_DIRECT_ADC) { chan_type =3D IIO_TEMP; iio_chan =3D &iio_chan_t; } else { @@ -1508,6 +1864,9 @@ static int ltc2983_setup(struct ltc2983_data *st, boo= l assign_iio) */ st->iio_chan[iio_idx++] =3D LTC2983_CHAN(chan_type, (*iio_chan)++, chan); + + if (st->sensors[chan]->n_iio_chan =3D=3D 2) + st->iio_chan[iio_idx++] =3D LTC2983_CHAN(IIO_RESISTANCE, iio_chan_r++, = chan); } =20 return 0; @@ -1516,6 +1875,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), @@ -1658,25 +2018,34 @@ static DEFINE_SIMPLE_DEV_PM_OPS(ltc2983_pm_ops, ltc= 2983_suspend, static const struct ltc2983_chip_info ltc2983_chip_info_data =3D { .name =3D "ltc2983", .max_channels_nr =3D 20, + .supported_sensors =3D LTC2983_COMMON_SENSORS, }; =20 static const struct ltc2983_chip_info ltc2984_chip_info_data =3D { .name =3D "ltc2984", .max_channels_nr =3D 20, + .supported_sensors =3D LTC2983_COMMON_SENSORS, .has_eeprom =3D true, }; =20 static const struct ltc2983_chip_info ltc2986_chip_info_data =3D { .name =3D "ltc2986", .max_channels_nr =3D 10, - .has_temp =3D true, + .supported_sensors =3D LTC2983_COMMON_SENSORS | BIT_ULL(LTC2983_SENSOR_AC= TIVE_TEMP), .has_eeprom =3D true, }; =20 static const struct ltc2983_chip_info ltm2985_chip_info_data =3D { .name =3D "ltm2985", .max_channels_nr =3D 10, - .has_temp =3D true, + .supported_sensors =3D LTC2983_COMMON_SENSORS | BIT_ULL(LTC2983_SENSOR_AC= TIVE_TEMP), + .has_eeprom =3D true, +}; + +static const struct ltc2983_chip_info adt7604_chip_info_data =3D { + .name =3D "adt7604", + .max_channels_nr =3D 20, + .supported_sensors =3D ADT7604_SENSORS, .has_eeprom =3D true, }; =20 @@ -1685,6 +2054,7 @@ static const struct spi_device_id ltc2983_id_table[] = =3D { { "ltc2984", (kernel_ulong_t)<c2984_chip_info_data }, { "ltc2986", (kernel_ulong_t)<c2986_chip_info_data }, { "ltm2985", (kernel_ulong_t)<m2985_chip_info_data }, + { "adt7604", (kernel_ulong_t)&adt7604_chip_info_data }, { } }; MODULE_DEVICE_TABLE(spi, ltc2983_id_table); @@ -1694,6 +2064,7 @@ static const struct of_device_id ltc2983_of_match[] = =3D { { .compatible =3D "adi,ltc2984", .data =3D <c2984_chip_info_data }, { .compatible =3D "adi,ltc2986", .data =3D <c2986_chip_info_data }, { .compatible =3D "adi,ltm2985", .data =3D <m2985_chip_info_data }, + { .compatible =3D "adi,adt7604", .data =3D &adt7604_chip_info_data }, { } }; MODULE_DEVICE_TABLE(of, ltc2983_of_match); --=20 2.43.0