From nobody Fri Dec 19 16:00:58 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C649ECAAA1 for ; Mon, 24 Oct 2022 14:18:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233111AbiJXOSf (ORCPT ); Mon, 24 Oct 2022 10:18:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235547AbiJXOOu (ORCPT ); Mon, 24 Oct 2022 10:14:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B43F10B46; Mon, 24 Oct 2022 05:54:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6649761323; Mon, 24 Oct 2022 12:16:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EFBFC433C1; Mon, 24 Oct 2022 12:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613786; bh=iHjA9UZZEe3lNIcO82e1PBlGNygInJEsytiPcnt3KpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VpBqEwO7rAuwJ95XTA0CztlhAcqJOrLBb5Ph2z3s/PesDh/KAFqFzXaMzy5l5ESqr tCWqYgoVl5Z/GbPRg4IEm6CYw2Jxm6JLmGIdAKjKY9/OAXzQzYyhoCt++6x42nRKOT 9SB6kdFUmAyRfhKTbdy7oi6ysP8Jj5DxD0x5hbUI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Nuno=20S=C3=A1?= , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.10 014/390] iio: adc: ad7923: fix channel readings for some variants Date: Mon, 24 Oct 2022 13:26:51 +0200 Message-Id: <20221024113023.162341121@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nuno S=C3=A1 commit f4f43f01cff2f29779343ade755191afd2581c77 upstream. Some of the supported devices have 4 or 2 LSB trailing bits that should not be taken into account. Hence we need to shift these bits out which fits perfectly on the scan type shift property. This change fixes both raw and buffered reads. Fixes: f2f7a449707e ("iio:adc:ad7923: Add support for the ad7904/ad7914/ad7= 924") Fixes: 851644a60d20 ("iio: adc: ad7923: Add support for the ad7908/ad7918/a= d7928") Signed-off-by: Nuno S=C3=A1 Link: https://lore.kernel.org/r/20220912081223.173584-2-nuno.sa@analog.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/ad7923.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -93,6 +93,7 @@ enum ad7923_id { .sign =3D 'u', \ .realbits =3D (bits), \ .storagebits =3D 16, \ + .shift =3D 12 - (bits), \ .endianness =3D IIO_BE, \ }, \ } @@ -274,7 +275,8 @@ static int ad7923_read_raw(struct iio_de return ret; =20 if (chan->address =3D=3D EXTRACT(ret, 12, 4)) - *val =3D EXTRACT(ret, 0, 12); + *val =3D EXTRACT(ret, chan->scan_type.shift, + chan->scan_type.realbits); else return -EIO; =20