From nobody Mon Feb 9 01:51:35 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 5748536C5B6 for ; Mon, 19 Jan 2026 18:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847076; cv=none; b=lSHSkM2NEFoc8WgzVyS1A23BIwBaTfsnUMEvc9S2v21IuOiTcbXfv4AU3Qy3Hyl1nMzu1ojCqQ6mul4qdfcuTsPO/wNXovOLVXHTAz1ALZ0w3twyU1o6ez9/Jai1KZOWo9i8ZGXpmGGzR8jV8Oik5Ubsi9XwcErw6sDO0nDCkDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847076; c=relaxed/simple; bh=hfRqSHoUd/W/eV/madXW+xbCjKlyqcFtv2XVBYIuxKk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IBEsRmvyK9vKmU9GtRSAuZGqUEdzm9z8u3ocLEHxYqzewwDM3c+UeX8FZ+bQMRdoAxRR0cxpAV6ZPNo6wFkZVhQc4TpdY2zhjesEdxd5GZn9QmDkAyY9TWNvVgTEc3dR3QCvOUHPFa2KdJXJp2mDLpRPzA2eKz0FdL5gfliTbOQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vhtvO-0004SL-7c; Mon, 19 Jan 2026 19:24:26 +0100 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac] helo=dude04) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vhtvO-001SUe-0v; Mon, 19 Jan 2026 19:24:25 +0100 Received: from ore by dude04 with local (Exim 4.98.2) (envelope-from ) id 1vhtvN-00000006y1U-2H6t; Mon, 19 Jan 2026 19:24:25 +0100 From: Oleksij Rempel To: Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Andy Shevchenko , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , David Jander Subject: [PATCH v1 1/8] dt-bindings: iio: dac: maxim,ds4424: add ds4402/ds4404 Date: Mon, 19 Jan 2026 19:24:17 +0100 Message-ID: <20260119182424.1660601-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260119182424.1660601-1-o.rempel@pengutronix.de> References: <20260119182424.1660601-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add compatible strings for Maxim DS4402 and DS4404 current DACs. These devices are 5-bit variants of the DS4422/DS4424 family. Signed-off-by: Oleksij Rempel Acked-by: Conor Dooley --- .../devicetree/bindings/iio/dac/maxim,ds4424.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/dac/maxim,ds4424.yaml b/= Documentation/devicetree/bindings/iio/dac/maxim,ds4424.yaml index 264fa7c5fe3a..efe63e6cb55d 100644 --- a/Documentation/devicetree/bindings/iio/dac/maxim,ds4424.yaml +++ b/Documentation/devicetree/bindings/iio/dac/maxim,ds4424.yaml @@ -4,18 +4,21 @@ $id: http://devicetree.org/schemas/iio/dac/maxim,ds4424.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# =20 -title: Maxim Integrated DS4422/DS4424 7-bit Sink/Source Current DAC +title: Maxim Integrated DS4402/DS4404 and DS4422/DS4424 Current DACs =20 maintainers: - Ismail Kose =20 description: | - Datasheet publicly available at: + Datasheets publicly available at: + https://datasheets.maximintegrated.com/en/ds/DS4402-DS4404.pdf https://datasheets.maximintegrated.com/en/ds/DS4422-DS4424.pdf =20 properties: compatible: enum: + - maxim,ds4402 + - maxim,ds4404 - maxim,ds4422 - maxim,ds4424 =20 --=20 2.47.3 From nobody Mon Feb 9 01:51:35 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 5606532C957 for ; Mon, 19 Jan 2026 18:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847076; cv=none; b=K544c4reidvpNk5oS/FAINUF1i+/WV+TqtRKliH8CWgXvuXONHH5UTZ/mRdLZkcA4GllN/HSL7XdPuRiTduwK+C/aOhMtAFRr7GdUz8n+nmX/4bFtydeHqC3raZTpL+f/6f6Z5N8xsd4WuqJalpidOzWq5lvOgSYcsbxzt4ZC7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847076; c=relaxed/simple; bh=hAEvEHpjltGseJiJJMnfe33kIokUzk+wFFOghd/Au8E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NSMXQogeWZiT6E1Q5Iemn8ZGT3QtLcWBof1DAlebLn3LQTr7k6ArfH60wNIjcDSatDGmGT7ocxuezqYoQ3jTD4GrPYNSpua+vbSL+9cZCD6IUEhFj69PNollaZUKiPOOI6IXXabTekvpPc0gUQYjCleU/rkQqdIS6KyRgVGNM4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vhtvO-0004SM-7b; Mon, 19 Jan 2026 19:24:26 +0100 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac] helo=dude04) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vhtvO-001SUf-10; Mon, 19 Jan 2026 19:24:25 +0100 Received: from ore by dude04 with local (Exim 4.98.2) (envelope-from ) id 1vhtvN-00000006y1e-2OA6; Mon, 19 Jan 2026 19:24:25 +0100 From: Oleksij Rempel To: Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Andy Shevchenko , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , David Jander Subject: [PATCH v1 2/8] dt-bindings: iio: dac: maxim,ds4424: add maxim,rfs-ohms property Date: Mon, 19 Jan 2026 19:24:18 +0100 Message-ID: <20260119182424.1660601-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260119182424.1660601-1-o.rempel@pengutronix.de> References: <20260119182424.1660601-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Introduce the 'maxim,rfs-ohms' property. The full-scale output current of these DACs is determined by external resistors (Rfs) connected to the FS pins. The driver requires the physical resistance values to calculate the correct current scale (Amps per step) for the IIO subsystem. Keep it optional to avoid forcing updates of existing DTs; without it the driver cannot derive a correct IIO scale. Signed-off-by: Oleksij Rempel --- .../devicetree/bindings/iio/dac/maxim,ds4424.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/dac/maxim,ds4424.yaml b/= Documentation/devicetree/bindings/iio/dac/maxim,ds4424.yaml index efe63e6cb55d..b7af8464a4fc 100644 --- a/Documentation/devicetree/bindings/iio/dac/maxim,ds4424.yaml +++ b/Documentation/devicetree/bindings/iio/dac/maxim,ds4424.yaml @@ -27,6 +27,17 @@ properties: =20 vcc-supply: true =20 + maxim,rfs-ohms: + description: | + Array of resistance values in Ohms for the external Rfs resistors + connected to the FS pins. + - For DS44x2 (2 channels): 2 values required. + - For DS44x4 (4 channels): 4 values required. + Typical values range from 40000 (40 kOhm) to 160000 (160 kOhm). + minItems: 2 + maxItems: 4 + $ref: /schemas/types.yaml#/definitions/uint32-array + required: - compatible - reg --=20 2.47.3 From nobody Mon Feb 9 01:51:35 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 5733D36BCE5 for ; Mon, 19 Jan 2026 18:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847075; cv=none; b=pjl0yR+Y0DfUJGtpn/k0LqT+6owFNhjN7iIN1W4ShnhXtYnKaO80+YlieICPj+NeTdVhLbxA8+W/m6tVO6tLc4Y1uJ0pDWhgFwm/Ld++WfgKWQn90Gp0TrGHpDpRHBwsG8/XC3Mn8uGkrWLACG2WmeixnGVuoinuLFY+lDxUDOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847075; c=relaxed/simple; bh=7DFKPDbFnEIjbEcnSA5MiuH+pLp28VdV2rLS44SFNTA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bcqR4Yn1BQ6hQW7zVybAwuWYopD26duMs0RV700ZSvMq4o5ojLs0RLOVkbRCcuvv2M5mQJqwQH13kc3wMX1z7ORWead34MJ9+pH8LVZ/LcDqNy9wMxmkW2UD8tFDbFZvyLfIdHCkLOV0E9BifszV5C+CIyMN3/SHlULoCpLyaCY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vhtvO-0004SN-7Y; Mon, 19 Jan 2026 19:24:26 +0100 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac] helo=dude04) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vhtvO-001SUh-15; Mon, 19 Jan 2026 19:24:25 +0100 Received: from ore by dude04 with local (Exim 4.98.2) (envelope-from ) id 1vhtvN-00000006y1o-2UkW; Mon, 19 Jan 2026 19:24:25 +0100 From: Oleksij Rempel To: Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , David Jander , kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Andy Shevchenko , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= Subject: [PATCH v1 3/8] iio: dac: ds4424: add DS4402/DS4404 device IDs Date: Mon, 19 Jan 2026 19:24:19 +0100 Message-ID: <20260119182424.1660601-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260119182424.1660601-1-o.rempel@pengutronix.de> References: <20260119182424.1660601-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add I2C/OF IDs for DS4402 and DS4404 and set the correct channel count. Follow-up changes add per-variant scaling based on external Rfs. Signed-off-by: David Jander Signed-off-by: Oleksij Rempel --- drivers/iio/dac/ds4424.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c index a8198ba4f98a..072b7e6672cf 100644 --- a/drivers/iio/dac/ds4424.c +++ b/drivers/iio/dac/ds4424.c @@ -48,6 +48,8 @@ union ds4424_raw_data { }; =20 enum ds4424_device_ids { + ID_DS4402, + ID_DS4404, ID_DS4422, ID_DS4424, }; @@ -248,6 +250,12 @@ static int ds4424_probe(struct i2c_client *client) goto fail; =20 switch (id->driver_data) { + case ID_DS4402: + indio_dev->num_channels =3D DS4422_MAX_DAC_CHANNELS; + break; + case ID_DS4404: + indio_dev->num_channels =3D DS4424_MAX_DAC_CHANNELS; + break; case ID_DS4422: indio_dev->num_channels =3D DS4422_MAX_DAC_CHANNELS; break; @@ -289,6 +297,8 @@ static void ds4424_remove(struct i2c_client *client) } =20 static const struct i2c_device_id ds4424_id[] =3D { + { "ds4402", ID_DS4402 }, + { "ds4404", ID_DS4404 }, { "ds4422", ID_DS4422 }, { "ds4424", ID_DS4424 }, { } @@ -297,6 +307,8 @@ static const struct i2c_device_id ds4424_id[] =3D { MODULE_DEVICE_TABLE(i2c, ds4424_id); =20 static const struct of_device_id ds4424_of_match[] =3D { + { .compatible =3D "maxim,ds4402" }, + { .compatible =3D "maxim,ds4404" }, { .compatible =3D "maxim,ds4422" }, { .compatible =3D "maxim,ds4424" }, { } --=20 2.47.3 From nobody Mon Feb 9 01:51:35 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 5663A36A016 for ; Mon, 19 Jan 2026 18:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847078; cv=none; b=Ko3cpRPZ5DyoX6LtptGF0e+SU3j62MBnvaD7H0po59MWR8rxt8VzKxFYyIaQdFZDCG+b/1VV4DqUNCR+rq9hP3gldheMaSnEOLpPykjbEis+4yTaDC1gkf2uQL+riZxN4h1HMo4C1oF5Jli3ZkKrq5HLLJbJR6VpT9ewDcTkkvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847078; c=relaxed/simple; bh=+L8hofjKyjTSzyKgvlJ00wSPTK1EZoc14n6gT4ZKxvI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aBIyc1ulwfrxW9HSGCYnyOf6VCMJIjvijyz3s3zTsRWFcEC3f/NgRcGtMu7NOX15dQAJzW0sNNErBhHlSwWDuEWbaTGdIFGlcUnInyxkOdxyJ7bn5sJJ/O9DRIu7Xvm7TCgUltvlrBU/n9MBPuhGNLorNI55dKay1TzDESdknkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vhtvO-0004SO-7c; Mon, 19 Jan 2026 19:24:26 +0100 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac] helo=dude04) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vhtvO-001SUi-1B; Mon, 19 Jan 2026 19:24:25 +0100 Received: from ore by dude04 with local (Exim 4.98.2) (envelope-from ) id 1vhtvN-00000006y1y-2aWd; Mon, 19 Jan 2026 19:24:25 +0100 From: Oleksij Rempel To: Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , stable@vger.kernel.org, kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Andy Shevchenko , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , David Jander Subject: [PATCH v1 4/8] iio: dac: ds4424: reject -128 RAW value Date: Mon, 19 Jan 2026 19:24:20 +0100 Message-ID: <20260119182424.1660601-5-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260119182424.1660601-1-o.rempel@pengutronix.de> References: <20260119182424.1660601-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The DS442x DAC uses sign-magnitude encoding, so -128 cannot be represented in hardware. With the previous check, userspace could pass -128, which gets converted to a magnitude of 128 and then truncated by the 7-bit DAC field. This ends up programming a zero magnitude with the sign bit set, i.e. an unintended output (effectively 0 mA instead of -128 steps). Reject -128 to avoid silently producing the wrong current. Fixes: d632a2bd8ffc ("iio: dac: ds4422/ds4424 dac driver") Cc: Signed-off-by: Oleksij Rempel --- drivers/iio/dac/ds4424.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c index 072b7e6672cf..9c24c37d3c42 100644 --- a/drivers/iio/dac/ds4424.c +++ b/drivers/iio/dac/ds4424.c @@ -143,7 +143,7 @@ static int ds4424_write_raw(struct iio_dev *indio_dev, =20 switch (mask) { case IIO_CHAN_INFO_RAW: - if (val < S8_MIN || val > S8_MAX) + if (val <=3D S8_MIN || val > S8_MAX) return -EINVAL; =20 if (val > 0) { --=20 2.47.3 From nobody Mon Feb 9 01:51:35 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 573D236C5A5 for ; Mon, 19 Jan 2026 18:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847076; cv=none; b=R7scPPJghmT9DOVlSD9SQ2IDV94dD526DOFxhy4TJLnXg5DW3pEqfgVHc5l4xPwDbluM+LR3nlebpRoVZGK0R4KxcWWqDuUgJnjj5yqVLVqf64dj8PGbl+AUV7cRkTRZ2ufO48VcdGxYVxOeVZs+3MZoP8pkdXBDAqowFTzCci8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847076; c=relaxed/simple; bh=WTzdsTpYNInqLGPOOUqeJAkoZ9UkVda5LqW9qOOCN/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zgi5Jyu8Wz1kfeT0ijN2tXq2eFq1XGCjKtthR+fHjLDc5Oa//GScK8Y68236/ka/VSqPFanLOcojxfu4K+q6fXuvavbp7o/BQzKgNjMJe63xqwY9EKG0dFF0DEndWZHe/yWKKCeezrmaYYy3o/aSQguJd2oei6zPXyug/xpxsLI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vhtvO-0004SP-7e; Mon, 19 Jan 2026 19:24:26 +0100 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac] helo=dude04) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vhtvO-001SUl-1L; Mon, 19 Jan 2026 19:24:25 +0100 Received: from ore by dude04 with local (Exim 4.98.2) (envelope-from ) id 1vhtvN-00000006y29-2gQi; Mon, 19 Jan 2026 19:24:25 +0100 From: Oleksij Rempel To: Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Andy Shevchenko , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , David Jander Subject: [PATCH v1 5/8] iio: dac: ds4424: add Rfs-based scale and per-variant limits Date: Mon, 19 Jan 2026 19:24:21 +0100 Message-ID: <20260119182424.1660601-6-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260119182424.1660601-1-o.rempel@pengutronix.de> References: <20260119182424.1660601-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Parse optional maxim,rfs-ohms values to derive the per-channel output current scale (mA per step) for the IIO current ABI. Select per-variant parameters to match the shared register map while handling different data widths and full-scale current calculations. Behavior changes: - If maxim,rfs-ohms is present, IIO_CHAN_INFO_SCALE becomes available and reports mA/step derived from Rfs. - If maxim,rfs-ohms is missing, SCALE is not exposed to keep older DTs working without requiring updates. - RAW writes are now limited to the representable sign-magnitude range of the detected variant to avoid silent truncation (e.g. +/-31 on DS440x). Signed-off-by: Oleksij Rempel --- drivers/iio/dac/ds4424.c | 137 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 132 insertions(+), 5 deletions(-) diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c index 9c24c37d3c42..a0c60eb89717 100644 --- a/drivers/iio/dac/ds4424.c +++ b/drivers/iio/dac/ds4424.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -54,12 +55,41 @@ enum ds4424_device_ids { ID_DS4424, }; =20 +/* + * Two variant groups share the same register map but differ in: + * - resolution/data mask (DS4402/DS4404: 5-bit, DS4422/DS4424: 7-bit) + * - full-scale current calculation (different Vref and divider) + * Addressing also differs (DS440x tri-level, DS442x bi-level), but is + * handled via board configuration, not driver logic. + */ +struct ds4424_chip_info { + u8 result_mask; + int vref_mv; + int scale_denom; +}; + +static const struct ds4424_chip_info ds4424_info =3D { + .result_mask =3D 0x7F, + .vref_mv =3D 976, + .scale_denom =3D 16, +}; + +/* DS4402 is handled like DS4404 (same resolution and scale formula). */ +static const struct ds4424_chip_info ds4404_info =3D { + .result_mask =3D 0x1F, + .vref_mv =3D 1230, + .scale_denom =3D 4, +}; + struct ds4424_data { struct i2c_client *client; struct mutex lock; uint8_t save[DS4424_MAX_DAC_CHANNELS]; struct regulator *vcc_reg; uint8_t raw[DS4424_MAX_DAC_CHANNELS]; + const struct ds4424_chip_info *chip_info; + u32 rfs_ohms[DS4424_MAX_DAC_CHANNELS]; + bool has_rfs; }; =20 static const struct iio_chan_spec ds4424_channels[] =3D { @@ -111,6 +141,7 @@ static int ds4424_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { union ds4424_raw_data raw; + struct ds4424_data *data =3D iio_priv(indio_dev); int ret; =20 switch (mask) { @@ -122,10 +153,19 @@ static int ds4424_read_raw(struct iio_dev *indio_dev, return ret; } raw.bits =3D *val; - *val =3D raw.dx; + *val =3D raw.dx & data->chip_info->result_mask; if (raw.source_bit =3D=3D DS4424_SINK_I) *val =3D -*val; return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + if (!data->has_rfs) + return -EINVAL; + + /* SCALE is mA/step: mV / Ohm =3D mA. */ + *val =3D data->chip_info->vref_mv; + *val2 =3D data->rfs_ohms[chan->channel] * + data->chip_info->scale_denom; + return IIO_VAL_FRACTIONAL; =20 default: return -EINVAL; @@ -136,6 +176,8 @@ static int ds4424_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) { + struct ds4424_data *data =3D iio_priv(indio_dev); + int max_val =3D data->chip_info->result_mask; union ds4424_raw_data raw; =20 if (val2 !=3D 0) @@ -143,7 +185,12 @@ static int ds4424_write_raw(struct iio_dev *indio_dev, =20 switch (mask) { case IIO_CHAN_INFO_RAW: - if (val <=3D S8_MIN || val > S8_MAX) + /* + * The hardware uses sign-magnitude representation (not + * two's complement). Therefore, the range is symmetric: + * [-max_val, +max_val]. + */ + if (val < -max_val || val > max_val) return -EINVAL; =20 if (val > 0) { @@ -173,6 +220,74 @@ static int ds4424_verify_chip(struct iio_dev *indio_de= v) return ret; } =20 +static int ds4424_setup_channels(struct i2c_client *client, + struct ds4424_data *data, + struct iio_dev *indio_dev) +{ + struct iio_chan_spec channels[DS4424_MAX_DAC_CHANNELS]; + size_t channels_size; + int i; + + channels_size =3D indio_dev->num_channels * sizeof(*channels); + memcpy(channels, ds4424_channels, channels_size); + + /* Enable scale only when rfs is available. */ + if (data->has_rfs) { + for (i =3D 0; i < indio_dev->num_channels; i++) + channels[i].info_mask_separate |=3D + BIT(IIO_CHAN_INFO_SCALE); + } + + indio_dev->channels =3D devm_kmemdup(&client->dev, channels, + channels_size, GFP_KERNEL); + if (!indio_dev->channels) + return -ENOMEM; + + return 0; +} + +static int ds4424_parse_rfs(struct i2c_client *client, + struct ds4424_data *data, + struct iio_dev *indio_dev) +{ + int count, i, ret; + + if (!device_property_present(&client->dev, "maxim,rfs-ohms")) { + dev_info_once(&client->dev, "maxim,rfs-ohms missing, scale not supported= \n"); + return 0; + } + + count =3D device_property_count_u32(&client->dev, "maxim,rfs-ohms"); + if (count !=3D indio_dev->num_channels) { + dev_err(&client->dev, + "maxim,rfs-ohms must have %u entries\n", + indio_dev->num_channels); + return -EINVAL; + } + + ret =3D device_property_read_u32_array(&client->dev, + "maxim,rfs-ohms", + data->rfs_ohms, + indio_dev->num_channels); + if (ret) { + dev_err(&client->dev, + "Failed to read maxim,rfs-ohms property\n"); + return ret; + } + + for (i =3D 0; i < indio_dev->num_channels; i++) { + if (!data->rfs_ohms[i]) { + dev_err(&client->dev, + "maxim,rfs-ohms entry %d is zero\n", + i); + return -EINVAL; + } + } + + data->has_rfs =3D true; + return 0; +} + static int ds4424_suspend(struct device *dev) { struct i2c_client *client =3D to_i2c_client(dev); @@ -210,7 +325,7 @@ static int ds4424_resume(struct device *dev) =20 static DEFINE_SIMPLE_DEV_PM_OPS(ds4424_pm_ops, ds4424_suspend, ds4424_resu= me); =20 -static const struct iio_info ds4424_info =3D { +static const struct iio_info ds4424_iio_info =3D { .read_raw =3D ds4424_read_raw, .write_raw =3D ds4424_write_raw, }; @@ -252,15 +367,20 @@ static int ds4424_probe(struct i2c_client *client) switch (id->driver_data) { case ID_DS4402: indio_dev->num_channels =3D DS4422_MAX_DAC_CHANNELS; + /* See ds4404_info comment above. */ + data->chip_info =3D &ds4404_info; break; case ID_DS4404: indio_dev->num_channels =3D DS4424_MAX_DAC_CHANNELS; + data->chip_info =3D &ds4404_info; break; case ID_DS4422: indio_dev->num_channels =3D DS4422_MAX_DAC_CHANNELS; + data->chip_info =3D &ds4424_info; break; case ID_DS4424: indio_dev->num_channels =3D DS4424_MAX_DAC_CHANNELS; + data->chip_info =3D &ds4424_info; break; default: dev_err(&client->dev, @@ -269,9 +389,16 @@ static int ds4424_probe(struct i2c_client *client) goto fail; } =20 - indio_dev->channels =3D ds4424_channels; + ret =3D ds4424_parse_rfs(client, data, indio_dev); + if (ret) + goto fail; + + ret =3D ds4424_setup_channels(client, data, indio_dev); + if (ret) + goto fail; + indio_dev->modes =3D INDIO_DIRECT_MODE; - indio_dev->info =3D &ds4424_info; + indio_dev->info =3D &ds4424_iio_info; =20 ret =3D iio_device_register(indio_dev); if (ret < 0) { --=20 2.47.3 From nobody Mon Feb 9 01:51:35 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 56553368279 for ; Mon, 19 Jan 2026 18:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847075; cv=none; b=sMX5DWB6k1e6ZTOn2eWMJLYtKoKZtL2M4xTGIRKi0koWCvVmx6vkc4MAmlZ6CEt25EOKGvWUYBUkkzcwH6xkuYo7AzPuBldrelWOi97OJ596JvhOcONOaPbZw51cPVS53xtR5VmGhOiosd4aoxJC5NUx2Yk9+3I6uoshc3qULHg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847075; c=relaxed/simple; bh=Vjn6/7sVL2PRX0fnsG7PEGcF6n99+IlYZKmpZI6Qq3g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=feMFjgKm/OuPl0lnDRFXCvv1F+iukBBiw5l95VC6MQ+68qtWYqdpmK1sqnMTqO+6tM1kbgtISnGi2ThxxgFZjdTDT/omMOfKMeb6wJNjty6t4uHKUfXi4H2vnOvGqKA4Y7EKqj3Nrj/OFAeEkRd29whzsISEaeSDB6BVgCuNG4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vhtvO-0004SQ-7b; Mon, 19 Jan 2026 19:24:26 +0100 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac] helo=dude04) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vhtvO-001SUn-1R; Mon, 19 Jan 2026 19:24:25 +0100 Received: from ore by dude04 with local (Exim 4.98.2) (envelope-from ) id 1vhtvN-00000006y2J-2lo9; Mon, 19 Jan 2026 19:24:25 +0100 From: Oleksij Rempel To: Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Andy Shevchenko , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , David Jander Subject: [PATCH v1 6/8] iio: dac: ds4424: clear outputs on probe Date: Mon, 19 Jan 2026 19:24:22 +0100 Message-ID: <20260119182424.1660601-7-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260119182424.1660601-1-o.rempel@pengutronix.de> References: <20260119182424.1660601-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The DS44xx devices have no reset pin or reset bit, so output registers may retain preconfigured values across reboot or warm reset. Also, the driver suspend/resume path restores from data->raw. When the device is first probed, data->raw is zero-initialized and may not match the actual hardware state. A later suspend/resume can therefore change an output from a preconfigured non-zero value to 0 mA. Initialize all channels to 0 output current during probe to ensure a deterministic baseline and consistent suspend/resume behavior. Signed-off-by: Oleksij Rempel --- drivers/iio/dac/ds4424.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c index a0c60eb89717..2d299a52cede 100644 --- a/drivers/iio/dac/ds4424.c +++ b/drivers/iio/dac/ds4424.c @@ -220,6 +220,20 @@ static int ds4424_verify_chip(struct iio_dev *indio_de= v) return ret; } =20 +static int ds4424_init(struct iio_dev *indio_dev) +{ + int i, ret; + + /* Set all channels to 0 current. */ + for (i =3D 0; i < indio_dev->num_channels; i++) { + ret =3D ds4424_set_value(indio_dev, 0, &indio_dev->channels[i]); + if (ret < 0) + return ret; + } + + return 0; +} + static int ds4424_setup_channels(struct i2c_client *client, struct ds4424_data *data, struct iio_dev *indio_dev) @@ -397,6 +411,11 @@ static int ds4424_probe(struct i2c_client *client) if (ret) goto fail; =20 + /* No reset pin/bit: clear any preconfigured output on probe. */ + ret =3D ds4424_init(indio_dev); + if (ret) + goto fail; + indio_dev->modes =3D INDIO_DIRECT_MODE; indio_dev->info =3D &ds4424_iio_info; =20 --=20 2.47.3 From nobody Mon Feb 9 01:51:35 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 5611E3346BC for ; Mon, 19 Jan 2026 18:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847077; cv=none; b=iYEPcaNP5bNs/TbrXEkE4If+vDsVu7k6hgzVKjzWShALwuxDdsrck8LL0isRXTCCbzDFU4V+cffQxnEAlRXRLMU0HyAgvTQoQjBJIsVSZt63V8XmFGfZhqpeeUTh8vb2mMqMPVfKvckK47sdUSuzu3gJ1CKbUi5B+hVjM/Eh42k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847077; c=relaxed/simple; bh=Xfoi+lem2nLxE7UAyO/lJ6F52/txLPDbokgn0yZNdFs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hyUzDe+Bclirm8DDTwvXjD55iIzQBbaJFYVUqTGBzimb9aw6PfZxNQ1jYKVnQjTW66wDiffRiZG5BsbClHjrFcmQ1q7gQmdLVCZ441OjRWbtiRtU1Z3W1NPupXgyzahSWDBkjdHjeVL65DnJN3B9xeIv0GmqqqRmgi5fn7xg9eQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vhtvO-0004SR-7d; Mon, 19 Jan 2026 19:24:26 +0100 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac] helo=dude04) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vhtvO-001SUp-1X; Mon, 19 Jan 2026 19:24:25 +0100 Received: from ore by dude04 with local (Exim 4.98.2) (envelope-from ) id 1vhtvN-00000006y2U-2r3l; Mon, 19 Jan 2026 19:24:25 +0100 From: Oleksij Rempel To: Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Andy Shevchenko , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , David Jander Subject: [PATCH v1 7/8] iio: dac: ds4424: ratelimit read errors and use device context Date: Mon, 19 Jan 2026 19:24:23 +0100 Message-ID: <20260119182424.1660601-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260119182424.1660601-1-o.rempel@pengutronix.de> References: <20260119182424.1660601-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace pr_err() with dev_err_ratelimited() in the RAW read path to avoid log spam on repeated I2C failures and to include the device context. Use %pe to print errno names for faster debugging. Signed-off-by: Oleksij Rempel --- drivers/iio/dac/ds4424.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c index 2d299a52cede..13acb427d43b 100644 --- a/drivers/iio/dac/ds4424.c +++ b/drivers/iio/dac/ds4424.c @@ -148,8 +148,9 @@ static int ds4424_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_RAW: ret =3D ds4424_get_value(indio_dev, val, chan->channel); if (ret < 0) { - pr_err("%s : ds4424_get_value returned %d\n", - __func__, ret); + dev_err_ratelimited(&indio_dev->dev, + "%s: ds4424_get_value failed %pe\n", + __func__, ERR_PTR(ret)); return ret; } raw.bits =3D *val; --=20 2.47.3 From nobody Mon Feb 9 01:51:35 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 5752A36CDE8 for ; Mon, 19 Jan 2026 18:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847077; cv=none; b=DmzMdTq5VAUsihASWqx1Cq4HBgbW9rjF+haq38P3u+UaABN4qUZTeN7cF1fzvfcW6SURPh8aOAUY3SIrWH4WjnWrLAlY7CSpuJ+puBRDhApg09xdN/rU5n1ZsGofnIzPo84+QtsnkUATi+OLn8I/xoROZVfxtpNIu8w7X0WQZGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768847077; c=relaxed/simple; bh=gKdxgCeUIfsMv9ke4Upzqo22FIpf6SCbXM4wJZi9nto=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mEDbyX65moYMs38sSABU6hMMIIGqrwzFldB7HxPxU93BuJAKPgZne1njO1GFPxCwmki0JdJB/XGNj6ZGca5qFakHuuIC5eZChBc1Myq2mdAEkiKtSiCsuYByJZrUA+zBsihNgiq2drAmdwY9subiwzYrhJgom5aINSLC2i6OKss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vhtvO-0004SS-7c; Mon, 19 Jan 2026 19:24:26 +0100 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac] helo=dude04) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vhtvO-001SUr-1Y; Mon, 19 Jan 2026 19:24:25 +0100 Received: from ore by dude04 with local (Exim 4.98.2) (envelope-from ) id 1vhtvN-00000006y2f-2wCL; Mon, 19 Jan 2026 19:24:25 +0100 From: Oleksij Rempel To: Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Andy Shevchenko , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , David Jander Subject: [PATCH v1 8/8] iio: dac: ds4424: document output sign and probe verification Date: Mon, 19 Jan 2026 19:24:24 +0100 Message-ID: <20260119182424.1660601-9-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260119182424.1660601-1-o.rempel@pengutronix.de> References: <20260119182424.1660601-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Document that a zero output value is encoded with a don't-care sign bit and that the driver verifies device presence via a readable register since the hardware provides no device ID. Signed-off-by: Oleksij Rempel --- drivers/iio/dac/ds4424.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c index 13acb427d43b..2ccac674878e 100644 --- a/drivers/iio/dac/ds4424.c +++ b/drivers/iio/dac/ds4424.c @@ -194,6 +194,7 @@ static int ds4424_write_raw(struct iio_dev *indio_dev, if (val < -max_val || val > max_val) return -EINVAL; =20 + /* Canonicalize 0 to sink; datasheet treats sign as don't-care. */ if (val > 0) { raw.source_bit =3D DS4424_SOURCE_I; raw.dx =3D val; @@ -213,6 +214,7 @@ static int ds4424_verify_chip(struct iio_dev *indio_dev) { int ret, val; =20 + /* No device ID; verify presence by a readable register. */ ret =3D ds4424_get_value(indio_dev, &val, 0); if (ret < 0) dev_err(&indio_dev->dev, --=20 2.47.3