From mboxrd@z Thu Jan 1 00:00:00 1970 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 E386D3451AA for ; Tue, 27 Jan 2026 10:49:14 +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=1769510957; cv=none; b=Jtqu6yG+QoONcY5As+GHl4T1FOv3Y+YwlLpZuG1Oh3u0sSOTRcx+OB+eYmjowLtBfoAzRPX4ryq8hPfIisHguEtMT0kYf/GpdcC9yzqMZLbCN9M53KpM5ouODR2jc8fo5evHtp7js07Ylxv4NMYhWCdkUzOZ6IvPKIIsdo1kC64= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769510957; c=relaxed/simple; bh=RLNOplt5iqFZ0f2CGEMaBfKeBIgV7AUHRe1T32MXLrc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jR61CZtrfXUbKutS0b4i/NqZudkIb8iTlPxiTOExCZsOT5foEMLlL3mKk63yFYA1E25OIfgc1qDpVR7m/MyWbdiZ6rpbSb5o8oGnFHGukr2lV1sF0SHrLXHMoouXIDvxr35L5RH8HHCfaOwUl6fmhl69elEuAM9+p0aQJA1Tu/o= 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 1vkgd8-0008Jo-W0; Tue, 27 Jan 2026 11:49:07 +0100 Received: from pty.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::c5]) 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 1vkgd8-002jZH-0H; Tue, 27 Jan 2026 11:49:05 +0100 Received: from ore by pty.whiteo.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1vkgd7-000o8s-0s; Tue, 27 Jan 2026 11:49:05 +0100 Date: Tue, 27 Jan 2026 11:49:05 +0100 From: Oleksij Rempel To: Andy Shevchenko Cc: Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , 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 , Nuno =?utf-8?B?U8Oh?= , David Jander Subject: Re: [PATCH v2 6/8] iio: dac: ds4424: fix -128 rejection and refactor raw access Message-ID: References: <20260127060939.3914006-1-o.rempel@pengutronix.de> <20260127060939.3914006-7-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain 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: stable@vger.kernel.org On Tue, Jan 27, 2026 at 12:42:24PM +0200, Andy Shevchenko wrote: > On Tue, Jan 27, 2026 at 07:09:37AM +0100, Oleksij Rempel wrote: > > The DS442x DAC uses sign-magnitude encoding, so -128 cannot be represented. > > Previously, passing -128 resulted in a truncated value that programmed 0mA. > > > > Fix this by validating the input against the 7-bit magnitude limit. > > Additionally, refactor the raw access logic to use symmetrical bitwise > > operations, replacing the union structure. > > > Fixes: d632a2bd8ffc ("iio: dac: ds4422/ds4424 dac driver") > > + /* > > + * Currents exiting the IC (Source) are positive. > > + * Canonicalize 0 to sink; datasheet treats sign as don't-care. > > + */ > > + if (val > 0) > > + abs_val |= DS4424_DAC_SOURCE; > > Hmm... Maybe 0 should be excluded as invalid? 0 is valid value for no current flow (power off). The direction bit DS4424_DAC_SOURCE will just make no difference if value is 0. -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |