From patchwork Mon Oct 24 11:26:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9478 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp480613wru; Mon, 24 Oct 2022 07:21:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6TGFcPVD2bIoYPjQYwCrJZ7qActH3n4WWqhDaycMnFBVeWpv2fARD4VydAwScf3shlVFwH X-Received: by 2002:a17:906:8471:b0:7a2:859a:873a with SMTP id hx17-20020a170906847100b007a2859a873amr8733463ejc.730.1666621280114; Mon, 24 Oct 2022 07:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621280; cv=none; d=google.com; s=arc-20160816; b=J2MgVVepJpBI23VEjKvO5PEKfNkSc9kfadFosFWyU5euJTn9TCpn8tx++qQZReCW30 tc/IhM2Nu5voWGWbVyt5ZeNl8AREAP4CQDXyRy/6jHADFTL9ajRqaiMiWzFDKZlPCd6K A5tjz3aH+ZFF0AwVhQHGHTTel5Oj3PKTGYqWh5n7R82O6sLrK44QCAv9Q9RrL5R4wfaB rUAK5YR9DeBvyijYgnmDclRYPbVkjXfrdhPaLG1QjTruGepwZHkFo4V7X7rv1J/R9bgn 57glEubbIlMgkepNT1+oXW7KkU51BLsypYAaPLMQm4qqEu7zqAZXkdb5W39GKuqzPn49 W49Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gjJGEXbkkvR0vo9OkNAuRJKyNnf2UOv5tNkw3BcvuKc=; b=bsm359IWTLxcKVg+JEHCqHfMk+OqI+1Njhe3AysrdFREHaUlmG/E1lwpbsTcbVDs8O f6EiK9vHNC5F/bOyPLs8M3W6sPugWpCW5qa8rCqvn+xrZ9LiuflTRcByY56WEQUuV2aZ 4dT97dXZQusixfmCuOnkzoMvMp2P0sWEjXT6kfaivqbdKl3tzaxxQM25MiyKbSiHsx/o zy8i2MLTVpUe8hakqx2vwa6+0ymtedKJpX/QnEZ0dRQnBx4CXwEYJ+ZCOvNue9iJqKN6 sEnJaUpuxscRK0ojiR0Rg9USZBD6fNSo9YQnKaU4Ciuy9aaFRIiGr1qfNIonVcBcdfqb d8YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VpBqEwO7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go42-20020a1709070daa00b007a7b4b41ccasi3194869ejc.562.2022.10.24.07.20.54; Mon, 24 Oct 2022 07:21:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VpBqEwO7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235084AbiJXOS3 (ORCPT + 99 others); Mon, 24 Oct 2022 10:18:29 -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_S=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 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747579075349736531?= X-GMAIL-MSGID: =?utf-8?q?1747579075349736531?= From: Nuno Sá 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/ad7924") Fixes: 851644a60d20 ("iio: adc: ad7923: Add support for the ad7908/ad7918/ad7928") Signed-off-by: Nuno Sá 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 = 'u', \ .realbits = (bits), \ .storagebits = 16, \ + .shift = 12 - (bits), \ .endianness = IIO_BE, \ }, \ } @@ -274,7 +275,8 @@ static int ad7923_read_raw(struct iio_de return ret; if (chan->address == EXTRACT(ret, 12, 4)) - *val = EXTRACT(ret, 0, 12); + *val = EXTRACT(ret, chan->scan_type.shift, + chan->scan_type.realbits); else return -EIO;