Received: by 10.192.165.156 with SMTP id m28csp2767236imm; Sun, 15 Apr 2018 08:36:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/mBOGm9NGMb/XafqqOeotHSTyLTZIexNCfhxlmTh1sYY5+EHTANdjSxoUKR9XrUmVBgUrR X-Received: by 10.98.155.12 with SMTP id r12mr18447915pfd.15.1523806606400; Sun, 15 Apr 2018 08:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523806606; cv=none; d=google.com; s=arc-20160816; b=FuXJ/pvf1bKjilqqh0bFYAdM52zHWOscoZif47+GV7Vk86pHL3ia22bt0doFVfLQvg +IbLGy6y/KpEBmK14UdnmgwZGrMXZcu41eZo4MlBkVhGqBVkV2iV6Lo8vmJVcuZAvugv o7W/RFmT9jBlLPrHzcTvH5K5PeyKNBRuOjGSchBIrBu84V+yxX7x1mw2rLR/uo+fIZa7 wOnlAjEIkWEO9hXrIQ1aq18Tr35HfOCMuAGUlhi84yxbheSJ53wUl9e4Tm3NwYbdbFDB Wec6mv/P1PtwoV5+LyhmyE/YMl8R4o6fn2bOnUwPgBrj2GGJo0/xWkgjtwS55/oRZaO/ COOw== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=aSGu/WYCOPLFHhgsc8wnhHsShl5d/Tqqj472xMJ5/UU=; b=qJ4uGmvzSe29snWDKLF3TSCd6TBrH0cxxf2koSjqteVE3fr8jM/OYwwyYJ4K/OE37y dpyu0XmF32v+7Aft+YWugL8XiQhxuuOlV3hcotJNnhJ+8Rzs4223pRXfmcjQ+9lZBcem vxgyEB8YUk/zGfL7kK3jG5jIcZhECnF4r27SXSNNSyUKN5dnj8rZbJ73n6gjW3x5QBdj bnG9bq/G00ASEeoUoEed1fSMF5b1QHNjPaRtxXOLjgec/sHEWwfK+11MkXp/Ym38UGcM ZfgvwOQ3G+0IEV4cIBVhXurLxXABbXemC8bz56p8JUynzYg+lNOB83QnL6WYdyMXZ03V qarw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p9si7777203pgu.80.2018.04.15.08.36.32; Sun, 15 Apr 2018 08:36:46 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752666AbeDOPf1 convert rfc822-to-8bit (ORCPT + 99 others); Sun, 15 Apr 2018 11:35:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:39858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752399AbeDOPf0 (ORCPT ); Sun, 15 Apr 2018 11:35:26 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EFC2D2176F; Sun, 15 Apr 2018 15:35:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFC2D2176F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jic23@kernel.org Date: Sun, 15 Apr 2018 16:35:20 +0100 From: Jonathan Cameron To: =?UTF-8?B?SGVybsOhbg==?= Gonzalez Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, Michael.Hennerich@analog.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 10/14] staging: iio: ad7746: Add comments Message-ID: <20180415163520.3480439f@archlinux> In-Reply-To: <1523637411-8531-11-git-send-email-hernan@vanguardiasur.com.ar> References: <1523637411-8531-1-git-send-email-hernan@vanguardiasur.com.ar> <1523637411-8531-11-git-send-email-hernan@vanguardiasur.com.ar> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 13 Apr 2018 13:36:47 -0300 Hernán Gonzalez wrote: > Add comments to clarify some of the calculations made, specially when > reading or writing values. > Mostly good, but a few minor comments. Jonathan > Signed-off-by: Hernán Gonzalez > --- > drivers/staging/iio/cdc/ad7746.c | 32 +++++++++++++++++++++++++++----- > 1 file changed, 27 insertions(+), 5 deletions(-) > > diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c > index 05506bf9..ef0ebb5 100644 > --- a/drivers/staging/iio/cdc/ad7746.c > +++ b/drivers/staging/iio/cdc/ad7746.c > @@ -429,6 +429,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev, > goto out; > } > > + /* 2^16 in micro */ I'm not seeing the connection... what is 2^16? > val = (val2 * 1024) / 15625; > > switch (chan->type) { > @@ -554,6 +555,13 @@ static int ad7746_read_raw(struct iio_dev *indio_dev, > if (ret < 0) > goto out; > > + /* > + * Either for Capacitance, Voltage or Temperature, > + * the 0x000000 code represents negative full scale, > + * the 0x800000 code represents zero scale, and > + * the 0xFFFFFF code represents positive full scale. > + */ > + > *val = (be32_to_cpu(chip->data.d32) & 0xFFFFFF) - 0x800000; > > switch (chan->type) { > @@ -565,7 +573,13 @@ static int ad7746_read_raw(struct iio_dev *indio_dev, > *val = (*val * 125) / 256; > break; > case IIO_VOLTAGE: > - if (chan->channel == 1) /* supply_raw*/ > + > + /* > + * The voltage from the VDD pin is internally > + * attenuated by 6. > + */ > + > + if (chan->channel == 1) /* supply_raw */ > *val = *val * 6; > break; > default: > @@ -606,6 +620,13 @@ static int ad7746_read_raw(struct iio_dev *indio_dev, > ret = IIO_VAL_INT; > break; > case IIO_CHAN_INFO_OFFSET: > + > + /* > + * CAPDAC Scale = 21pF_typ / 127 > + * CIN Scale = 8.192pF / 2^24 > + * Offset Scale = CAPDAC Scale / CIN Scale = 338646 > + */ I don't think the following blank line does much other than make it less clear what the comment is about. Same in other locations. Allow the absence of a blank line on one side of the comment to indicate it's association. > + > *val = AD7746_CAPDAC_DACP(chip->capdac[chan->channel] > [chan->differential]) * 338646; > > @@ -614,13 +635,13 @@ static int ad7746_read_raw(struct iio_dev *indio_dev, > case IIO_CHAN_INFO_SCALE: > switch (chan->type) { > case IIO_CAPACITANCE: > - /* 8.192pf / 2^24 */ > + /* CIN Scale: 8.192pf / 2^24 */ > *val = 0; > *val2 = 488; > ret = IIO_VAL_INT_PLUS_NANO; > break; > case IIO_VOLTAGE: > - /* 1170mV / 2^23 */ > + /* VIN Scale: 1170mV / 2^23 */ > *val = 1170; > *val2 = 23; > ret = IIO_VAL_FRACTIONAL_LOG2; > @@ -674,7 +695,8 @@ static struct ad7746_platform_data *ad7746_parse_dt(struct device *dev) > unsigned int tmp; > int ret; > > - /* The default excitation outputs are not inverted, it should be stated > + /* > + * The default excitation outputs are not inverted, it should be stated > * in the dt if needed. > */ > > @@ -685,7 +707,7 @@ static struct ad7746_platform_data *ad7746_parse_dt(struct device *dev) > ret = of_property_read_u32(np, "adi,exclvl", &tmp); > if (ret || tmp > 3) { > dev_warn(dev, "Wrong exclvl value, using default\n"); > - pdata->exclvl = 3; /* default value */ > + pdata->exclvl = 3; > } else { > pdata->exclvl = tmp; > }