From patchwork Sat Oct 22 07:18:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7143 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1087569wrr; Sat, 22 Oct 2022 00:36:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/Mk4Mu/5x95gudH/DIf5b15qdLBWs4csVwt5WiWMn2tf4pIeReXqc2Fq48+MCHF2ORtoq X-Received: by 2002:a17:907:3ea4:b0:78e:25e2:c33b with SMTP id hs36-20020a1709073ea400b0078e25e2c33bmr18271929ejc.603.1666424219007; Sat, 22 Oct 2022 00:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424219; cv=none; d=google.com; s=arc-20160816; b=dYXZ58vPQzx9oauuhrdHoqApwd1mE3vPlQUtckJ9mFwF0Urc7SAIk+K2Y1aoFz0cHe 8z8H21/BK6nPPCzY2gSqdYhJDjrc5gRWf6rsBA2B3XUMvPOZTOt1LF994jb4fTIAVVWC qWr2bMYw/0mNC1Roz1jfgjz8ugEqoAbWxzIh4MB9xnWbFDDYhv5UxC0/ombtkm3yTa24 sI7+xYt8DASanTgJ0CUqIth2Pd/BK1bJ6eT7gU91BqNLz/oj7O5R3zwA7OcTw4s+pNSO qocI4HYs11A7f5ELYDZsLhs4976tdu0SHMtdjSQlzfFuF/edcU14rhgI501BkJZA5pfT qfkA== 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=R2oOnadywMpAXObGGxWfODPdLCzObm5yiLWHR2++LVmm0oSJX532lIkmgAz5Z33rtX oO0xCCRrERyxS06PhWtusTCMPFmOkVSm4XgLY08HRWmaIc68oTHjp+bN0YXl9hN/7XTm 3c0SpROMo+ePVBtJfJ1CxgDBcXsEE+mtU7kCqv4Au7QwgoOrxN6sTRpkvcforUe6kIQf jpmKxZFAE10yM00AK8NEcz2YDtU0kje3Tm1BIaPi3U4YRTZkohKSyzFVcuI3SL6DPmcu TokiaCE/TC4094i0jbSdNcU2AGjFLhmAkn1luuYh3o77nXSYkh6vJk5ZVfVx8EWq2MvZ DOYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z58ydCmm; 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 xa8-20020a170906fd8800b0079dccbbf0c0si3005237ejb.146.2022.10.22.00.36.35; Sat, 22 Oct 2022 00:36:58 -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=Z58ydCmm; 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 S230188AbiJVHfr (ORCPT + 99 others); Sat, 22 Oct 2022 03:35:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230193AbiJVHfL (ORCPT ); Sat, 22 Oct 2022 03:35:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F6A310B9; Sat, 22 Oct 2022 00:34:42 -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 4C6E860AD9; Sat, 22 Oct 2022 07:34:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42C5DC433C1; Sat, 22 Oct 2022 07:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424080; bh=ua2YKCret8Q3QdpyymxKIeW3ykV2g5RTC7x+GcOzxVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z58ydCmmhDIST5ZKR4nRnChXTCxmA10teoGqWaR8GZxkK0hA9wpqLSeSDSs5IxcOZ B3lLr1qTUtj1e/BdyZDZca5IJFz1nqEimj/hV+ePundNexfn8lFgsD2P/bORV6IKtB eqZXA/bBnEPzxv+mvh1qkiLiDI/3WkatdpdcVxXc= 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.19 021/717] iio: adc: ad7923: fix channel readings for some variants Date: Sat, 22 Oct 2022 09:18:20 +0200 Message-Id: <20221022072418.828181689@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747372441840543066?= X-GMAIL-MSGID: =?utf-8?q?1747372441840543066?= 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;