From mboxrd@z Thu Jan 1 00:00:00 1970 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 BD924215060; Tue, 29 Apr 2025 17:54: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=1745949277; cv=none; b=uGlOal7UIXKBynVdzOqNG7uTOF9xUsUOfalMBI8PxHMbb/EhdxUzUejqbqWwA5qTvGdRADo58QTVjDZlSFPBDPggvg+6050xo6FmktGODTGhpjNuWABUMWPGyhPTWPv2ja4L1fKyRG9IBLkfDOiOQQnjTA57P+I5FtZLUzwSyRY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745949277; c=relaxed/simple; bh=7ENcSCnSl/RnKPu999SQ++NgTEAfpQ/Y6OnEf7Oy0/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UDRxt8yUv2HRHn89v7GvkFQgP6ozp+i1H3fNQ3q2ZaLOxs6HyQT6XIUBxq3Y2J+LBzXaRi0Saqm3V7N/SAu+PYFiI0tXIg+m5FX48rt1eo/pKFzVHX6SipHuYEFalTyF87D0QGF+zQBPmpmvTrdxiIgaJsH9fvh+6Bt05zN0fyU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UophkesT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="UophkesT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D422C4CEE3; Tue, 29 Apr 2025 17:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745949277; bh=7ENcSCnSl/RnKPu999SQ++NgTEAfpQ/Y6OnEf7Oy0/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UophkesTKQqtYQAMn0bJCZkDLoNJWE/aytQwdofnnSp8Xu879B5w6uO+1TQy49AaH PCkeO6uIZ6ony1mQFyYVmY/NG66TNbZszGcaC5YKMUE9KI84JCeGtmemRw+FrQCo/s ey0AYh//wgl5SiXeGfeyZHhGEBjhFLR58JeeeKfw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Lechner , Marcelo Schmitt , Sergiu Cuciurean , Jonathan Santos , Stable@vger.kernel.org, Jonathan Cameron , Sasha Levin Subject: [PATCH 5.15 267/373] iio: adc: ad7768-1: Fix conversion result sign Date: Tue, 29 Apr 2025 18:42:24 +0200 Message-ID: <20250429161134.105757360@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161123.119104857@linuxfoundation.org> References: <20250429161123.119104857@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sergiu Cuciurean [ Upstream commit 8236644f5ecb180e80ad92d691c22bc509b747bb ] The ad7768-1 ADC output code is two's complement, meaning that the voltage conversion result is a signed value.. Since the value is a 24 bit one, stored in a 32 bit variable, the sign should be extended in order to get the correct representation. Also the channel description has been updated to signed representation, to match the ADC specifications. Fixes: a5f8c7da3dbe ("iio: adc: Add AD7768-1 ADC basic support") Reviewed-by: David Lechner Reviewed-by: Marcelo Schmitt Signed-off-by: Sergiu Cuciurean Signed-off-by: Jonathan Santos Cc: Link: https://patch.msgid.link/505994d3b71c2aa38ba714d909a68e021f12124c.1741268122.git.Jonathan.Santos@analog.com Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/adc/ad7768-1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c index 22c0303587b07..c922faab4a52b 100644 --- a/drivers/iio/adc/ad7768-1.c +++ b/drivers/iio/adc/ad7768-1.c @@ -142,7 +142,7 @@ static const struct iio_chan_spec ad7768_channels[] = { .channel = 0, .scan_index = 0, .scan_type = { - .sign = 'u', + .sign = 's', .realbits = 24, .storagebits = 32, .shift = 8, @@ -374,7 +374,7 @@ static int ad7768_read_raw(struct iio_dev *indio_dev, iio_device_release_direct_mode(indio_dev); if (ret < 0) return ret; - *val = ret; + *val = sign_extend32(ret, chan->scan_type.realbits - 1); return IIO_VAL_INT; -- 2.39.5