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 5DF9E82C60; Tue, 29 Apr 2025 17:25:24 +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=1745947524; cv=none; b=QGzrhSYcqBXMrqV+A6Bu5tCUOgv/CJrrFsKgPSSlVuoYb61cUa9vmZ3CUDkIqUPywbzePTvkrn8ndEPG3hAY323d7plm35AJOOuWpmpKB1ul0ML/4GozPYdxGcVKJ8DVyTlnMAdARrEQVRTPkZ+FCGE8hL/bo0pTaywyWbwfQrg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745947524; c=relaxed/simple; bh=4bYj+A0/nKLZdHxwaciZPDcXd0SXBUjYl+sCfupR2Jk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pIIKL8SjXH00pluOkI4whj0TKk33nm9fZI3bp1RoB4mkaRCTBVynivjwbV6rgqPE76YVju9M5jHOZTTWO9P2m872PUjLXYdxOScyJe8jWhNNb3N0mk47TpYVAYYEn9Lpcx28jzUKS8ztz1AlThUNDQuspoq5gGgvzi3Mu8lYE2k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nSlCg2xw; 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="nSlCg2xw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBA80C4CEE9; Tue, 29 Apr 2025 17:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745947524; bh=4bYj+A0/nKLZdHxwaciZPDcXd0SXBUjYl+sCfupR2Jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nSlCg2xwZlOHSZraWMHbes7y5EfX7R3Os06V+Q1B3WWUOwPZmLs9LYW+J3NmPQUdm IJ5wK3bfEDikio9YF0t+xZY6Q2a2eo7lrAX4VcQU7ziNTUv10PFu374XcYGVahH2ZY DFk9M5juCMj/wzwm7NIJaXpm4P0B4A7XchNcyLbM= 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 6.12 022/280] iio: adc: ad7768-1: Fix conversion result sign Date: Tue, 29 Apr 2025 18:39:23 +0200 Message-ID: <20250429161116.002815616@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161115.008747050@linuxfoundation.org> References: <20250429161115.008747050@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-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 c78243a68b6e0..157a0df97f971 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