Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2637938pxk; Sun, 6 Sep 2020 07:53:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGNfPzVjV46qoMe1Soubeh//VHPwZ827Q8uu5c97rNsezicHm6z6nEObRI90ml1HvBLXaf X-Received: by 2002:a17:906:2962:: with SMTP id x2mr2962077ejd.188.1599404019594; Sun, 06 Sep 2020 07:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599404019; cv=none; d=google.com; s=arc-20160816; b=mG9h9wjEqdMphztT/fpeDV926mUGNlqwt7W/+WsUDQzmFHlpXJgcfmPlvO8M9/Qxn0 GpVzNYywm6I2GUyBJqfgwyxMoAppsjd1st2nJnvIiOFqyYxVKqziiOvf1fsIkrFXlD97 /Xu3XBnDN2/RNXl5ZX0vqphMsrznq6O8IJKhq1D0LzrqEtcTQoHniXoXzNcpuaHtDYK9 fFjJnDWsz6+PffBCF0Fb7mmQCv2qPIO0W/LMpwE0D0SGUxylAES3CPMYjCXz8F7dm4bw Y+SNEwby1QUqoBIaX1/F/LTjxOppngRKFMvKfGcQokkrgJFDIQ+czM7geb0/qoV+9MGr W8ew== 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=NOjRdXOOhNI41pye3A1o7jCcNiprTWN4C6rmGOyfaCM=; b=EBlLwbfCfWBbN66b3CKSrv6c6FNCPJxD2ODug5Y07TAO61tzTjMFPUkGy64Y4zGw3o SK8v+6nDf9EM1PlXMoZICyCZCobbDn3I6JDovi8NKfNsV7BH09ofXFmmW5uhRYo6DuJB QaKooO9qaDuDkHWl7eFslADJ8dNkjczVhTe8AkhTIAFjvuR/134QFBHRu42Ga/Yj5AB7 ca0wqSXZzVeDgnyzB0gCMh68YXoe9lT/wAAsnGpObHS8s8Y+78GMQbMCAUnWZIS93q6C Hv/cb2e8KkIlzwfRz7wPeNuvCmZHSo7KNQhuWwz2QYYcsL4W/eDniaL8o+5Uwe3qj50g fwvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2RoUnMqJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id u18si7965754edy.380.2020.09.06.07.53.15; Sun, 06 Sep 2020 07:53:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2RoUnMqJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728763AbgIFOwA (ORCPT + 99 others); Sun, 6 Sep 2020 10:52:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:37522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726931AbgIFOvx (ORCPT ); Sun, 6 Sep 2020 10:51:53 -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 4F5D220714; Sun, 6 Sep 2020 14:51:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599403912; bh=InP0l+FKFxfUCyzLZPZhSXwYzVMvc8E5Css3wMf7MiQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=2RoUnMqJdrlR/rDJgefMAFqd9x+FvxOBqm6wLoDt6Ve43N3hEQe2FaZiO+03bCUK+ R/iAwNLbrTzGkKn9fa2Lu3rBX6A3rqdyrPV066JwCc3Qe7TljrIRxIEQHorCQ7c3Dg wakt2VULUbs5+Q4xVs6CXlg+J+PFBbGf7wf2zgWQ= Date: Sun, 6 Sep 2020 15:51:47 +0100 From: Jonathan Cameron To: Nishant Malpani Cc: Rob Herring , "Bogdan, Dragos" , Darius , Linux Kernel Mailing List , linux-iio , devicetree Subject: Re: [PATCH 1/3] iio: gyro: adxrs290: Add triggered buffer support Message-ID: <20200906155147.662f5df9@archlinux> In-Reply-To: References: <20200825124711.11455-1-nish.malpani25@gmail.com> <20200825124711.11455-2-nish.malpani25@gmail.com> <20200829174623.422f7e7d@archlinux> X-Mailer: Claws Mail 3.17.6 (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 Thu, 3 Sep 2020 18:07:00 +0530 Nishant Malpani wrote: > Hello, > > Thanks for the review, Jonathan. Comments inline... > ... > > > > > > +static void adxrs290_chip_off_action(void *data) > > > +{ > > > + struct iio_dev *indio_dev = data; > > > + > > > + adxrs290_set_mode(indio_dev, ADXRS290_MODE_STANDBY); > > > +} > > > + > > > static int adxrs290_read_raw(struct iio_dev *indio_dev, > > > struct iio_chan_spec const *chan, > > > int *val, > > > @@ -215,24 +287,34 @@ static int adxrs290_read_raw(struct iio_dev *indio_dev, > > > > > > switch (mask) { > > > case IIO_CHAN_INFO_RAW: > > > + ret = iio_device_claim_direct_mode(indio_dev); > > > + if (ret) > > > + return ret; > > > + > > > switch (chan->type) { > > > case IIO_ANGL_VEL: > > > ret = adxrs290_get_rate_data(indio_dev, > > > ADXRS290_READ_REG(chan->address), > > > val); > > > if (ret < 0) > > > - return ret; > > > + goto err_release; > > > > > > - return IIO_VAL_INT; > > > + ret = IIO_VAL_INT; > > > + break; > > > case IIO_TEMP: > > > ret = adxrs290_get_temp_data(indio_dev, val); > > > if (ret < 0) > > > - return ret; > > > + goto err_release; > > > > > > - return IIO_VAL_INT; > > > + ret = IIO_VAL_INT; > > > + break; > > > default: > > > - return -EINVAL; > > > + ret = -EINVAL; > > > + break; > > > } > > > +err_release: > > > + iio_device_release_direct_mode(indio_dev); > > > + return ret; > > > case IIO_CHAN_INFO_SCALE: > > > switch (chan->type) { > > > case IIO_ANGL_VEL: > > > @@ -279,34 +361,53 @@ static int adxrs290_write_raw(struct iio_dev *indio_dev, > > > long mask) > > > { > > > struct adxrs290_state *st = iio_priv(indio_dev); > > > - int lpf_idx, hpf_idx; > > > + int ret, lpf_idx, hpf_idx; > > > + > > > + ret = iio_device_claim_direct_mode(indio_dev); > > > > Is there anything in the datasheet that says we can't change the filters > > whilst doing captures? Might get crazy data but if the datasheet doesn't > > want against a particular action, then we tend not to try and prevent it. > > > > The datasheet, to my knowledge, explicitly doesn't mention any > restriction on changing the filter settings during a capture. > > Quoting the datasheet, "The group delay of the wideband filter option > is less than 0.5ms" (pg. 11) - during an ongoing capture if one > re-configures the filter, how do we address this? To be honest, I'm not really sure what that means, so will if you think it makes sense it is fine to keep protections to not allow a filter update during buffered capture. > > > > + if (ret) > > > + return ret; ... > > > static int adxrs290_probe(struct spi_device *spi) > > > { > > > struct iio_dev *indio_dev; > > > @@ -384,6 +609,7 @@ static int adxrs290_probe(struct spi_device *spi) > > > indio_dev->channels = adxrs290_channels; > > > indio_dev->num_channels = ARRAY_SIZE(adxrs290_channels); > > > indio_dev->info = &adxrs290_info; > > > + indio_dev->available_scan_masks = adxrs290_avail_scan_masks; > > > > > > mutex_init(&st->lock); > > > > > > @@ -416,6 +642,12 @@ static int adxrs290_probe(struct spi_device *spi) > > > /* max transition time to measurement mode */ > > > msleep(ADXRS290_MAX_TRANSITION_TIME_MS); > > > > > > + ret = devm_add_action_or_reset(&spi->dev, > > > + adxrs290_chip_off_action, > > > + indio_dev); > > > > What is this unwinding? We should only be using devm to undo things > > that have been 'done' in probe and the association should be clear. > > > > This unwinding is for placing the device **back** to its default > 'STANDBY' mode. The device, during the probe, was put to 'MEASUREMENT' > mode during 'adxrs290_initial_setup()' a few lines back. > > How else do you suggest I highlight the association? Perhaps put it inside the call to initial_setup() so it is clearly paired with the 'forwards' action. Jonathan