From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E439F3FB7E6; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=ID/vdmkjflgYFdLzaOyedWZwhnsPCThvfw3jXQvLPTH7OiVf63D7qEjguYyu/UMHEWm6fIBHjxWddS9ZdRvmjt9L5UDNtktU/tRHjrq1OwCcPUaXp9rzDVwMCSmKkEmndZtghJkmWPUJaz8pirk+nphDvd0bmjlv7ZyjeCRY2jA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=NV+pb6nkEs/Kb/1eTRMnTHalM7wi/b80qqdCmx/U20E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Zb5cmi4Qnqsry/qC1rTj+9YOeoDpcFMi8316OdbxvuWxraFfDBt7wfXwt7gCDyRL6qY2X2I2QY8veqAAGrEqLXBF86ilKY73ntPaNDeVKudpSYl9lUzJpd0qxYEAODthZvBVh1uSZ2tWwWMF6h2hoxbAK86ut34VTc83cKwlaMA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sdO0q6xa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sdO0q6xa" Received: by smtp.kernel.org (Postfix) with ESMTPS id 99067C2BCB8; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468057; bh=NV+pb6nkEs/Kb/1eTRMnTHalM7wi/b80qqdCmx/U20E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=sdO0q6xa7tnp8omHixWCCH4uB2eDYQWfhCcSfBt32RxS1s38gEld+kt10052HhJPw +N6+B7yrzGGoUYumVoNEN1369dGV3/G2Ge5F/U23+2GhFrav4XwNXEpwzvOnuPGvR7 GRMeHmn+AVYsvgVbN5dZ8PS2T0mXgoBLUIaS9+sQfunkpbrbEQQMDuHCMq81TTQreh 3wwE6Z02ODXl4fdhqIcg1Hzfht+N1+U97ZZF2P2J8dt2zWLRdrXoquZtyd6Q0u41zd v3h6rqaiNoZkSsJHiKAMXuyPRf7QHPbTyL1EBd8WZ64Nt+pNxq3Bbx0ZYlpurnV9S6 lngOQHFwI64hQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85827FF8875; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:31 +0100 Subject: [PATCH v4 01/13] iio: dac: ad5686: fix ref bit initialization for single-channel parts Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-1-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar , Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=1845; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=ACFFNXIkeDLRrCLvd6fNW7RHjZhA5Kd+3kUIKJGbV70=; b=IrFovwyeu4ePdUt+T4KDYb3N0B+hdMRzVEPLxaHgVEGrpLe4eCiX5TxkaEOtmDhIn1IkREE+W 53cK2RhfYJzBdOVY3aYj36CzVFmFoiMsG5+IEjrlZJniAlbIMsTL+zA X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar The reference bit position was ignored when writing the register at the probe() function (!!val was used). When such bit is 1, internal voltage reference is disabled so that an external one can be used. For multi-channel devices, bit 0 of the Internal Reference Setup command behaves the same way, so AD5686_REF_BIT_MSK is created. The issue exists since support for single-channel devices were first introduced. Fixes: be1b24d24541 ("iio:dac:ad5686: Add AD5691R/AD5692R/AD5693/AD5693R su= pport") Reviewed-by: Andy Shevchenko Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 6 +++--- drivers/iio/dac/ad5686.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 9a384c50929b..1fc54c38b629 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -511,7 +511,7 @@ int ad5686_probe(struct device *dev, break; case AD5686_REGMAP: cmd =3D AD5686_CMD_INTERNAL_REFER_SETUP; - ref_bit_msk =3D 0; + ref_bit_msk =3D AD5686_REF_BIT_MSK; break; case AD5693_REGMAP: cmd =3D AD5686_CMD_CONTROL_REG; @@ -522,9 +522,9 @@ int ad5686_probe(struct device *dev, return -EINVAL; } =20 - val =3D (has_external_vref | ref_bit_msk); + val =3D has_external_vref ? ref_bit_msk : 0; =20 - ret =3D st->write(st, cmd, 0, !!val); + ret =3D st->write(st, cmd, 0, val); if (ret) return ret; =20 diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index e7d36bae3e59..36e16c5c4581 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -46,6 +46,7 @@ =20 #define AD5310_REF_BIT_MSK BIT(8) #define AD5683_REF_BIT_MSK BIT(12) +#define AD5686_REF_BIT_MSK BIT(0) #define AD5693_REF_BIT_MSK BIT(12) =20 /** --=20 2.43.0 From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E453D3FB7E8; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=Y4tWL7IqgNobk4Rs5jYYIJsZMdiy6I3Y2MOFbEXS/Hd9Jd8e9G2TtPCMBG9qCIivroZihMXauE8/BRKccXY8TMdNtF5okjOp3wMQfYwhVAZ1pU7ck9imP8Iuie4iLFxTaid0/UPodiTXvlqZ3GNyaJWkGDIrdUWnZYE5mvQO20U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=7Mc0VNRZ1CCHsXaSFdFIyxqQMqScXwRjdBvOyAElbig=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DJk2M6do4ux0mno7ljFk74vzQrpTCC8cVRqXhKyWNWwEKCEdnn+p1naanQ0hj8V6rBg6+OjRJp4KVrE4BWjF9zF8Tx/2SiZrt8POpzKnxF4BxXvvt55BNTPcFtM6DPsfuArLYVGPWJKuH9kEvOV9Bgj5y3FzxQEQ49Z0NJKBB9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A2DfcT6Q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A2DfcT6Q" Received: by smtp.kernel.org (Postfix) with ESMTPS id A26C0C2BCC4; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468057; bh=7Mc0VNRZ1CCHsXaSFdFIyxqQMqScXwRjdBvOyAElbig=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=A2DfcT6QDnOZxeP4IOOFtTPp9dW6rKyPeNBrIIy98brs5OpLeRN8kkS4NtPHiMF+k XDBujp0J93Ln4Xkkep9j2glCWSkNcUUleGC7SOuCVfnj5CkqdG8x7VsqdRxY9cTp0p /g5y2f7GIo94sXboMdstyJRU6rmGLgHo2QrjgBgkqZmJc1nZjyjyhZ57QsWefyxmHs abSN69zmPs80Ws9AYRIius9XG9Oj045spSc3NX3hUqz5LXSOIVGHXTqwgZkZR1b6bg tIwJXRuBlsTB832b4afErY76svdrqGi9ShekdroAo/YiRK/r677ngAY047BFO3eyYy ILSQJloO3gvcg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98114FF8867; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:32 +0100 Subject: [PATCH v4 02/13] iio: dac: ad5686: fix input raw value check Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-2-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar , Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=1063; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=vDIfN7HwJer2abOZhavJmea2PyXmNcae90gQrhX9MT8=; b=HgZk4TEcba2cXSLR98o44JR0MM2hVQBajd6/SvZsOD1dNrrtM1BzsOEdpkEOmh1BS8rYA3i7b CDOffrKxWYCBXVqoDz6N91tVnvUFpkHtyfqJ+xXysdkXE/tpGqkfkvq X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Fix range check for input raw value, which is off by one, i.e., for a 10-bit DAC the max valid value is 1023, but 1 << 10 equals 1024, which passes the previous check, allowing an out-of-range write. The issue exists since the ad5686 driver was first introduced. Fixes: c2f37c8dcadc ("iio: dac: New driver for AD5686R, AD5685R, AD5684R Di= gital to analog converters") Reviewed-by: Andy Shevchenko Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 1fc54c38b629..076fe8b8bd85 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -154,7 +154,7 @@ static int ad5686_write_raw(struct iio_dev *indio_dev, =20 switch (mask) { case IIO_CHAN_INFO_RAW: - if (val > (1 << chan->scan_type.realbits) || val < 0) + if (val >=3D (1 << chan->scan_type.realbits) || val < 0) return -EINVAL; =20 mutex_lock(&st->lock); --=20 2.43.0 From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E75D43FB7EB; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=tXemPXMETmXE7R9WPoMU0P6JQKjvONNGE3gNk69ZfglVYMj029rAPCR7dKTOcdMX9IL1gvnIONASXVfY3agTm94Vd1tyYvpOourNC1qxFKipuEAjHG5hIAeRK6xlWrm1kRY0g3hTtSQO/xulgph2Xp1rsXMkzFdMf6VvTgMbEn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=l6b0m/8tpPZhcd1xoUPK+UYPNIMKo+diyowWW/xZ9TA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Obez5gZmlz4v/qolARSYdcMGoT+2BW7xpIxZ4KZ89X25IAs6GgAdhJb9gRTKsQYjUTu9X0Ca5nd6PXgKW0Z4LNG5G6/HjMA9GY38q/dt/Fv5OXV9gy711AEy1DG4rt4MxIQXI0CY3aBp58PQwT3b6zVsseuY0VoTDnOrTmZUgaA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=juMA2E/4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="juMA2E/4" Received: by smtp.kernel.org (Postfix) with ESMTPS id B89DEC2BCC7; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468057; bh=l6b0m/8tpPZhcd1xoUPK+UYPNIMKo+diyowWW/xZ9TA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=juMA2E/4ZgAvK1zoj0e7C3B2rH916GVbqYzvw5zZTKi5cG3bayMGWwE5bUBsHP7MA EGMwa2w7xH+nJUHJZO/dj+zs7ExqcX39vxLE+lDac2T8laX6RQ/mPd5kzmp5Gy4qya EQbvyf2w1QEcV1JnljqNOQTT7CF4ufyisFyPmZ4hV1RMKhS9R4wwdleN3hVVIkn1We ngxMKpdgVLjaKyUgLOrWWc0Pjz8H06+t1iMRLfRodOcCkzEUjfUcq783vYdt/oFAjC Vm+t9eCfB9jMRrHT1VX+/tiqBNpCkXSvv/rcgNu8WoxBL2rSoPTMeCDJPjU60m8qhF 0ps4VtfmuSvsg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABAE2CCFA13; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:33 +0100 Subject: [PATCH v4 03/13] iio: dac: ad5686: acquire lock when doing powerdown control Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-3-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar , Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=1395; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=WJ9grwmFpTnUy61Cm75lOSuLfVSZ+oTAauaTKqq2DP4=; b=T7BVHu5psApAgmbYyqcoLyIDl6hmOfPSHkeMbNdd/TivFEWQ8YxMpQVYsJ93XLzftGvtvFqgn DJPEQsGqh0pCXm17IZJevbWiFr5nRN5r4FIlmureG8AdLLH0KJqiXxb X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Protect write access of pwr_down_mode and pwr_down_mask fields with existing mutex lock. Each channel exposes their own attributes for controlling powerdown modes and powerdown state. This fixes potential race conditions as those functions perform non-atomic read-modify-write operations to those pwr_down_* fields. This issue exists since the ad5686 driver was first introduced. Fixes: c2f37c8dcadc ("iio: dac: New driver for AD5686R, AD5685R, AD5684R Di= gital to analog converters") Reviewed-by: Andy Shevchenko Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 076fe8b8bd85..69358dd66cbc 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -39,6 +39,8 @@ static int ad5686_set_powerdown_mode(struct iio_dev *indi= o_dev, { struct ad5686_state *st =3D iio_priv(indio_dev); =20 + guard(mutex)(&st->lock); + st->pwr_down_mode &=3D ~(0x3 << (chan->channel * 2)); st->pwr_down_mode |=3D ((mode + 1) << (chan->channel * 2)); =20 @@ -77,6 +79,8 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev = *indio_dev, if (ret) return ret; =20 + guard(mutex)(&st->lock); + if (readin) st->pwr_down_mask |=3D (0x3 << (chan->channel * 2)); else --=20 2.43.0 From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 ED48E38AC6C; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=j/nqK8Xx4FGSM8YDpqWS75oD8PttmFlHdGTTVrvFCv5HVIrMZQVyjPRbrKiFWLG+6rc6vepwAGGwmH00p0FKL+PuhWWPkG4mn0Mr6mTWnSjR1yDvdHTIBtJ/foET0OIS3P6Wld7SU8oYscd3NwXlZ3PrCpPrQIATm3KtMPJwuio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=/vz/Et57/ETkKqO/2fI8BIAP8N2wyHZmnMQrgdd/wog=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=o7colu8sdtkFNvw9pZxLJga2y1EpfCFvyn1HjeKjnj67PRIpoFAlgbmTmgwF2/DM6u8sgnmuhzGqaik5PADs15rPiQsqeikhjcw4o/CBu2aFnE9Xa32y9MgW9n84JnRyY3Wvikn97KZdmZ59Nc5y9mD88R/R5Ne1Ef0lUnmWoXI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oY+teXrT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oY+teXrT" Received: by smtp.kernel.org (Postfix) with ESMTPS id C7256C2BCC6; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468057; bh=/vz/Et57/ETkKqO/2fI8BIAP8N2wyHZmnMQrgdd/wog=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=oY+teXrTUMfxw40l+a7Pw4I04i5/ZKvmJnCvkqlEYSxjUZfgOYL+nUflEuByAqFzV 7dRb+LGkrYB42QM3eHN8mI0iH+UeSGN54xrXdU/fWyoz343v1aGQnZylHjAWcB1M/r dug9SB8zb4iNqvgP6WcOXfTnj3AF4VLYzB06lxqEO6BIRyTXrpPnd1KFqNP/Zf9tLW l7NrVj0xTFQYtEOCeAaeBE4S7XHCLFO5uoRTUqVzWdwW3CScJQ+302NZviCkMxl4ox SRm/fIcaZyYNYO4yi82/vpo3aXbmn/tWFJtEkQZ2N6KIdORkAmRfxepfFnAVlR+tny RB1VTQ25edupA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCC45FF8877; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:34 +0100 Subject: [PATCH v4 04/13] iio: dac: ad5686: fix powerdown control on dual-channel devices Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-4-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=4523; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=W7kLkmqYDobLBwqnuuqx8gF9sREn36byIbemRQVPp+E=; b=eLq0z63FiYJqz9ScM9sFXUTx3ezbNaQNM82T5VF7q9DoH3kMi9pT7R1wjJ/bg1GRRYV51eMIh i/eLE+GW4lID3dndx1hSyr3wqgaeYqIYetGkxTOz/5MLzAqyxWkfZz0 X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Fix powerdown control by using a proper bit shift for the powerdown mask values. During initialization, powerdown bits are initialized so that unused bits are set to 1 and the correct bit shift is used. Dual-channel devices use one-hot encoding in the address and that reflects on the position of the powerdown bits, which are not channel-index based for that case. Quad-channel devices also use one-hot encoding for the channel address but the result of log2(address) coincides with the channel index value. The issue was introduced when first adding support for dual-channel devices, which overlooked powerdown control differences. Fixes: 7dc8faeab3e3 ("iio: dac: ad5686: add support for AD5338R") Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 69358dd66cbc..c607251b82a0 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -25,24 +25,35 @@ static const char * const ad5686_powerdown_modes[] =3D { "three_state" }; =20 +static inline unsigned int ad5686_pd_mask_shift(const struct iio_chan_spec= *chan) +{ + if (chan->channel =3D=3D chan->address) + return chan->channel * 2; + + /* one-hot encoding is used in dual/quad channel devices */ + return __ffs(chan->address) * 2; +} + static int ad5686_get_powerdown_mode(struct iio_dev *indio_dev, const struct iio_chan_spec *chan) { + unsigned int shift =3D ad5686_pd_mask_shift(chan); struct ad5686_state *st =3D iio_priv(indio_dev); =20 - return ((st->pwr_down_mode >> (chan->channel * 2)) & 0x3) - 1; + return ((st->pwr_down_mode >> shift) & 0x3) - 1; } =20 static int ad5686_set_powerdown_mode(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, unsigned int mode) { + unsigned int shift =3D ad5686_pd_mask_shift(chan); struct ad5686_state *st =3D iio_priv(indio_dev); =20 guard(mutex)(&st->lock); =20 - st->pwr_down_mode &=3D ~(0x3 << (chan->channel * 2)); - st->pwr_down_mode |=3D ((mode + 1) << (chan->channel * 2)); + st->pwr_down_mode &=3D ~(0x3 << shift); + st->pwr_down_mode |=3D (mode + 1) << shift; =20 return 0; } @@ -57,10 +68,10 @@ static const struct iio_enum ad5686_powerdown_mode_enum= =3D { static ssize_t ad5686_read_dac_powerdown(struct iio_dev *indio_dev, uintptr_t private, const struct iio_chan_spec *chan, char *buf) { + unsigned int shift =3D ad5686_pd_mask_shift(chan); struct ad5686_state *st =3D iio_priv(indio_dev); =20 - return sysfs_emit(buf, "%d\n", !!(st->pwr_down_mask & - (0x3 << (chan->channel * 2)))); + return sysfs_emit(buf, "%d\n", !!(st->pwr_down_mask & (0x3 << shift))); } =20 static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev, @@ -82,9 +93,9 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev = *indio_dev, guard(mutex)(&st->lock); =20 if (readin) - st->pwr_down_mask |=3D (0x3 << (chan->channel * 2)); + st->pwr_down_mask |=3D 0x3 << ad5686_pd_mask_shift(chan); else - st->pwr_down_mask &=3D ~(0x3 << (chan->channel * 2)); + st->pwr_down_mask &=3D ~(0x3 << ad5686_pd_mask_shift(chan)); =20 switch (st->chip_info->regmap_type) { case AD5310_REGMAP: @@ -464,7 +475,7 @@ int ad5686_probe(struct device *dev, { struct ad5686_state *st; struct iio_dev *indio_dev; - unsigned int val, ref_bit_msk; + unsigned int val, ref_bit_msk, shift; bool has_external_vref; u8 cmd; int ret, i; @@ -488,9 +499,18 @@ int ad5686_probe(struct device *dev, has_external_vref =3D ret !=3D -ENODEV; st->vref_mv =3D has_external_vref ? ret / 1000 : st->chip_info->int_vref_= mv; =20 + /* Initialize masks to all ones provided the max shift (last channel) */ + shift =3D ad5686_pd_mask_shift(&st->chip_info->channels[st->chip_info->nu= m_channels - 1]); + st->pwr_down_mask =3D GENMASK(shift + 1, 0); + st->pwr_down_mode =3D GENMASK(shift + 1, 0); + /* Set all the power down mode for all channels to 1K pulldown */ - for (i =3D 0; i < st->chip_info->num_channels; i++) - st->pwr_down_mode |=3D (0x01 << (i * 2)); + for (i =3D 0; i < st->chip_info->num_channels; i++) { + shift =3D ad5686_pd_mask_shift(&st->chip_info->channels[i]); + st->pwr_down_mask &=3D ~(0x3 << shift); /* powered up state */ + st->pwr_down_mode &=3D ~(0x3 << shift); + st->pwr_down_mode |=3D 0x01 << shift; + } =20 indio_dev->name =3D name; indio_dev->info =3D &ad5686_info; --=20 2.43.0 From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 412403FBEBD; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=IsIJPRQ6cpNpljsF6p6iYIQ049eTKIdmtIhA9HykUYmBI4jY7a0ciOvIjWohPTDs38/kxyayJHwmQZm314+ciD5Xealjn/SnEnpZx6SgqBrKYQsa9F75J/NoDb2xm1S+LH8EmnGlWyQjXIhrPstdroFillGGLWzwvZrXfKNJcLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=sM1kRdBJCD4TGiRYIknbJztxuL3qEzLsr8B45TCbhY8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ao6pUcl5F5cOtEQiOidwT91XgfsjQV9pYr9qVLMg1+5YPpMUSGQRpEqeay1gKZ0WV1ClzGP/zcEaRQmhtbIK6NPcPBrtSQt3/qSUe1mAnLuc4RkurLzXKjMDernZaNibfXxHzJlpjWVrGsE0V9XgxYVHA2KNgt4Yx0+sEhPhGdY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lGRAhzgV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lGRAhzgV" Received: by smtp.kernel.org (Postfix) with ESMTPS id D3FA1C2BCF5; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468057; bh=sM1kRdBJCD4TGiRYIknbJztxuL3qEzLsr8B45TCbhY8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=lGRAhzgVKzzRPNVpOTMhDpqAxaLrqDNDPyLEFIVdv0iC4+BrcKtMA043Cwwo6jN/9 9XS6CQxqUvVhZB3zS6EZ9mtLJ/BwJQskYi/QZsNKq6aw7X6CkZLkxEcjl2kgWmYveU DpmUjUTU+LgsO+Cngr3KwzDvMRq4v+jiQ39lTdvkoQkkZInrBLzuYWk75crQmH/JXK Tkxq9SJqbNypT0jLYD8Do9v5c/hFDjaYEVC4IEXbZW6DRXSzTXDzWnhOtcLE/q1A7I KamQIRL+ru9LvAgoOSDMeu7wIy9Xej/GUB3gBEBHq9AXxjvIg1Pxw6ETSw2Ch1Cc1Z NY/lHrK4mtEEw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC538FF8875; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:35 +0100 Subject: [PATCH v4 05/13] iio: dac: ad5686: fix overlapping DMA buffers in I2C read Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-5-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=1342; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=z//9u6PswtgHUejmo4eNzd3La9IQg4Jj8G/hjxUaHc0=; b=Q5kCfVXd2U0uebBfIbMgi/xxxP092I/getGLhO8heWIERHqVUwrL33qNiSNI3sKyyEhZIdFPt 7AB/vH7vdh9BeyGTOPuhdh1CyWfhjveeo7JcuRCMmnt1coUliChCjMq X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar The TX and RX buffers in ad5686_i2c_read() both reference data[0], causing byte d8[1] to be shared between the TX buffer and the RX buffer. I2C controller drivers that map all message buffers for DMA before initiating the hardware transaction will map overlapping memory ranges with conflicting DMA directions (DMA_TO_DEVICE and DMA_FROM_DEVICE). This issue was reported by sashiko. Fixes: 4177381b4401 ("iio:dac:ad5686: Add AD5671R/75R/94/94R/95R/96/96R sup= port") Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5696-i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index d3327bca0e07..d3b46496d67d 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -26,7 +26,7 @@ static int ad5686_i2c_read(struct ad5686_state *st, u8 ad= dr) .addr =3D i2c->addr, .flags =3D i2c->flags | I2C_M_RD, .len =3D 2, - .buf =3D (char *)&st->data[0].d16, + .buf =3D (char *)&st->data[1].d16, }, }; int ret; @@ -39,7 +39,7 @@ static int ad5686_i2c_read(struct ad5686_state *st, u8 ad= dr) if (ret < 0) return ret; =20 - return be16_to_cpu(st->data[0].d16); + return be16_to_cpu(st->data[1].d16); } =20 static int ad5686_i2c_write(struct ad5686_state *st, --=20 2.43.0 From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1FA413FBEA5; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=W0W+S14bTRW8vHZOAxWbruk1uCJ/IWZon8izEWaUIHhCjtNWxUAjbfI6njlJj6nE8qeVqQzRogrRcktaL4Y69LwG2Lr+jRpvMt6dKg1eS0nqq3lf4NUAF92b8vmDX461d2EZnnMOPQ0IU+fu0hROwioMoNpwrpOpTJx8tkmSR8k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=lcv6z1ZAdYCF6mpSpS498JRZrHuLPx8kHVH8W6ltjks=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kZSvmm3cAnZmxCY3S286KRsrortVy83DZoK/AImCEnTovTrWJX6LwT7RfSNsTxXCRh+38/JSTVj+xAHQIn8F9KAphICyBqZip/vdBh3cEcHVfuT2bGu4ZhRI5E6T1ouxOJZSaVY/Rhzgh3vspU/ZAmYGlNcYqnhHSOod7FQW2+k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ejSvqJz8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ejSvqJz8" Received: by smtp.kernel.org (Postfix) with ESMTPS id E3A44C2BCC9; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468057; bh=lcv6z1ZAdYCF6mpSpS498JRZrHuLPx8kHVH8W6ltjks=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ejSvqJz8HCc6/w8K/2g1AX5r1YAhcup39HMvKln4Sgl9GRO9GtB9jDKg8lH6OcyVQ 6PSoBpBdKj8wtlnNoDNwCknOtLZYvfrdo/DyvQDSm/u6pivvnTb41YOOApQwSV/qry w486OuprIdscsso3aCJk9i8YxQyg4A6oIc62gNzpQ75vyo0rClm42IKV9XoGWV456L OUmxUL3oTRWgrswncZpl5ir/vAGmfGAVU5sbuGkaAXX9PCswM1Aew8U8kcdf9EeeRj EgVkhLbsjfkhlTpsKbNMsgYabr4qZWPfwqfvk3gr+fa+fzZMQ+0CfPxM1JVMa+96Db qDznVOP/mJrdA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC9FFFF8867; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:36 +0100 Subject: [PATCH v4 06/13] iio: dac: ad5686: refactor include headers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-6-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=2812; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=RoEVXdmkieaZi4J+cKaVs7klr+L+vuT7yR/Soth67CQ=; b=6u19Rb2FA8K8uhyW0pE98CrBrrMekTF6xQnsgtpv453n7vxdXU9glXr9dwE3BBxBZc5gVv3iB /Xo8aDZ8SWpD6NNHBZWvgBYMsMXFtqfDLEsuMp0lppOnTItWvko/EX9 X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Apply IWYU principle, replacing unused/generic headers for specific/missing headers. The resulting include directive lists are sorted accordingly. Signed-off-by: Rodrigo Alencar Reviewed-by: Andy Shevchenko --- drivers/iio/dac/ad5686-spi.c | 9 +++++++-- drivers/iio/dac/ad5686.c | 13 ++++++------- drivers/iio/dac/ad5686.h | 5 ++--- drivers/iio/dac/ad5696-i2c.c | 10 +++++++--- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index df8619e0c092..cec784b617e6 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -8,11 +8,16 @@ * Copyright 2018 Analog Devices Inc. */ =20 -#include "ad5686.h" - +#include +#include +#include #include #include =20 +#include + +#include "ad5686.h" + static int ad5686_spi_write(struct ad5686_state *st, u8 cmd, u8 addr, u16 val) { diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index c607251b82a0..572dcc918ef2 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -5,17 +5,16 @@ * Copyright 2011 Analog Devices Inc. */ =20 -#include -#include -#include +#include +#include +#include +#include +#include #include -#include -#include -#include #include +#include =20 #include -#include =20 #include "ad5686.h" =20 diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index 36e16c5c4581..d08160e7fad9 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -8,10 +8,9 @@ #ifndef __DRIVERS_IIO_DAC_AD5686_H__ #define __DRIVERS_IIO_DAC_AD5686_H__ =20 -#include -#include +#include #include -#include +#include =20 #include =20 diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index d3b46496d67d..5b5b30f586c1 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -7,10 +7,14 @@ * Copyright 2018 Analog Devices Inc. */ =20 -#include "ad5686.h" - -#include +#include #include +#include +#include + +#include + +#include "ad5686.h" =20 static int ad5686_i2c_read(struct ad5686_state *st, u8 addr) { --=20 2.43.0 From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 453883FBEC2; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=vE9bI3RxvSRmorXr+v9uJJs/Kf/ewffhDOp3xp739ZoV86ISDDRUuwqIk9YCpY8RfPnxdAKc3IckRMEn2QX+4SHdVHANF892+/GFm21EO7TBd5gVXTd8Rqpox4BwxndlZGk3ym1Xlf2jy5EQ7JRAHQFcS2ZGEX/dOZZ6eXR8ukE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=cUU49IwGzqomXwO+cbWgn3tRrnMtke2zHDK1OHMoFXs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Lh18YgsVBxiclnpdZ5UjXo3mAjhIy6FispleMoNgfTMeUMol/0ShprEduSluiREipJ5npYvCNQoUdXDc19k/KOAdg4Zu8I/mM9Yh5JnWx4tFGwiAHA4CWtd/YQ+KToJEUEL/YA4UVU6G7h/nPskkRcjwh3fA20RQAqHCXJyKp54= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=twNAQ6ZX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="twNAQ6ZX" Received: by smtp.kernel.org (Postfix) with ESMTPS id 00E62C2BCF6; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468058; bh=cUU49IwGzqomXwO+cbWgn3tRrnMtke2zHDK1OHMoFXs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=twNAQ6ZXPsLWL3y2/QHrNrPaeWASsZCfrh8Sa7ke59NY8qdl5V4oExBq7r39aLJcb 4VExkpmvPjPXX8u8ZBbeo+UQcr9Hi9ACOl+1sscr2XY2sttnYUHdf1cHuTcS/eV8Vy GR06DitJ1lC5OlTaqaVXtqBz1ZHRK42SRf+UQpKdgh2pudlBJCrETTQo9rVszFN1+l R12esaiF11487MrOybWVlPtLyl6XBeOfkTBm3yvC7YasjKh0oM3XQ7LQzw6oUTLN7R W2zMEj3qbG7fxoTvNvoau0AwLDWTXRLze9euac/zOrZ/xpIk9ROYBOBGFmITeCpYrZ tMHe5j0TjFrSQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECD5ECCF9E3; Wed, 29 Apr 2026 13:07:37 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:37 +0100 Subject: [PATCH v4 07/13] iio: dac: ad5686: remove redundant register definition Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-7-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar , Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=2960; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=pwWvV2HjzWSFMct9O8d223hNHPcXUCQE4vnfDjAN1E0=; b=CkzubH4KB8VSnQAdtJ0AbC6i7+Kq5M3Jzd0AC2d0shIhg4Mz5FyD2m4ay7KHFNOqwbNMQl2go e19shlKquVwCwHE9pM7T43dg2NvSb188WtMYUFC/LHA4AM9PrH+OzuE X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar AD5683_REGMAP and AD5693_REGMAP behave the same way in the common code, and that is because they target single channel devices from the same sub-family. There is no reason to separate them and it will make things simpler when refactoring the chip info table. Reviewed-by: Andy Shevchenko Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 19 +++++-------------- drivers/iio/dac/ad5686.h | 2 -- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 572dcc918ef2..d9bab8d7bcb0 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -112,10 +112,6 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_d= ev *indio_dev, if (chan->channel > 0x7) address =3D 0x8; break; - case AD5693_REGMAP: - shift =3D 13; - ref_bit_msk =3D AD5693_REF_BIT_MSK; - break; default: return -EINVAL; } @@ -296,7 +292,7 @@ static const struct ad5686_chip_info ad5686_chip_info_t= bl[] =3D { .channels =3D ad5311r_channels, .int_vref_mv =3D 2500, .num_channels =3D 1, - .regmap_type =3D AD5693_REGMAP, + .regmap_type =3D AD5683_REGMAP, }, [ID_AD5337R] =3D { .channels =3D ad5337r_channels, @@ -418,24 +414,24 @@ static const struct ad5686_chip_info ad5686_chip_info= _tbl[] =3D { .channels =3D ad5691r_channels, .int_vref_mv =3D 2500, .num_channels =3D 1, - .regmap_type =3D AD5693_REGMAP, + .regmap_type =3D AD5683_REGMAP, }, [ID_AD5692R] =3D { .channels =3D ad5692r_channels, .int_vref_mv =3D 2500, .num_channels =3D 1, - .regmap_type =3D AD5693_REGMAP, + .regmap_type =3D AD5683_REGMAP, }, [ID_AD5693] =3D { .channels =3D ad5693_channels, .num_channels =3D 1, - .regmap_type =3D AD5693_REGMAP, + .regmap_type =3D AD5683_REGMAP, }, [ID_AD5693R] =3D { .channels =3D ad5693_channels, .int_vref_mv =3D 2500, .num_channels =3D 1, - .regmap_type =3D AD5693_REGMAP, + .regmap_type =3D AD5683_REGMAP, }, [ID_AD5694] =3D { .channels =3D ad5684_channels, @@ -536,11 +532,6 @@ int ad5686_probe(struct device *dev, cmd =3D AD5686_CMD_INTERNAL_REFER_SETUP; ref_bit_msk =3D AD5686_REF_BIT_MSK; break; - case AD5693_REGMAP: - cmd =3D AD5686_CMD_CONTROL_REG; - ref_bit_msk =3D AD5693_REF_BIT_MSK; - st->use_internal_vref =3D !has_external_vref; - break; default: return -EINVAL; } diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index d08160e7fad9..af15994c01ad 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -46,7 +46,6 @@ #define AD5310_REF_BIT_MSK BIT(8) #define AD5683_REF_BIT_MSK BIT(12) #define AD5686_REF_BIT_MSK BIT(0) -#define AD5693_REF_BIT_MSK BIT(12) =20 /** * ad5686_supported_device_ids: @@ -89,7 +88,6 @@ enum ad5686_regmap_type { AD5310_REGMAP, AD5683_REGMAP, AD5686_REGMAP, - AD5693_REGMAP }; =20 struct ad5686_state; --=20 2.43.0 From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 70E7C3FCB00; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=JCXRMcaiqVHODxjkxb8oRzcVsK7BQ6r2TAX88/4/7xlFiJtbQgScERXJmW3Rt+6E8fomm+JI/m6OVc42G229jj0raxAB6HhJ1LWODIqScr3prNIbK8kikQ8Mpvx1uwDGrN85Bk37YECqEVrLbP8yCyY/wG//spuUcHBAbwId8PM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=j5t4lvD/UTSoDQysnRCzH8RKlbZXZ9fjhAXlQWqxxkE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RLvXHpoXck/pTHKrI5Y9OYtuQJ4LYW8mriF1Cz3dQfxyLNbiZ8z8E/zUhswN4JBQLr0JsoOSm+s5n9TG+OjeUJw/S3MF+ZsKl/+sxxFI8b6yzSVL64eYKOkYLDHcuQgFSQmxqbADG65yxRMRkCRox8SSs28p2uOStQvn9g/vC54= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Yp/C7xcD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Yp/C7xcD" Received: by smtp.kernel.org (Postfix) with ESMTPS id 15653C19425; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468058; bh=j5t4lvD/UTSoDQysnRCzH8RKlbZXZ9fjhAXlQWqxxkE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Yp/C7xcDPsw8hogG5O5f7so7Pg2iGt3zpRFtHeCztnWZABHey0jjbEbiqeA9T6esi eusC92P8ZPf9B/51NDdkwE92GDRQP51P9FfogVYiPECZkaYD/SCRg4BTBQAGGnS3lj D04CbUF5nvcEUKW2sRKAwsnbc8mufZZhZd6g/NqCDbVRNk3F+Gckx5B49R0b+1VOYI vxWcFEOgOIn4nyUrjjIfEQBZzFdqFgeNIH71DGZL2M8ke/3fD8Ti2IY3ZI1gesSdSI tIU6IqUwV/NLbszPg48P77NK+WqYSfgrzFIXh+xwr32bywVCwB5fn1u3DQtFEyU+kS n3phiWUNizAww== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DEEBFF8867; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:38 +0100 Subject: [PATCH v4 08/13] iio: dac: ad5686: drop enum id Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-8-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar , Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=20169; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=I49Ws6Otsq7NhNVy0AKvwo0tq/6AM6B9Z62kb2ELIIo=; b=SrkNcr/GDDbNYQULgG8sUYrDnb5nCzWtgvZib5TMeEdfqhUfv4U+CLWeFIXTJ/LYwpSadv9IW Z71eNrG+BVJCKbqYLL+/QptL78rf3AtTCt2jDiftTzvpp6pp8iytv2Z X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Split chip info table into separate structs and expose them to the spi i2c drivers. That is the preferrable approach and allows for the drivers to have knowledge of the device info before the common probe function gets called. Those chip info structs may be shared by SPI and I2C driver variants. Channel declaration definitions are grouped according to channel count and DECLARE_AD5693_CHANNELS() macro is renamed to DECLARE_AD5683_CHANNELS() to match the regmap_type enum. Use spi_get_device_match_data() and i2c_get_match_data() to get chip info struct reference, passing it as parameter to the core probe function. Reviewed-by: Andy Shevchenko Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686-spi.c | 38 +++-- drivers/iio/dac/ad5686.c | 358 ++++++++++++++++++++-------------------= ---- drivers/iio/dac/ad5686.h | 66 ++++---- drivers/iio/dac/ad5696-i2c.c | 65 ++++---- 4 files changed, 241 insertions(+), 286 deletions(-) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index cec784b617e6..5cf60a6e19d1 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -94,29 +94,27 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 = addr) =20 static int ad5686_spi_probe(struct spi_device *spi) { - const struct spi_device_id *id =3D spi_get_device_id(spi); - - return ad5686_probe(&spi->dev, id->driver_data, id->name, - ad5686_spi_write, ad5686_spi_read); + return ad5686_probe(&spi->dev, spi_get_device_match_data(spi), + spi->modalias, ad5686_spi_write, ad5686_spi_read); } =20 static const struct spi_device_id ad5686_spi_id[] =3D { - {"ad5310r", ID_AD5310R}, - {"ad5672r", ID_AD5672R}, - {"ad5674r", ID_AD5674R}, - {"ad5676", ID_AD5676}, - {"ad5676r", ID_AD5676R}, - {"ad5679r", ID_AD5679R}, - {"ad5681r", ID_AD5681R}, - {"ad5682r", ID_AD5682R}, - {"ad5683", ID_AD5683}, - {"ad5683r", ID_AD5683R}, - {"ad5684", ID_AD5684}, - {"ad5684r", ID_AD5684R}, - {"ad5685", ID_AD5685R}, /* Does not exist */ - {"ad5685r", ID_AD5685R}, - {"ad5686", ID_AD5686}, - {"ad5686r", ID_AD5686R}, + { "ad5310r", (kernel_ulong_t)&ad5310r_chip_info }, + { "ad5672r", (kernel_ulong_t)&ad5672r_chip_info }, + { "ad5674r", (kernel_ulong_t)&ad5674r_chip_info }, + { "ad5676", (kernel_ulong_t)&ad5676_chip_info }, + { "ad5676r", (kernel_ulong_t)&ad5676r_chip_info }, + { "ad5679r", (kernel_ulong_t)&ad5679r_chip_info }, + { "ad5681r", (kernel_ulong_t)&ad5681r_chip_info }, + { "ad5682r", (kernel_ulong_t)&ad5682r_chip_info }, + { "ad5683", (kernel_ulong_t)&ad5683_chip_info }, + { "ad5683r", (kernel_ulong_t)&ad5683r_chip_info }, + { "ad5684", (kernel_ulong_t)&ad5684_chip_info }, + { "ad5684r", (kernel_ulong_t)&ad5684r_chip_info }, + { "ad5685", (kernel_ulong_t)&ad5685r_chip_info }, /* Does not exist */ + { "ad5685r", (kernel_ulong_t)&ad5685r_chip_info }, + { "ad5686", (kernel_ulong_t)&ad5686_chip_info }, + { "ad5686r", (kernel_ulong_t)&ad5686r_chip_info }, { } }; MODULE_DEVICE_TABLE(spi, ad5686_spi_id); diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index d9bab8d7bcb0..4bcabdbaf1d8 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -215,7 +215,7 @@ static const struct iio_chan_spec_ext_info ad5686_ext_i= nfo[] =3D { .ext_info =3D ad5686_ext_info, \ } =20 -#define DECLARE_AD5693_CHANNELS(name, bits, _shift) \ +#define DECLARE_AD5683_CHANNELS(name, bits, _shift) \ static const struct iio_chan_spec name[] =3D { \ AD5868_CHANNEL(0, 0, bits, _shift), \ } @@ -266,205 +266,172 @@ static const struct iio_chan_spec name[] =3D { \ AD5868_CHANNEL(15, 15, bits, _shift), \ } =20 -DECLARE_AD5693_CHANNELS(ad5310r_channels, 10, 2); -DECLARE_AD5693_CHANNELS(ad5311r_channels, 10, 6); +/* single-channel */ +DECLARE_AD5683_CHANNELS(ad5310r_channels, 10, 2); +DECLARE_AD5683_CHANNELS(ad5311r_channels, 10, 6); +DECLARE_AD5683_CHANNELS(ad5681r_channels, 12, 4); +DECLARE_AD5683_CHANNELS(ad5682r_channels, 14, 2); +DECLARE_AD5683_CHANNELS(ad5683r_channels, 16, 0); + +/* dual-channel */ DECLARE_AD5338_CHANNELS(ad5337r_channels, 8, 8); DECLARE_AD5338_CHANNELS(ad5338r_channels, 10, 6); -DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4); -DECLARE_AD5679_CHANNELS(ad5674r_channels, 12, 4); -DECLARE_AD5676_CHANNELS(ad5676_channels, 16, 0); -DECLARE_AD5679_CHANNELS(ad5679r_channels, 16, 0); -DECLARE_AD5686_CHANNELS(ad5684_channels, 12, 4); -DECLARE_AD5686_CHANNELS(ad5685r_channels, 14, 2); -DECLARE_AD5686_CHANNELS(ad5686_channels, 16, 0); -DECLARE_AD5693_CHANNELS(ad5693_channels, 16, 0); -DECLARE_AD5693_CHANNELS(ad5692r_channels, 14, 2); -DECLARE_AD5693_CHANNELS(ad5691r_channels, 12, 4); =20 -static const struct ad5686_chip_info ad5686_chip_info_tbl[] =3D { - [ID_AD5310R] =3D { - .channels =3D ad5310r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5310_REGMAP, - }, - [ID_AD5311R] =3D { - .channels =3D ad5311r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5337R] =3D { - .channels =3D ad5337r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 2, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5338R] =3D { - .channels =3D ad5338r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 2, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5671R] =3D { - .channels =3D ad5672_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 8, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5672R] =3D { - .channels =3D ad5672_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 8, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5673R] =3D { - .channels =3D ad5674r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 16, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5674R] =3D { - .channels =3D ad5674r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 16, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5675R] =3D { - .channels =3D ad5676_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 8, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5676] =3D { - .channels =3D ad5676_channels, - .num_channels =3D 8, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5676R] =3D { - .channels =3D ad5676_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 8, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5677R] =3D { - .channels =3D ad5679r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 16, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5679R] =3D { - .channels =3D ad5679r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 16, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5681R] =3D { - .channels =3D ad5691r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5682R] =3D { - .channels =3D ad5692r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5683] =3D { - .channels =3D ad5693_channels, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5683R] =3D { - .channels =3D ad5693_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5684] =3D { - .channels =3D ad5684_channels, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5684R] =3D { - .channels =3D ad5684_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5685R] =3D { - .channels =3D ad5685r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5686] =3D { - .channels =3D ad5686_channels, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5686R] =3D { - .channels =3D ad5686_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5691R] =3D { - .channels =3D ad5691r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5692R] =3D { - .channels =3D ad5692r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5693] =3D { - .channels =3D ad5693_channels, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5693R] =3D { - .channels =3D ad5693_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5694] =3D { - .channels =3D ad5684_channels, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5694R] =3D { - .channels =3D ad5684_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5695R] =3D { - .channels =3D ad5685r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5696] =3D { - .channels =3D ad5686_channels, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5696R] =3D { - .channels =3D ad5686_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, +/* quad-channel */ +DECLARE_AD5686_CHANNELS(ad5684r_channels, 12, 4); +DECLARE_AD5686_CHANNELS(ad5685r_channels, 14, 2); +DECLARE_AD5686_CHANNELS(ad5686r_channels, 16, 0); + +/* 8-channel */ +DECLARE_AD5676_CHANNELS(ad5672r_channels, 12, 4); +DECLARE_AD5676_CHANNELS(ad5676r_channels, 16, 0); + +/* 16-channel */ +DECLARE_AD5679_CHANNELS(ad5674r_channels, 12, 4); +DECLARE_AD5679_CHANNELS(ad5679r_channels, 16, 0); + +const struct ad5686_chip_info ad5310r_chip_info =3D { + .channels =3D ad5310r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 1, + .regmap_type =3D AD5310_REGMAP, }; +EXPORT_SYMBOL_NS_GPL(ad5310r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5311r_chip_info =3D { + .channels =3D ad5311r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 1, + .regmap_type =3D AD5683_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5311r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5681r_chip_info =3D { + .channels =3D ad5681r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 1, + .regmap_type =3D AD5683_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5681r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5682r_chip_info =3D { + .channels =3D ad5682r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 1, + .regmap_type =3D AD5683_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5682r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5683_chip_info =3D { + .channels =3D ad5683r_channels, + .num_channels =3D 1, + .regmap_type =3D AD5683_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5683_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5683r_chip_info =3D { + .channels =3D ad5683r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 1, + .regmap_type =3D AD5683_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5683r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5337r_chip_info =3D { + .channels =3D ad5337r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 2, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5337r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5338r_chip_info =3D { + .channels =3D ad5338r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 2, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5338r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5684_chip_info =3D { + .channels =3D ad5684r_channels, + .num_channels =3D 4, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5684_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5684r_chip_info =3D { + .channels =3D ad5684r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 4, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5684r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5685r_chip_info =3D { + .channels =3D ad5685r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 4, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5685r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5686_chip_info =3D { + .channels =3D ad5686r_channels, + .num_channels =3D 4, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5686_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5686r_chip_info =3D { + .channels =3D ad5686r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 4, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5686r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5672r_chip_info =3D { + .channels =3D ad5672r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 8, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5672r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5676_chip_info =3D { + .channels =3D ad5676r_channels, + .num_channels =3D 8, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5676_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5676r_chip_info =3D { + .channels =3D ad5676r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 8, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5676r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5674r_chip_info =3D { + .channels =3D ad5674r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 16, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5674r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5679r_chip_info =3D { + .channels =3D ad5679r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 16, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5679r_chip_info, "IIO_AD5686"); =20 int ad5686_probe(struct device *dev, - enum ad5686_supported_device_ids chip_type, + const struct ad5686_chip_info *chip_info, const char *name, ad5686_write_func write, ad5686_read_func read) { @@ -484,8 +451,7 @@ int ad5686_probe(struct device *dev, st->dev =3D dev; st->write =3D write; st->read =3D read; - - st->chip_info =3D &ad5686_chip_info_tbl[chip_type]; + st->chip_info =3D chip_info; =20 ret =3D devm_regulator_get_enable_read_voltage(dev, "vcc"); if (ret < 0 && ret !=3D -ENODEV) diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index af15994c01ad..caadc7403da1 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -47,42 +47,6 @@ #define AD5683_REF_BIT_MSK BIT(12) #define AD5686_REF_BIT_MSK BIT(0) =20 -/** - * ad5686_supported_device_ids: - */ -enum ad5686_supported_device_ids { - ID_AD5310R, - ID_AD5311R, - ID_AD5337R, - ID_AD5338R, - ID_AD5671R, - ID_AD5672R, - ID_AD5673R, - ID_AD5674R, - ID_AD5675R, - ID_AD5676, - ID_AD5676R, - ID_AD5677R, - ID_AD5679R, - ID_AD5681R, - ID_AD5682R, - ID_AD5683, - ID_AD5683R, - ID_AD5684, - ID_AD5684R, - ID_AD5685R, - ID_AD5686, - ID_AD5686R, - ID_AD5691R, - ID_AD5692R, - ID_AD5693, - ID_AD5693R, - ID_AD5694, - ID_AD5694R, - ID_AD5695R, - ID_AD5696, - ID_AD5696R, -}; =20 enum ad5686_regmap_type { AD5310_REGMAP, @@ -112,6 +76,34 @@ struct ad5686_chip_info { enum ad5686_regmap_type regmap_type; }; =20 +/* single-channel instances */ +extern const struct ad5686_chip_info ad5310r_chip_info; +extern const struct ad5686_chip_info ad5311r_chip_info; +extern const struct ad5686_chip_info ad5681r_chip_info; +extern const struct ad5686_chip_info ad5682r_chip_info; +extern const struct ad5686_chip_info ad5683_chip_info; +extern const struct ad5686_chip_info ad5683r_chip_info; + +/* dual-channel instances */ +extern const struct ad5686_chip_info ad5337r_chip_info; +extern const struct ad5686_chip_info ad5338r_chip_info; + +/* quad-channel instances */ +extern const struct ad5686_chip_info ad5684_chip_info; +extern const struct ad5686_chip_info ad5684r_chip_info; +extern const struct ad5686_chip_info ad5685r_chip_info; +extern const struct ad5686_chip_info ad5686_chip_info; +extern const struct ad5686_chip_info ad5686r_chip_info; + +/* 8-channel instances */ +extern const struct ad5686_chip_info ad5672r_chip_info; +extern const struct ad5686_chip_info ad5676_chip_info; +extern const struct ad5686_chip_info ad5676r_chip_info; + +/* 16-channel instances */ +extern const struct ad5686_chip_info ad5674r_chip_info; +extern const struct ad5686_chip_info ad5679r_chip_info; + /** * struct ad5686_state - driver instance specific data * @spi: spi_device @@ -149,7 +141,7 @@ struct ad5686_state { =20 =20 int ad5686_probe(struct device *dev, - enum ad5686_supported_device_ids chip_type, + const struct ad5686_chip_info *chip_info, const char *name, ad5686_write_func write, ad5686_read_func read); =20 diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index 5b5b30f586c1..6943616eace3 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -64,47 +64,46 @@ static int ad5686_i2c_write(struct ad5686_state *st, =20 static int ad5686_i2c_probe(struct i2c_client *i2c) { - const struct i2c_device_id *id =3D i2c_client_get_device_id(i2c); - return ad5686_probe(&i2c->dev, id->driver_data, id->name, - ad5686_i2c_write, ad5686_i2c_read); + return ad5686_probe(&i2c->dev, i2c_get_match_data(i2c), + i2c->name, ad5686_i2c_write, ad5686_i2c_read); } =20 static const struct i2c_device_id ad5686_i2c_id[] =3D { - {"ad5311r", ID_AD5311R}, - {"ad5337r", ID_AD5337R}, - {"ad5338r", ID_AD5338R}, - {"ad5671r", ID_AD5671R}, - {"ad5673r", ID_AD5673R}, - {"ad5675r", ID_AD5675R}, - {"ad5677r", ID_AD5677R}, - {"ad5691r", ID_AD5691R}, - {"ad5692r", ID_AD5692R}, - {"ad5693", ID_AD5693}, - {"ad5693r", ID_AD5693R}, - {"ad5694", ID_AD5694}, - {"ad5694r", ID_AD5694R}, - {"ad5695r", ID_AD5695R}, - {"ad5696", ID_AD5696}, - {"ad5696r", ID_AD5696R}, + { "ad5311r", (kernel_ulong_t)&ad5311r_chip_info }, + { "ad5337r", (kernel_ulong_t)&ad5337r_chip_info }, + { "ad5338r", (kernel_ulong_t)&ad5338r_chip_info }, + { "ad5671r", (kernel_ulong_t)&ad5672r_chip_info }, + { "ad5673r", (kernel_ulong_t)&ad5674r_chip_info }, + { "ad5675r", (kernel_ulong_t)&ad5676r_chip_info }, + { "ad5677r", (kernel_ulong_t)&ad5679r_chip_info }, + { "ad5691r", (kernel_ulong_t)&ad5681r_chip_info }, + { "ad5692r", (kernel_ulong_t)&ad5682r_chip_info }, + { "ad5693", (kernel_ulong_t)&ad5683_chip_info }, + { "ad5693r", (kernel_ulong_t)&ad5683r_chip_info }, + { "ad5694", (kernel_ulong_t)&ad5684_chip_info }, + { "ad5694r", (kernel_ulong_t)&ad5684r_chip_info }, + { "ad5695r", (kernel_ulong_t)&ad5685r_chip_info }, + { "ad5696", (kernel_ulong_t)&ad5686_chip_info }, + { "ad5696r", (kernel_ulong_t)&ad5686r_chip_info }, { } }; MODULE_DEVICE_TABLE(i2c, ad5686_i2c_id); =20 static const struct of_device_id ad5686_of_match[] =3D { - { .compatible =3D "adi,ad5311r" }, - { .compatible =3D "adi,ad5337r" }, - { .compatible =3D "adi,ad5338r" }, - { .compatible =3D "adi,ad5671r" }, - { .compatible =3D "adi,ad5675r" }, - { .compatible =3D "adi,ad5691r" }, - { .compatible =3D "adi,ad5692r" }, - { .compatible =3D "adi,ad5693" }, - { .compatible =3D "adi,ad5693r" }, - { .compatible =3D "adi,ad5694" }, - { .compatible =3D "adi,ad5694r" }, - { .compatible =3D "adi,ad5695r" }, - { .compatible =3D "adi,ad5696" }, - { .compatible =3D "adi,ad5696r" }, + { .compatible =3D "adi,ad5311r", .data =3D &ad5311r_chip_info }, + { .compatible =3D "adi,ad5337r", .data =3D &ad5337r_chip_info }, + { .compatible =3D "adi,ad5338r", .data =3D &ad5338r_chip_info }, + { .compatible =3D "adi,ad5671r", .data =3D &ad5672r_chip_info }, + { .compatible =3D "adi,ad5675r", .data =3D &ad5676r_chip_info }, + { .compatible =3D "adi,ad5691r", .data =3D &ad5681r_chip_info }, + { .compatible =3D "adi,ad5692r", .data =3D &ad5682r_chip_info }, + { .compatible =3D "adi,ad5693", .data =3D &ad5683_chip_info }, + { .compatible =3D "adi,ad5693r", .data =3D &ad5683r_chip_info }, + { .compatible =3D "adi,ad5694", .data =3D &ad5684_chip_info }, + { .compatible =3D "adi,ad5694r", .data =3D &ad5684r_chip_info }, + { .compatible =3D "adi,ad5695r", .data =3D &ad5685r_chip_info }, + { .compatible =3D "adi,ad5696", .data =3D &ad5686_chip_info }, + { .compatible =3D "adi,ad5696r", .data =3D &ad5686r_chip_info }, { } }; MODULE_DEVICE_TABLE(of, ad5686_of_match); --=20 2.43.0 From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 70A7D3FBEDF; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=UIH/e3lX7X9E4FscKAPpXV6iCyYxxB6lfMYFkIcNWUe7WGABeK8EyD/qJZdsHMIgISQuAG6EAdO9vGBlkzsvEed0zqf5BbhckxuMg2ximkMfnJDO8udMHbhvUzNo2Z1Sx6VAZcyHeXF6YS3JYTabd8cTpxuwB9voHRzVpCOtxco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=5OQ30KArxmdJ4d84VYLW3NcLCUWs3NbxBmlSWwWqBIk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j0nApICHIJTSYG3nRpqF6Djpb3rH2OgJaIlyIe0DiDoYudhb1bMNaaTmq71DENgkQABDqZXkOupPWTisUmoBFVutuJeTfDbE9xgJM9GngOKQQuZYkAi38Nk13TmA9HqADB4TnrDB33kRKrEu9mEQjG+etCs5rOalZULgBH1P3S4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i3fL1g21; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i3fL1g21" Received: by smtp.kernel.org (Postfix) with ESMTPS id 283B5C2BCB8; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468058; bh=5OQ30KArxmdJ4d84VYLW3NcLCUWs3NbxBmlSWwWqBIk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=i3fL1g21AGHB2OnY1/IOz+vZCfJ7vVQ+UIXUoDQJ1kDAFducX7lKrC2gD8vt/RGT1 gCowmuyC6utVbwrvO4ol87Pj9RaC/rHXZvid+TbZZfhnq/+YxDLjpNJF1W9CgFrOEh nOoLZyayH6XvcBH5rCm3W5SWCgYz1RkU3XM77OnL1srCFCTEAd8rKcEH4qwrE4w7mK zl0SmCYwSlwlTU0OS8tYTwUBdlWVyLydoIa59N2aCv7pzE0TkwuOnCzUwSt9reZvu9 RDd2zxdTgRvpbBjV5x23S33LDeQT4TjI196onq4qWyeRXiB/7hF0vOhWG6qiOlNqKe hOKAmZ2L2gLDA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F905CCFA13; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:39 +0100 Subject: [PATCH v4 09/13] iio: dac: ad5686: add of_match table to the spi driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-9-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar , Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=1909; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=wFk8LhEhsvyl3awicLq5nznLuet66NPWLXqtRqBdDRo=; b=Uy1DSFQruTXgTBzSVnGSQhz9L1j8GGk318zwa0z2EY1yCRgk0nvkS6dSR3klKv035+utIAPVZ jofZDvaHFZZBYLVaP1O/dITQBKI+3caZYpSIWuHaiin/2SuB9zAjC/c X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Add of_match table for the SPI device variants to be consistent with the AD5696 I2C driver. Reviewed-by: Andy Shevchenko Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686-spi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index 5cf60a6e19d1..9493511d9e7f 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -119,9 +119,30 @@ static const struct spi_device_id ad5686_spi_id[] =3D { }; MODULE_DEVICE_TABLE(spi, ad5686_spi_id); =20 +static const struct of_device_id ad5686_of_match[] =3D { + { .compatible =3D "adi,ad5310r", .data =3D &ad5310r_chip_info }, + { .compatible =3D "adi,ad5672r", .data =3D &ad5672r_chip_info }, + { .compatible =3D "adi,ad5674r", .data =3D &ad5674r_chip_info }, + { .compatible =3D "adi,ad5676", .data =3D &ad5676_chip_info }, + { .compatible =3D "adi,ad5676r", .data =3D &ad5676r_chip_info }, + { .compatible =3D "adi,ad5679r", .data =3D &ad5679r_chip_info }, + { .compatible =3D "adi,ad5681r", .data =3D &ad5681r_chip_info }, + { .compatible =3D "adi,ad5682r", .data =3D &ad5682r_chip_info }, + { .compatible =3D "adi,ad5683", .data =3D &ad5683_chip_info }, + { .compatible =3D "adi,ad5683r", .data =3D &ad5683r_chip_info }, + { .compatible =3D "adi,ad5684", .data =3D &ad5684_chip_info }, + { .compatible =3D "adi,ad5684r", .data =3D &ad5684r_chip_info }, + { .compatible =3D "adi,ad5685r", .data =3D &ad5685r_chip_info }, + { .compatible =3D "adi,ad5686", .data =3D &ad5686_chip_info }, + { .compatible =3D "adi,ad5686r", .data =3D &ad5686r_chip_info }, + { } +}; +MODULE_DEVICE_TABLE(of, ad5686_of_match); + static struct spi_driver ad5686_spi_driver =3D { .driver =3D { .name =3D "ad5686", + .of_match_table =3D ad5686_of_match, }, .probe =3D ad5686_spi_probe, .id_table =3D ad5686_spi_id, --=20 2.43.0 From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 574423FBED1; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=XyUObtFKHnYFl7yWDLJ7ALWP72HocvY3VxBo+kE/4+bQgqM2jv8gc04l5QSHqXHbAcvTJomozZwLxaZMQC03ppAoUNRwDcwx83FnEY59ClaixKGdk6+8Ws0v/Y+MJ3CSYOKRTGsZ3uXI3ar9X5tRfX1/4PVWQ66j6LX0yeTIaFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=ofi5Nr2V7S4nqvAUGiuyQ9AB3wCRZIur4VO+quE7/no=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SqIS6gMaY8SpA96QL62ljThLIMW3TCjHKg9cZGuXDhBJj+caMI2RJ5fq8ElBYJweMvgG5GBT7BdtSZAoFvizExKODkhwp+F+trxR7iSevJy8P2PqnDmtTgj5+qK4YlA7a3xPW/phVaUd+OHnwQEHLOtix6GaTkTGKV+CWaDhnF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=smnDo1Va; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="smnDo1Va" Received: by smtp.kernel.org (Postfix) with ESMTPS id 37972C2BCC6; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468058; bh=ofi5Nr2V7S4nqvAUGiuyQ9AB3wCRZIur4VO+quE7/no=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=smnDo1Va4UHhQPACWpkKJE7xz1e6CUx0vn7AxEYwdS5YUQmxkhpG3abEZaIfhso2Z KP2zfTJSoPabHgaTSg5vBKjRcQPdtnuXt16hUyMy7glm5nn0K8zZRXJb5h3xc8FyOX AvNI78nPaSn9lZ9ZAGsSCIaQIYpQ3s95dLS4MWTZk0UzXprfcR+4OXYLZsZfsB5xQk ng+IuSpNcuni7ZwElUmVwfjOXet/jOPHqN6yIjveEMPA2ZcJ97YZH8QjtmZLwAPVT4 rxFyzUTRhKfgtMc1wFT+HHjDaKmi9NjDOAKBH7PIOOCvZ4LSLqKsVwa0ycxqJvTGUg XwsjrNwSL0jgA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 308E4CCF9E3; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:40 +0100 Subject: [PATCH v4 10/13] iio: dac: ad5686: remove powerdown mask magic number Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-10-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=2952; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=x+f5X9G+QgQmbzFHF+5ueLvHY+KAC7dvWbfcoQHYU34=; b=X2uVsE4M/sgiAOEaPE2oy3tNs+ey1gwQCHd2/J4JwZu3egSDguRYLm7Ok+A6/Kr4YVErYcQD8 ZYhNTC83U81A7ZC8dH0fTfHk7eyABP16PBLY8AGPZxcyNxSE5KzeqF8 X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Define macro AD5686_PD_MSK to hold powerdown mask value. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 16 ++++++++-------- drivers/iio/dac/ad5686.h | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 4bcabdbaf1d8..0590716191c1 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -39,7 +39,7 @@ static int ad5686_get_powerdown_mode(struct iio_dev *indi= o_dev, unsigned int shift =3D ad5686_pd_mask_shift(chan); struct ad5686_state *st =3D iio_priv(indio_dev); =20 - return ((st->pwr_down_mode >> shift) & 0x3) - 1; + return ((st->pwr_down_mode >> shift) & AD5686_PD_MSK) - 1; } =20 static int ad5686_set_powerdown_mode(struct iio_dev *indio_dev, @@ -51,8 +51,8 @@ static int ad5686_set_powerdown_mode(struct iio_dev *indi= o_dev, =20 guard(mutex)(&st->lock); =20 - st->pwr_down_mode &=3D ~(0x3 << shift); - st->pwr_down_mode |=3D (mode + 1) << shift; + st->pwr_down_mode &=3D ~(AD5686_PD_MSK << shift); + st->pwr_down_mode |=3D ((mode + 1) & AD5686_PD_MSK) << shift; =20 return 0; } @@ -70,7 +70,7 @@ static ssize_t ad5686_read_dac_powerdown(struct iio_dev *= indio_dev, unsigned int shift =3D ad5686_pd_mask_shift(chan); struct ad5686_state *st =3D iio_priv(indio_dev); =20 - return sysfs_emit(buf, "%d\n", !!(st->pwr_down_mask & (0x3 << shift))); + return sysfs_emit(buf, "%d\n", !!(st->pwr_down_mask & (AD5686_PD_MSK << s= hift))); } =20 static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev, @@ -92,9 +92,9 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev = *indio_dev, guard(mutex)(&st->lock); =20 if (readin) - st->pwr_down_mask |=3D 0x3 << ad5686_pd_mask_shift(chan); + st->pwr_down_mask |=3D AD5686_PD_MSK << ad5686_pd_mask_shift(chan); else - st->pwr_down_mask &=3D ~(0x3 << ad5686_pd_mask_shift(chan)); + st->pwr_down_mask &=3D ~(AD5686_PD_MSK << ad5686_pd_mask_shift(chan)); =20 switch (st->chip_info->regmap_type) { case AD5310_REGMAP: @@ -468,8 +468,8 @@ int ad5686_probe(struct device *dev, /* Set all the power down mode for all channels to 1K pulldown */ for (i =3D 0; i < st->chip_info->num_channels; i++) { shift =3D ad5686_pd_mask_shift(&st->chip_info->channels[i]); - st->pwr_down_mask &=3D ~(0x3 << shift); /* powered up state */ - st->pwr_down_mode &=3D ~(0x3 << shift); + st->pwr_down_mask &=3D ~(AD5686_PD_MSK << shift); /* powered up state */ + st->pwr_down_mode &=3D ~(AD5686_PD_MSK << shift); st->pwr_down_mode |=3D 0x01 << shift; } =20 diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index caadc7403da1..b9eee3ad4dc8 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -47,6 +47,7 @@ #define AD5683_REF_BIT_MSK BIT(12) #define AD5686_REF_BIT_MSK BIT(0) =20 +#define AD5686_PD_MSK GENMASK(1, 0) =20 enum ad5686_regmap_type { AD5310_REGMAP, --=20 2.43.0 From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B92D43FCB15; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=tfX0pr/1aJBAeI2sUXtzOxKSTG2Bv68Tgu/E+L768knMRfbtVzfav4c0xT+apteC5fsRkSOZUuwMvgXROK4EH99T4r9guW8c+uiE4LveyM0eXEEzxvJ+fD0BAxI57AlkR2G3csh4xub/Vtn6WBPoenvdcvxRfRVfOFO8zfADcxg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=iPrMO31/+/fx+412Uc1izl2un9j/z5gdSUXz+F111kM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u9tPAw57SgVJE+ekDCEKOFuJiBB4gpnDsDTTj3HPyKP5qYqHwYjP+lB5pk5D6WGn7vffqkOxGO+O5fEXAZONsn3gExANS+Mp4Bn+EGJgEBwU4pyqTqC9DZjDk6qpO6YthPBlZjpSdbafklh8dFJ58trEoHvuNPEBI98focGs/i8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jTDYRP7d; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jTDYRP7d" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4C30DC2BCC4; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468058; bh=iPrMO31/+/fx+412Uc1izl2un9j/z5gdSUXz+F111kM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jTDYRP7dczKWiE2HanXF/UPJ+LsWp90A79adU3S1Sf6QkIAeyLLzlqTCi84UoYf7L UblkQ+9oPNbiyF+NV/+U/sNKtIJqtEtb3B1Uzl1Bipa2uTM4y9PGoK4eodZdqljl/M UEtJ3kTekBekj2/qwREUBfpaibRqFiPo9U2I+pIhlL9HuNivJSX9366nnRk9bmaAh9 RwZ/OlNreRMGhUeIe2q2QRN6d1tVDZgU8f2LbFgXKtCvVLZDNpv8RdekuEpTETLnq+ igBWpgxuqud/FvzBW9qIQo7i7WPMygDTZHdfWcoaJwwtKjk08+3cvdPOzj8RwIRrHn WkW36P1y+k30g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44F6BFF8875; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:41 +0100 Subject: [PATCH v4 11/13] iio: dac: ad5686: add control_sync() for single-channel devices Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-11-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar , Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=6326; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=XSe5vaMQORw7mcD7Wxjsqs0Rww8Q+L26YaLGRXd+7NI=; b=MsVJ91aG4iSfoMlGkguMQ3+Qyedj4wxkFclze1W0ylZDVt1VdyC9PsO1PlX5wscqs3Jyw0kYC BzOtaQByY2CB2bPajLWuHZ9sg5sse2xkRzP1GAtU+eXdui+IQrbBdXb X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Create ad5310_control_sync() and ad5683_control_sync() functions that properly consumes the mask definitions with FIELD_PREP(). This allows to reuse a function that updates the control register with cached values, without relying on confusing logic that depends on st->use_internal_vref, which is initialized earlier in ad5686_probe() because it is also applicable to the AD5686_REGMAP case, removing the need for the has_external_vref. The change cleans up ad5686_write_dac_powerdown() and ad5686_probe(), organizing the code for feature extension, e.g. gain control support for single-channel devices. Reviewed-by: Andy Shevchenko Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 88 ++++++++++++++++++++++++++++----------------= ---- drivers/iio/dac/ad5686.h | 7 ++-- 2 files changed, 57 insertions(+), 38 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 0590716191c1..bf3dc3903346 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -6,6 +6,7 @@ */ =20 #include +#include #include #include #include @@ -13,6 +14,7 @@ #include #include #include +#include =20 #include =20 @@ -24,6 +26,24 @@ static const char * const ad5686_powerdown_modes[] =3D { "three_state" }; =20 +static int ad5310_control_sync(struct ad5686_state *st) +{ + unsigned int pd_val =3D st->pwr_down_mask & st->pwr_down_mode; + + return st->write(st, AD5686_CMD_CONTROL_REG, 0, + FIELD_PREP(AD5310_PD_MSK, pd_val) | + FIELD_PREP(AD5310_REF_BIT_MSK, st->use_internal_vref ? 0 : 1)); +} + +static int ad5683_control_sync(struct ad5686_state *st) +{ + unsigned int pd_val =3D st->pwr_down_mask & st->pwr_down_mode; + + return st->write(st, AD5686_CMD_CONTROL_REG, 0, + FIELD_PREP(AD5683_PD_MSK, pd_val) | + FIELD_PREP(AD5683_REF_BIT_MSK, st->use_internal_vref ? 0 : 1)); +} + static inline unsigned int ad5686_pd_mask_shift(const struct iio_chan_spec= *chan) { if (chan->channel =3D=3D chan->address) @@ -82,8 +102,8 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev= *indio_dev, bool readin; int ret; struct ad5686_state *st =3D iio_priv(indio_dev); - unsigned int val, ref_bit_msk; - u8 shift, address =3D 0; + unsigned int val; + u8 address; =20 ret =3D kstrtobool(buf, &readin); if (ret) @@ -98,32 +118,34 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_d= ev *indio_dev, =20 switch (st->chip_info->regmap_type) { case AD5310_REGMAP: - shift =3D 9; - ref_bit_msk =3D AD5310_REF_BIT_MSK; + ret =3D ad5310_control_sync(st); + if (ret) + return ret; break; case AD5683_REGMAP: - shift =3D 13; - ref_bit_msk =3D AD5683_REF_BIT_MSK; + ret =3D ad5683_control_sync(st); + if (ret) + return ret; break; case AD5686_REGMAP: - shift =3D 0; - ref_bit_msk =3D 0; /* AD5674R/AD5679R have 16 channels and 2 powerdown registers */ - if (chan->channel > 0x7) + val =3D st->pwr_down_mask & st->pwr_down_mode; + if (chan->channel > 0x7) { address =3D 0x8; + val =3D upper_16_bits(val); + } else { + address =3D 0x0; + val =3D lower_16_bits(val); + } + ret =3D st->write(st, AD5686_CMD_POWERDOWN_DAC, address, val); + if (ret) + return ret; break; default: return -EINVAL; } =20 - val =3D ((st->pwr_down_mask & st->pwr_down_mode) << shift); - if (!st->use_internal_vref) - val |=3D ref_bit_msk; - - ret =3D st->write(st, AD5686_CMD_POWERDOWN_DAC, - address, val >> (address * 2)); - - return ret ? ret : len; + return len; } =20 static int ad5686_read_raw(struct iio_dev *indio_dev, @@ -437,9 +459,7 @@ int ad5686_probe(struct device *dev, { struct ad5686_state *st; struct iio_dev *indio_dev; - unsigned int val, ref_bit_msk, shift; - bool has_external_vref; - u8 cmd; + unsigned int shift; int ret, i; =20 indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); @@ -457,8 +477,8 @@ int ad5686_probe(struct device *dev, if (ret < 0 && ret !=3D -ENODEV) return ret; =20 - has_external_vref =3D ret !=3D -ENODEV; - st->vref_mv =3D has_external_vref ? ret / 1000 : st->chip_info->int_vref_= mv; + st->use_internal_vref =3D ret =3D=3D -ENODEV; + st->vref_mv =3D st->use_internal_vref ? st->chip_info->int_vref_mv : ret = / 1000; =20 /* Initialize masks to all ones provided the max shift (last channel) */ shift =3D ad5686_pd_mask_shift(&st->chip_info->channels[st->chip_info->nu= m_channels - 1]); @@ -485,29 +505,25 @@ int ad5686_probe(struct device *dev, =20 switch (st->chip_info->regmap_type) { case AD5310_REGMAP: - cmd =3D AD5686_CMD_CONTROL_REG; - ref_bit_msk =3D AD5310_REF_BIT_MSK; - st->use_internal_vref =3D !has_external_vref; + ret =3D ad5310_control_sync(st); + if (ret) + return ret; break; case AD5683_REGMAP: - cmd =3D AD5686_CMD_CONTROL_REG; - ref_bit_msk =3D AD5683_REF_BIT_MSK; - st->use_internal_vref =3D !has_external_vref; + ret =3D ad5683_control_sync(st); + if (ret) + return ret; break; case AD5686_REGMAP: - cmd =3D AD5686_CMD_INTERNAL_REFER_SETUP; - ref_bit_msk =3D AD5686_REF_BIT_MSK; + ret =3D st->write(st, AD5686_CMD_INTERNAL_REFER_SETUP, 0, + st->use_internal_vref ? 0 : AD5686_REF_BIT_MSK); + if (ret) + return ret; break; default: return -EINVAL; } =20 - val =3D has_external_vref ? ref_bit_msk : 0; - - ret =3D st->write(st, cmd, 0, val); - if (ret) - return ret; - return devm_iio_device_register(dev, indio_dev); } EXPORT_SYMBOL_NS_GPL(ad5686_probe, "IIO_AD5686"); diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index b9eee3ad4dc8..0ba4168195f5 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -44,9 +44,12 @@ #define AD5686_CMD_READBACK_ENABLE_V2 0x5 =20 #define AD5310_REF_BIT_MSK BIT(8) -#define AD5683_REF_BIT_MSK BIT(12) -#define AD5686_REF_BIT_MSK BIT(0) +#define AD5310_PD_MSK GENMASK(10, 9) =20 +#define AD5683_REF_BIT_MSK BIT(12) +#define AD5683_PD_MSK GENMASK(14, 13) + +#define AD5686_REF_BIT_MSK BIT(0) #define AD5686_PD_MSK GENMASK(1, 0) =20 enum ad5686_regmap_type { --=20 2.43.0 From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 81B893FCB06; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=dBBpb1mWD55N0AvOwSPOOk7z9tSZWYra/mcv1Iljo9Y43IBAo0tVZLC+M6KtePQ/C1RxzSgoY43hA8mfi+/DHpue12ONruC1rQ5abdsHBzG+6DRjuQmExvpvnApHl9xW2O4EDrwmOaH6MU1ElRSMAHgRKaveNh4IBBvZ4E165sU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=kxWf2yrbRlNkPFnXK5Px/ytjzc2qowszjnLUder71N4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MQE42B7p7xYFBHw74NAo34sqrMr+m99c3SNRr5lIdZltTedL0c94RK16eiDH8YcpRaxZk0Iglo2UpUzf4DegWsvVl2mPv8Q3P/704xuH1+rERi8+eo/Sc65XnpksWz9ZZGMmvDsbdliK/+YnbDiPioas+uABAm5wyb+C/CVd4Gs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NFfa8drP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NFfa8drP" Received: by smtp.kernel.org (Postfix) with ESMTPS id 60F69C2BCC7; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468058; bh=kxWf2yrbRlNkPFnXK5Px/ytjzc2qowszjnLUder71N4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=NFfa8drPb27kTtrdtbzc+x45yDcmdPVAB9ShVZ4so0cmEwVoCos9muyBF0LGI+LF5 mhS7TodKBPZzcmnGlSObU+IljLLbrAhMvoI1PTKLnRq/rJYVTbhzElZUwq9oUSE+uM GO3hDofNpZwEZWW9zODqBuRvUXcGRxrv/v1K3hr6PRRma+ow92G6lmDKaJyeKi9sYu df7GwG5+rhGyKRqONFhLJvzNPELob9fVfxqNcpStK/1VYmW+cJHmkXSR9YVN9kMb6M LuWg63DEByj8SxAt5DyUw/OditEIpVhWbHgBtmcaTQsLy0A3z41Nd70lmWkus36fHQ ie6K6gopOIIwQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57500FF8867; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:42 +0100 Subject: [PATCH v4 12/13] iio: dac: ad5686: cleanup doc header of local structs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-12-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar , Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=1894; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=7fK7LzhRbt6H+qVkvDS3hfVh7J2ix4vmxSrC1uBPzCI=; b=VugNGuFE5jd7c2QljSlg4tqBai3LmahN+M53MRFeZmx4FBErYGHnPNqn3JO+X6ZGpuoA/A/jI hNxZNIuGxb/AujHpE1ZKv8hIdj5qcI+vXv2q+TXy4a4qHogOTmB9Re5 X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Review documentation comment header for ad5686_chip_info and ad5686_state. Update variable names and description and remove unnecessary blank line between comment and struct declaration. Reviewed-by: Andy Shevchenko Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index 0ba4168195f5..4397ffd2e236 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -67,12 +67,11 @@ typedef int (*ad5686_read_func)(struct ad5686_state *st= , u8 addr); =20 /** * struct ad5686_chip_info - chip specific information - * @int_vref_mv: AD5620/40/60: the internal reference voltage + * @int_vref_mv: the internal reference voltage * @num_channels: number of channels * @channel: channel specification * @regmap_type: register map layout variant */ - struct ad5686_chip_info { u16 int_vref_mv; unsigned int num_channels; @@ -110,16 +109,16 @@ extern const struct ad5686_chip_info ad5679r_chip_inf= o; =20 /** * struct ad5686_state - driver instance specific data - * @spi: spi_device + * @dev: device instance * @chip_info: chip model specific constants, available modes etc * @vref_mv: actual reference voltage used * @pwr_down_mask: power down mask * @pwr_down_mode: current power down mode * @use_internal_vref: set to true if the internal reference voltage is us= ed - * @lock lock to protect the data buffer during regmap ops - * @data: spi transfer buffers + * @lock: lock to protect access to state fields, which includes + * the data buffer during regmap ops + * @data: transfer buffers */ - struct ad5686_state { struct device *dev; const struct ad5686_chip_info *chip_info; --=20 2.43.0 From nobody Tue Jun 16 19:33:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 92CDF3FCB0F; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; cv=none; b=QJguD+CQSbxMdobCxzUSQJgJPNso5ym3GxGNluHsoYZOeDMkmhwVM+DSKKXXZ4LpEd/TP1g2+f+2Eyp6a/SwXRGEFGw0+Er/NCHvLvH3uXfEIBlmU9RMWcycKH2Ca87jG3CIgQkEPqYHGy3z4s7XEPuomJPi24N5Kgg8Mdb9OCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777468058; c=relaxed/simple; bh=lU10aBiNaCnOCjpQ9vlIHxj+qef4u1iX9RvfOqGg1jo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GeIvKnr+m8sc5MRxx+QQFg9am8p7mjds/fRDLukIba6T4YBFNZ3NTPVqM8oX8fnPsPk3XKVqG3SumU1OGA4uTlBjFyKCC48gQRw1R/o/CBAa9bPFzutWw/iUS1U287Lda1eBsF9rSc7jcyHGNjnJ53PPKlm4wj71doQhVvnrgCc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bch9PDox; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bch9PDox" Received: by smtp.kernel.org (Postfix) with ESMTPS id 73BD2C2BCF7; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777468058; bh=lU10aBiNaCnOCjpQ9vlIHxj+qef4u1iX9RvfOqGg1jo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=bch9PDoxWbqeyPW5/LK9A6uwfFDvMRtpF1UjUT7xXEj7dyyUQXcbbB/g2UzP6nFK3 rNL0le2usHR38kccwwKgyCZjIjDf+HFBMotmbcWbTSMmTRJIWvP5fv8Idt12he/6aS kPjgoyK/qbX5QKWaQTMdwcWN4MLNQOXUEFfGGedfz7iLByhXgl7RnuK2ne4Hu31CeP fKidb4uh1WmuaW2FyCve/lxsxhhhOqgnvInpzqksSfPHdM40d9B/VHiVfskrZIJTty 1yVlSv3C38SOYzVf9C/MwjI2BlEhRQRfnmoMySIB557ET4qlMbi0sRe7xq6DBGn326 Gaqw9RNPshPMw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C19ACCFA13; Wed, 29 Apr 2026 13:07:38 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 29 Apr 2026 14:07:43 +0100 Subject: [PATCH v4 13/13] iio: dac: ad5686: create bus ops struct Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260429-ad5686-fixes-v4-13-bb8f1cbd68e1@analog.com> References: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> In-Reply-To: <20260429-ad5686-fixes-v4-0-bb8f1cbd68e1@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar , Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777468056; l=7566; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=LuP1ax2zq6YT04bIBwYyw9AJEsK6qS3wccsB9OfuPxA=; b=tZSNC+Ace8IuxliSDceImaRkbkvwwKKuqGEYup4Ow0DVKkxhokbh84UNAYEJTr49gqHv8DrxD c1BGhMiHqoAAZ4mEtsNATf5ne8PsuVJjQIbaFL60nqs/hB3CtCiPUyt X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Create struct with bus operations, which will be used to extend bus implementation features. Auxiliary functions ad5686_write() and ad5686_read() are created and ad5686_probe() now receives an ops struct pointer rather than individual read and write functions. Reviewed-by: Andy Shevchenko Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686-spi.c | 7 ++++++- drivers/iio/dac/ad5686.c | 32 ++++++++++++++------------------ drivers/iio/dac/ad5686.h | 29 +++++++++++++++++++++-------- drivers/iio/dac/ad5696-i2c.c | 7 ++++++- 4 files changed, 47 insertions(+), 28 deletions(-) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index 9493511d9e7f..7409624b954b 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -92,10 +92,15 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 = addr) return be32_to_cpu(st->data[2].d32); } =20 +static const struct ad5686_bus_ops ad5686_spi_ops =3D { + .write =3D ad5686_spi_write, + .read =3D ad5686_spi_read, +}; + static int ad5686_spi_probe(struct spi_device *spi) { return ad5686_probe(&spi->dev, spi_get_device_match_data(spi), - spi->modalias, ad5686_spi_write, ad5686_spi_read); + spi->modalias, &ad5686_spi_ops); } =20 static const struct spi_device_id ad5686_spi_id[] =3D { diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index bf3dc3903346..5df2527b3a2e 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -30,18 +30,18 @@ static int ad5310_control_sync(struct ad5686_state *st) { unsigned int pd_val =3D st->pwr_down_mask & st->pwr_down_mode; =20 - return st->write(st, AD5686_CMD_CONTROL_REG, 0, - FIELD_PREP(AD5310_PD_MSK, pd_val) | - FIELD_PREP(AD5310_REF_BIT_MSK, st->use_internal_vref ? 0 : 1)); + return ad5686_write(st, AD5686_CMD_CONTROL_REG, 0, + FIELD_PREP(AD5310_PD_MSK, pd_val) | + FIELD_PREP(AD5310_REF_BIT_MSK, st->use_internal_vref ? 0 : 1)); } =20 static int ad5683_control_sync(struct ad5686_state *st) { unsigned int pd_val =3D st->pwr_down_mask & st->pwr_down_mode; =20 - return st->write(st, AD5686_CMD_CONTROL_REG, 0, - FIELD_PREP(AD5683_PD_MSK, pd_val) | - FIELD_PREP(AD5683_REF_BIT_MSK, st->use_internal_vref ? 0 : 1)); + return ad5686_write(st, AD5686_CMD_CONTROL_REG, 0, + FIELD_PREP(AD5683_PD_MSK, pd_val) | + FIELD_PREP(AD5683_REF_BIT_MSK, st->use_internal_vref ? 0 : 1)); } =20 static inline unsigned int ad5686_pd_mask_shift(const struct iio_chan_spec= *chan) @@ -137,7 +137,7 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_de= v *indio_dev, address =3D 0x0; val =3D lower_16_bits(val); } - ret =3D st->write(st, AD5686_CMD_POWERDOWN_DAC, address, val); + ret =3D ad5686_write(st, AD5686_CMD_POWERDOWN_DAC, address, val); if (ret) return ret; break; @@ -160,7 +160,7 @@ static int ad5686_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_RAW: mutex_lock(&st->lock); - ret =3D st->read(st, chan->address); + ret =3D ad5686_read(st, chan->address); mutex_unlock(&st->lock); if (ret < 0) return ret; @@ -190,10 +190,8 @@ static int ad5686_write_raw(struct iio_dev *indio_dev, return -EINVAL; =20 mutex_lock(&st->lock); - ret =3D st->write(st, - AD5686_CMD_WRITE_INPUT_N_UPDATE_N, - chan->address, - val << chan->scan_type.shift); + ret =3D ad5686_write(st, AD5686_CMD_WRITE_INPUT_N_UPDATE_N, + chan->address, val << chan->scan_type.shift); mutex_unlock(&st->lock); break; default: @@ -454,8 +452,7 @@ EXPORT_SYMBOL_NS_GPL(ad5679r_chip_info, "IIO_AD5686"); =20 int ad5686_probe(struct device *dev, const struct ad5686_chip_info *chip_info, - const char *name, ad5686_write_func write, - ad5686_read_func read) + const char *name, const struct ad5686_bus_ops *ops) { struct ad5686_state *st; struct iio_dev *indio_dev; @@ -469,8 +466,7 @@ int ad5686_probe(struct device *dev, st =3D iio_priv(indio_dev); =20 st->dev =3D dev; - st->write =3D write; - st->read =3D read; + st->ops =3D ops; st->chip_info =3D chip_info; =20 ret =3D devm_regulator_get_enable_read_voltage(dev, "vcc"); @@ -515,8 +511,8 @@ int ad5686_probe(struct device *dev, return ret; break; case AD5686_REGMAP: - ret =3D st->write(st, AD5686_CMD_INTERNAL_REFER_SETUP, 0, - st->use_internal_vref ? 0 : AD5686_REF_BIT_MSK); + ret =3D ad5686_write(st, AD5686_CMD_INTERNAL_REFER_SETUP, 0, + st->use_internal_vref ? 0 : AD5686_REF_BIT_MSK); if (ret) return ret; break; diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index 4397ffd2e236..e8dc21ecc0c5 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -60,10 +60,15 @@ enum ad5686_regmap_type { =20 struct ad5686_state; =20 -typedef int (*ad5686_write_func)(struct ad5686_state *st, - u8 cmd, u8 addr, u16 val); - -typedef int (*ad5686_read_func)(struct ad5686_state *st, u8 addr); +/** + * struct ad5686_bus_ops - bus specific read/write operations + * @read: read a register value at the given address + * @write: write a command, address and value to the device + */ +struct ad5686_bus_ops { + int (*read)(struct ad5686_state *st, u8 addr); + int (*write)(struct ad5686_state *st, u8 cmd, u8 addr, u16 val); +}; =20 /** * struct ad5686_chip_info - chip specific information @@ -111,6 +116,7 @@ extern const struct ad5686_chip_info ad5679r_chip_info; * struct ad5686_state - driver instance specific data * @dev: device instance * @chip_info: chip model specific constants, available modes etc + * @ops: bus specific operations * @vref_mv: actual reference voltage used * @pwr_down_mask: power down mask * @pwr_down_mode: current power down mode @@ -122,11 +128,10 @@ extern const struct ad5686_chip_info ad5679r_chip_inf= o; struct ad5686_state { struct device *dev; const struct ad5686_chip_info *chip_info; + const struct ad5686_bus_ops *ops; unsigned short vref_mv; unsigned int pwr_down_mask; unsigned int pwr_down_mode; - ad5686_write_func write; - ad5686_read_func read; bool use_internal_vref; struct mutex lock; =20 @@ -145,8 +150,16 @@ struct ad5686_state { =20 int ad5686_probe(struct device *dev, const struct ad5686_chip_info *chip_info, - const char *name, ad5686_write_func write, - ad5686_read_func read); + const char *name, const struct ad5686_bus_ops *ops); =20 +static inline int ad5686_write(struct ad5686_state *st, u8 cmd, u8 addr, u= 16 val) +{ + return st->ops->write(st, cmd, addr, val); +} + +static inline int ad5686_read(struct ad5686_state *st, u8 addr) +{ + return st->ops->read(st, addr); +} =20 #endif /* __DRIVERS_IIO_DAC_AD5686_H__ */ diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index 6943616eace3..6f3842ef8f9c 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -62,10 +62,15 @@ static int ad5686_i2c_write(struct ad5686_state *st, return (ret !=3D 3) ? -EIO : 0; } =20 +static const struct ad5686_bus_ops ad5686_i2c_ops =3D { + .write =3D ad5686_i2c_write, + .read =3D ad5686_i2c_read, +}; + static int ad5686_i2c_probe(struct i2c_client *i2c) { return ad5686_probe(&i2c->dev, i2c_get_match_data(i2c), - i2c->name, ad5686_i2c_write, ad5686_i2c_read); + i2c->name, &ad5686_i2c_ops); } =20 static const struct i2c_device_id ad5686_i2c_id[] =3D { --=20 2.43.0