From patchwork Wed Oct 19 08:21:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4513 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp203073wrs; Wed, 19 Oct 2022 01:42:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5lug2k6sWhhPszYmthuVBg/d8sZNB7KwZktituw+nOsJvYZyE6toMvyCqV9ZVIFqYJCGRY X-Received: by 2002:a17:906:8a4b:b0:78d:d475:ff74 with SMTP id gx11-20020a1709068a4b00b0078dd475ff74mr5542302ejc.131.1666168929614; Wed, 19 Oct 2022 01:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666168929; cv=none; d=google.com; s=arc-20160816; b=gYbCCuuuzlvxPxewKFntRmHpzaXJkXGq89c2GTxm6c+l6F5+6wMDr/kGgCDkBCeKbH gCoLFVPg1UPyNUCJte+zSG0H8X/AhxKlBvf9/vGp7lYt62BaAZTJ08EDvdTFbdPM9Ilz D/eJyicu+x8U6o4cn3KadToc/DBTnpksgvHZiG87+pLrErxUkbcnTGMqHeFBz6vgDQxq 7zICYmyfgvlRdUM5YHsv9/s+Ft9Ez50rmjY8A8F9fIaRhOlRf2sYucp0ZHd2o7lrNf09 8/EWrelLZkQ3L2Xg9azWUiQs/yRn2f+Dy0SraZpT+dTo/Hv434lwyGrWtRB33hlpLOiW 5VzA== 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=hwuEHQ4Yj4TnGatb2JRWwukiknIOVCPFr4FcDVO1pTA=; b=Kg5mRFm9aL1Ia3i/t2jy2IMRdT+4/L+HKaXBi2cafKWoZ6OR17U5eJmPquuzkQEZ7H 9mrLymJ2FacRUfYP1HfKpkt/pkzizPFWiJnHNf+/JVXN3/Otxy7o6rt63JAHydM1izu7 db64nk/tJnluxpkIcgdxEe+cCr3oSlVi9D1YCISfuuMx/nwtNXJ1IszB+lJl+Ac35xSf ccqyvIiwX5YgmG9QIG9DXBHBMU2hfP5De6vzsdcm4sIWJIIfGcWKuR3nTf4+2V9oEiCi uQUMo4yspZ4x7d7kcUSs3X2P7zloDnnL9ylL6cVDqbz+fsL6Zn5lpIy2D3DevIYupIkm QD4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pXgbJ2Q+; 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 nb21-20020a1709071c9500b0078049ab4bbasi14898950ejc.526.2022.10.19.01.41.45; Wed, 19 Oct 2022 01:42:09 -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=pXgbJ2Q+; 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 S230319AbiJSIk6 (ORCPT + 99 others); Wed, 19 Oct 2022 04:40:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230186AbiJSIju (ORCPT ); Wed, 19 Oct 2022 04:39:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CD78814C0; Wed, 19 Oct 2022 01:39:01 -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 88913617D1; Wed, 19 Oct 2022 08:38:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D194C433D6; Wed, 19 Oct 2022 08:38:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168704; bh=ua2YKCret8Q3QdpyymxKIeW3ykV2g5RTC7x+GcOzxVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pXgbJ2Q+GPQIHGGeDXoFXdfDPF8o9Eta5Inl6wFNqDZP8r3Wrq3vkYmXmegQcEgsz FNilUXbvBTh4qP991iqwT4x8ERwZrybFH6hPLlPOXaYhLa5Vca+sLTS3FAuGbSwPDX k+2xlTx7Ml1O4ioEjY+4hs7R6xy8u8o/rqjJ1vk0= 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 6.0 026/862] iio: adc: ad7923: fix channel readings for some variants Date: Wed, 19 Oct 2022 10:21:53 +0200 Message-Id: <20221019083251.144378655@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747104751639920897?= X-GMAIL-MSGID: =?utf-8?q?1747104751639920897?= 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, \ }, \ } @@ -268,7 +269,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;