Received: by 2002:ac0:950e:0:0:0:0:0 with SMTP id f14csp131775imc; Fri, 15 Mar 2019 19:14:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLQNTZreLkowfp5eHRHk4V1Mz7gSt2LxFcDLk+/Nh3UmzGiPyXu5dXxfafyo5KgVEnl8y+ X-Received: by 2002:a17:902:a714:: with SMTP id w20mr7646408plq.331.1552702499051; Fri, 15 Mar 2019 19:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552702499; cv=none; d=google.com; s=arc-20160816; b=WltnH3Q2it8gXwVIBH/LU66thsxtgTRqXI6n80nIhFXrmiDHopVeKX5+d/zaqwo0p1 k57mIULexGuS/akHpjxo2SIZfh4MDk/K95cHiO36NebfJkY22NF9pM4+74Aklb8N63to AekJRx3xaC1uQ04ANDr9bOXp8twd0W6M7DfenSaEO9uPiSTE3oS95bCngcyIR6VctSGr pAfSvgTzeq7ud4SjL//h/I937Ek9Hu7ExePKAOnn64gInIluI9dY4u50rgAq0yplseK1 V3ZCowfOdvzDY5YgrJWRr4qJpJOP9Ms+IOtawfXD9t1O7OKbXTQ0XFHMNNK/wkAoYegA XzxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=EW53I3tp34rqtQ/MxyH8jsvT9bUM1N0O3iRAvZzkV/I=; b=KNaF/iLbNCOohvBo/atW/z5v0/MsJIACGYqX2/By75q6sv/YNmk0tmO3o/E3/sVnM2 8TeD9jSzqzQ50xo8tka/ERoxjTpZ47HqQuSShWm89KrZq1xLEd3+QiTBO34FrCdM2ZcQ HxJfeSvtFrS80vusMATN0SOdSsMxfCalYnOjjk6taRDOu6dfw6vxZ+HTfwYjU1bpfJ6r AMut05yp0Sy4j/dB2J22PzhofSqxkSTxG2TFxtzd5LLLXyiYKHtGyvwLqsu1jtdf0LkA ZhjOyDqz4fe+bXEkcfQmcVzpIPGerI2giDt+BxdhJJEY0v+n2yQE5QcJXPQfJytupQPg rihg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Z31pZ43v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si3107526plt.215.2019.03.15.19.14.44; Fri, 15 Mar 2019 19:14:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Z31pZ43v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727044AbfCPCNU (ORCPT + 99 others); Fri, 15 Mar 2019 22:13:20 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:41820 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbfCPCNU (ORCPT ); Fri, 15 Mar 2019 22:13:20 -0400 Received: by mail-qt1-f193.google.com with SMTP id w30so6969033qta.8; Fri, 15 Mar 2019 19:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=EW53I3tp34rqtQ/MxyH8jsvT9bUM1N0O3iRAvZzkV/I=; b=Z31pZ43v3zmFMa+52uuvPtWcEq5rQS55LJv3qM8rd3Pnm24SU5/dHfU/n4QegNmJCV R5j/FKnQo8Z5g7iyV6a7ziYPdKODmyrgKzxG+I9jVeYqSJAt6f7TD4U3mJq/2DjGJxtk bd0qBTnZVB9+DhE8byT2Qb+cFboXZF1i54EzLnVB61qq8rUrL9c7sih8AN1FJGHKYnpZ LQEXPOKXMzo5lft5CjYRLr1eRHd+HArLD/BgBKijHVkwfVvIOGQkonW5maBI8AkID4Sn Vcyk7n03MiCJ+BrbMBlxP5QYfyWqeY+GD+5J8LdkvduiM1FYlkS78K+uRW6AgIdP23cZ ciyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=EW53I3tp34rqtQ/MxyH8jsvT9bUM1N0O3iRAvZzkV/I=; b=c4TMo/SHcgiB5wWFQru5/VF+ahxhKkxBA5eB+wCzV6slU2nx4qe8gZmrxZVXMwrmIF NTXYKx4pt76MCvwivxNh5EdsKkYmfRPK7n5mqQSL9Xu+AtwORsdJTMgtCXxfVca/NmwZ rvBrNizEugktc0bDT2PEGozAMfViWnhJFJqEnl/E3/PDgJaraK9o/C0jV7UKyhYTn+HX SQ5/5S8tiaRbYpyacyqVl455aBDkm0oZB7275kJkL+bJWgG7eqlUuPs5Bs2bgXGfI1IA q6SZaqOTpWn9yisHWXK5YgAJWtldWqEF2A+rOShfZdWFO7MqzZKNgYi9WC+PPcefU87y avYA== X-Gm-Message-State: APjAAAX5KEGtRnfWpWwx2kQWsUfv+lNsbGo/nFcJPxnYGx5D+ftLE+tP vYzd7q1Hs7cvKP6ekue0xK4= X-Received: by 2002:ac8:1bc6:: with SMTP id m6mr5104987qtk.8.1552702399222; Fri, 15 Mar 2019 19:13:19 -0700 (PDT) Received: from renatolg ([186.220.21.102]) by smtp.gmail.com with ESMTPSA id d8sm1774846qtp.50.2019.03.15.19.13.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2019 19:13:19 -0700 (PDT) Date: Fri, 15 Mar 2019 23:13:13 -0300 From: Renato Lui Geh To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, stefan.popa@analog.com, alexandru.Ardelean@analog.com, giuliano.belinassi@usp.br, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org Subject: [PATCH v5 03/11] staging: iio: ad7780: add gain reading to ad778x Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds a new functionality of reading gain values from the ad778x chips. This value is stored in the chip's state struct and is updated whenever a read or write call is performed on the driver. Signed-off-by: Renato Lui Geh --- drivers/staging/iio/adc/ad7780.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index f4cd7bc3e02f..fbcc0d3345ca 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -42,6 +42,8 @@ #define AD7780_GAIN_MIDPOINT 64 #define AD7780_FILTER_MIDPOINT 13350 +static const unsigned int ad778x_gain[2] = { 1, 128 }; + struct ad7780_chip_info { struct iio_chan_spec channel; unsigned int pattern_mask; @@ -179,6 +181,9 @@ static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta, ((raw_sample & chip_info->pattern_mask) != chip_info->pattern)) return -EIO; + if (chip_info->is_ad778x) + st->gain = ad778x_gain[raw_sample & AD7780_GAIN]; + return 0; } -- 2.21.0