Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1840328ybl; Sun, 18 Aug 2019 11:41:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqztWF5sMPetfNbHkwKYK2vgYdgmgSn9UXiFdFlzbSMFNQHi/u8O5xbMQqYd6t2n3OsQYw+r X-Received: by 2002:aa7:915a:: with SMTP id 26mr20686075pfi.247.1566153685081; Sun, 18 Aug 2019 11:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566153685; cv=none; d=google.com; s=arc-20160816; b=lABl6VEeCqJwQV3miuuNhaW/0RtELrLIIA9nIMOFR6Q3L1EqVjpgRHSdtSVbqU99mB rK6oxozO5zPXBDTtdU76Dn3npxnJRDh608pNXsLJ5Z9RnW8Mizhpdofp7s4wFJLt96/b 3sdZ9pYBWViWTyDZITDIGMo2CSXMGidoKLhmALmY1VcLqbSoeLhdQzcINcl1110jDeTI e2Akq231GXtH4VXKRFp+B2LCuf/SQL8IMj9UWD8m+MBd5RJpnYS4yOl9NLTIq6Bwp2yT 4XQVG+wmjXSklZhrsx7f2aPDZnADL4OqcbGb6CsHcKA4CgNidY+/JXRV11pSYACHm/pK YoqQ== 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 :dkim-signature; bh=hA03fSfjhvr0oFU1saulkqmNwf7G886icqdFq+6au/Y=; b=JpCi7EcO6oaGiaO2cndWjlNBcGi1Xn2UdB0cMKh9UCepei029EFPBYQB4TNlX/U0et JQJu4q/ELx/TxHAoYFaooxCvD8uoffMAhIs/0QIG/a4MeBRVXSezxZI45lTmBTMRmAic DzIVOTUvpoF9tYLEPS/avHRpKW80ddKBMCwkwmCdjwQIcew7tP/gdb5CYsM2qd6XYUIy 9wLTDWogCCAXGoUGxmNRl3kWtVfBuG5GKXRo7G22QpuR8vsN8IgNeHSKKGoUqn6/6kfb qwLDtEcp4Lm1dpG7DLU75ocOT4wtiUVb58ciiwtg1xBVvz+J9wm9vFsPKjuB6BGrPZ1h hjVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UBO+B9Se; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14si8419191ply.347.2019.08.18.11.41.10; Sun, 18 Aug 2019 11:41:25 -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=@kernel.org header.s=default header.b=UBO+B9Se; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726961AbfHRSkX (ORCPT + 99 others); Sun, 18 Aug 2019 14:40:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:48562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbfHRSkX (ORCPT ); Sun, 18 Aug 2019 14:40:23 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 1AE6720B7C; Sun, 18 Aug 2019 18:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566153621; bh=meJqC7/AX0rwugLoFXfdiYsPkc55SQda8m3FYAF6tR0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UBO+B9SebXTSJYPls00r1xIsQX4qJWhg84bwALN3eX1zexkhkcPfX8P9rGPtv8P4m FCT6wWTU00a196WwkHHE/sgsOrzs0nNUnCK8tWJnZp6r7aphFLkd496Dw2odzBXZvm gta3ANyLnSYeYUOSxViPJMAj/1l/OinffoA9JlxE= Date: Sun, 18 Aug 2019 19:40:17 +0100 From: Jonathan Cameron To: Mircea Caprioru Cc: , , , , , , , Subject: Re: [PATCH V3 3/4] staging: iio: adc: ad7192: Add system calibration support Message-ID: <20190818194017.7ba2fc97@archlinux> In-Reply-To: <20190814073150.4602-3-mircea.caprioru@analog.com> References: <20190814073150.4602-1-mircea.caprioru@analog.com> <20190814073150.4602-3-mircea.caprioru@analog.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 14 Aug 2019 10:31:49 +0300 Mircea Caprioru wrote: > This patch will add a system calibration attribute for each channel. Using > this option the user will have the ability to calibrate each channel for > zero scale and full scale. It uses the iio_chan_spec_ext_info and IIO_ENUM > to implement the functionality. > > Signed-off-by: Mircea Caprioru Hi, This introduces new ABI so needs documentation in Documentation/ABI/testing/... I'm not particularly keen on a write to what might be considered a mode select register resulting in a calibration starting. That is rather non obvious, I'd prefer to either two attributes to trigger the two modes, or a mode attr and some sort of calibrate now attribute. I'll back out patch 2 for now, as it was there to support this. Thanks, Jonathan > --- > Changelog V2: > - no changes here > > Changelog V3: > - no changes here > > drivers/staging/iio/adc/ad7192.c | 55 +++++++++++++++++++++++++++++++- > 1 file changed, 54 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c > index d58ce08f3693..731072830f30 100644 > --- a/drivers/staging/iio/adc/ad7192.c > +++ b/drivers/staging/iio/adc/ad7192.c > @@ -155,6 +155,11 @@ > * The DOUT/RDY output must also be wired to an interrupt capable GPIO. > */ > > +enum { > + AD7192_SYSCALIB_ZERO_SCALE, > + AD7192_SYSCALIB_FULL_SCALE, > +}; > + > struct ad7192_state { > struct regulator *avdd; > struct regulator *dvdd; > @@ -169,10 +174,56 @@ struct ad7192_state { > u8 devid; > u8 clock_sel; > struct mutex lock; /* protect sensor state */ > + u8 syscalib_mode[8]; > > struct ad_sigma_delta sd; > }; > > +static const char * const ad7192_syscalib_modes[] = { > + [AD7192_SYSCALIB_ZERO_SCALE] = "zero_scale", > + [AD7192_SYSCALIB_FULL_SCALE] = "full_scale", > +}; > + > +static int ad7192_set_syscalib_mode(struct iio_dev *indio_dev, > + const struct iio_chan_spec *chan, > + unsigned int mode) > +{ > + struct ad7192_state *st = iio_priv(indio_dev); > + int ret; > + > + st->syscalib_mode[chan->channel] = mode; > + > + if (mode == AD7192_SYSCALIB_ZERO_SCALE) > + ret = ad_sd_calibrate(&st->sd, AD7192_MODE_CAL_SYS_ZERO, > + chan->address); > + else > + ret = ad_sd_calibrate(&st->sd, AD7192_MODE_CAL_SYS_FULL, > + chan->address); > + > + return ret; > +} > + > +static int ad7192_get_syscalib_mode(struct iio_dev *indio_dev, > + const struct iio_chan_spec *chan) > +{ > + struct ad7192_state *st = iio_priv(indio_dev); > + > + return st->syscalib_mode[chan->channel]; > +} > + > +static const struct iio_enum ad7192_syscalib_mode_enum = { > + .items = ad7192_syscalib_modes, > + .num_items = ARRAY_SIZE(ad7192_syscalib_modes), > + .set = ad7192_set_syscalib_mode, > + .get = ad7192_get_syscalib_mode > +}; > + > +static const struct iio_chan_spec_ext_info ad7192_calibsys_ext_info[] = { > + IIO_ENUM("system_calibration", IIO_SEPARATE, &ad7192_syscalib_mode_enum), > + IIO_ENUM_AVAILABLE("system_calibration", &ad7192_syscalib_mode_enum), > + {} > +}; > + > static struct ad7192_state *ad_sigma_delta_to_ad7192(struct ad_sigma_delta *sd) > { > return container_of(sd, struct ad7192_state, sd); > @@ -769,9 +820,11 @@ static int ad7192_channels_config(struct iio_dev *indio_dev) > *chan = channels[i]; > chan->info_mask_shared_by_all |= > BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY); > - if (chan->type != IIO_TEMP) > + if (chan->type != IIO_TEMP) { > chan->info_mask_shared_by_type_available |= > BIT(IIO_CHAN_INFO_SCALE); > + chan->ext_info = ad7192_calibsys_ext_info; > + } > chan++; > } >