Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp327401imu; Mon, 26 Nov 2018 11:27:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/VPiY9kHptaX2YP2D/esV0A4u0dCfzqnsYHZgrYXdQwqqOQU/lyIDEnv4dabYMqW+fW0gaF X-Received: by 2002:a63:ac46:: with SMTP id z6mr26119374pgn.162.1543260425882; Mon, 26 Nov 2018 11:27:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543260425; cv=none; d=google.com; s=arc-20160816; b=hPkw5ZUtLJCid7rXDK8Pathn1hwNcTBahb709cDowq0FJ5MfA5kx8ZN0Jr8l9JYr2v Droh6D2KOQZscoaFMzTqyJNhY3eFtRWLtXVWSFBEPGNDeT5zk2ex4fNOJYvltjYJHxY7 GKWful/MmCzoNxRLLUDLq/CZcdu9BhpiL3eB4XcGiPtlTED6FmPQoErus4gaRuKIOFM/ WLH1bLMX9GC5Mr2n2ZW89AWI2zEOsFVw5aiZFum2bIcHJrSriTYUj/2qF3VYAh+CIQOj fJKOnycnOJ4BDvnez07YZJS8BnjZ+V6D42WkTmkgUBSMxVGo5BOLgKYOAAslFJErYb9D pWIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=AvfIZ9PB1dFlppUzJKR1909FJIJrzR+QBaeS3Cpmn9w=; b=bKVAZuJuixsDVY+Sj/FgVHRQVbhsJNeXQ35HbX7ZkhGDno/cQdlWm0S5Yzhy+rsLhL kT0ibjvTHCPOcoK+DFrxqvKLekdElG2dh3JvNVicCXLSds9XZWvIOJNDXX4L3lSv8W0P 9haUGgOJpy/YeYwbmz1mRJ9EGgnykXmzVWPOk8A9VF38W9+F95diubv61g9bPk7fuxYR 0Xu42qDPfAUJNeDzuDt9jiAHELvrVq9iPK8xKi33GMvYh4Iq0M6fZdO8sh8GSlZVzuTs /+KWM6A/dnPAy+1y/0L98IxTdalzT2JbLJnXBzfQm7QRL4c5pFhfJfDm289EiWEgMeN+ E2FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SVX38tyo; 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 i20si1073951pgm.586.2018.11.26.11.26.36; Mon, 26 Nov 2018 11:27:05 -0800 (PST) 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=SVX38tyo; 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 S1727086AbeK0GTd (ORCPT + 99 others); Tue, 27 Nov 2018 01:19:33 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:46639 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726357AbeK0GTb (ORCPT ); Tue, 27 Nov 2018 01:19:31 -0500 Received: by mail-oi1-f194.google.com with SMTP id x202so16926601oif.13; Mon, 26 Nov 2018 11:24:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=AvfIZ9PB1dFlppUzJKR1909FJIJrzR+QBaeS3Cpmn9w=; b=SVX38tyoPh+Ne0hZ4ujiqVS3FY9BW7IyBp9zzj9KEj6shQAl+X/ODvU61qvCO5fD2r mUesX+qfnBKb9mYtmljgwOS/ijdZZ2zGzhkRVIqjOT1TPWGo+LKmaDz7QUXxNulCD4lE ONd78mQb+hHADpOag08TDvikUporiCcLxzCnSNHxrKfyUGZ5EcVDxgp6jDXZghgpTwhq hWH1zj6sjcwM4Z/w3j+/tuAbHz+hIv/Y2LaBddlgppeQFi31IZi4lHq9qt1jF2/0cts8 wjOKsrJFc0r50i2+PfX1x5IpY0SscoB3Ig+np68lW/Rxgww7QzM2mbDb1pS1IjYiMKDZ gOrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=AvfIZ9PB1dFlppUzJKR1909FJIJrzR+QBaeS3Cpmn9w=; b=RBPNbEGTIeiZo/AAmElywdK5cbLcnES0mFZ3Q5TqX0QDbe68z/Xbbw7IqPdpVqgSvS PNIm9VHi+KNijsi3d9DgP7x9AyhWbtI1GCNbyUCg1pNYC08PU0lJI4E2Wp8dF+fQi1BY IsYjDroYuPVg570lI44r3bE87bN6KL3qHYAC92YixfdZhWcuiyTt4atkfBCgKsMfiszP xzOuS4XHS586puIjl25vmZTFDS18AkIfF5sxnEYvXG0ob9MSs3w1X6pgSDww+EXLtBm4 rQlMl2BlW5qpZsM/XS4T9n2lhxy157+eMBesCtFz/7pUwJRb6CWUALwjpdm/htGqS+nz A1fQ== X-Gm-Message-State: AGRZ1gJ3ECDWtPvvJDorHQTREaGq3s6YwXf0nYOlkZHS7r4jkMkK2itv EtPx3pXCPxzzvxlVFrU1qeSBsOfDY+/aZzb1rEU= X-Received: by 2002:aca:a60d:: with SMTP id p13mr16745510oie.2.1543260265055; Mon, 26 Nov 2018 11:24:25 -0800 (PST) MIME-Version: 1.0 References: <20181121180443.tjgcpu2webrq53rh@smtp.gmail.com> <1542884458.30645.22.camel@analog.com> <20181125110839.4a3aecf9@archlinux> In-Reply-To: <20181125110839.4a3aecf9@archlinux> From: Giuliano Belinassi Date: Mon, 26 Nov 2018 17:24:13 -0200 Message-ID: Subject: Re: [PATCH] staging: iio: ad7780: Add gain & filter gpio support To: Jonathan Cameron Cc: StefanSerban.Popa@analog.com, "Ardelean, Alexandru" , Lars-Peter Clausen , Hartmut Knaack , Michael Hennerich , Peter Meerwald-Stadler , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, thank you for the review > On Thu, 22 Nov 2018 11:01:00 +0000 > "Popa, Stefan Serban" wrote: > > I think that instead of setting the gain directly, we should use > > the IIO_CHAN_INFO_SCALE attribute. At page 12 of the ad7780 datasheet t= here > > is a formula from which the output code can be calculated: > > Code =3D 2^(N =E2=88=92 1) > > =C3=97 [(AIN =C3=97 Gain /VREF) + 1]. So, by setting the scale from use= r space, the > > driver can calculate the correct gain by using the formula above. Also,= it > > would be useful to introduce scale available. > > Furthermore, there is a new > > ad7124 adc driver which does this exact thing. Take a look here: https:= //gi > > thub.com/analogdevicesinc/linux/blob/master/drivers/iio/adc/ad7124.c#L3= 37. We have some questions about the code you provided to us: 1-) What is exactly the inputs for the write_raw function? 2-) Could you give more details about the math around lines 346-348? Is it correct to assume that the multiplication at line 346 won't overflow? (vref is an uint) And regarding our code: 1-) The val in our write_raw function should be, in case of GAIN, a number that best approximate the actual gain value of 1 or 128? For instance, if the user inputs 126, we should default to 128? 2-) In the case of FILTER, is it the same? Is the user sending the value in mHz (milihertz)? Thank you