From patchwork Sun Feb 7 15:46:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12073101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3841C433E6 for ; Sun, 7 Feb 2021 15:50:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C05264D9A for ; Sun, 7 Feb 2021 15:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbhBGPu3 (ORCPT ); Sun, 7 Feb 2021 10:50:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:34026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbhBGPu0 (ORCPT ); Sun, 7 Feb 2021 10:50:26 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A9A8C64E60; Sun, 7 Feb 2021 15:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612712948; bh=Jp1GDzXZcYQ/pOlj6E9N5al14Xc2+FKEaMLpmh2SWpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LfZCXzVsdtJ6gHXisjXkTqvXjVdiEYtxsffkVBZeZ1CppDC6Fey3CASrbdyEk/zPl SfL+peDRIznMCnIoBrK/KwMujY0gH1ehd+kkt3gKMwCOuX48NxcdRr1UtyIEL3NnoQ 96lnliLzaVd6bk+SEWaYxDJBf5HF/7V4f9/SeUv78+saoR6/hSHlEsfX/1xMMYmOuJ O6+tsFbMVAKvfglFtFSJcYJ2NFnU5YugM4e+krpYiEQXl5KRakpQE/o4jQ3fx21fM+ LQtuDe8I58CCgWZXfPxv6MHV5On/FIuIw02rQqep+qmjqVXOk+wuTAdA4UU4yQ53To AkTL39pWjkECg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , song.bao.hua@hisilicon.com, robh+dt@kernel.org, Jonathan Cameron Subject: [PATCH 17/24] staging:iio:cdc:ad7150: Shift the _raw readings by 4 bits. Date: Sun, 7 Feb 2021 15:46:16 +0000 Message-Id: <20210207154623.433442-18-jic23@kernel.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210207154623.433442-1-jic23@kernel.org> References: <20210207154623.433442-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Every other register related to raw value on the datasheet is described as correpsonding to the 12MSB of the actual data registers + the bottom 4 bits are 0. So lets treat this as what it actually is, which is a 12 bit value. Note that we will have to be a little careful to compensate for the offset and scale values. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/cdc/ad7150.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 4c83e6e37c5a..97689625f26c 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -111,7 +111,7 @@ static int ad7150_read_raw(struct iio_dev *indio_dev, ad7150_addresses[channel][0]); if (ret < 0) return ret; - *val = ret; + *val = ret >> 4; return IIO_VAL_INT; case IIO_CHAN_INFO_AVERAGE_RAW: