Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp941588imm; Fri, 3 Aug 2018 14:34:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdsHBKWaAYJohXBBYJ8AUJew+/OA9ZzJeoX0VPoIP1rmJyepLpiV4k4fZovSjPy2AglRzqI X-Received: by 2002:a17:902:bc49:: with SMTP id t9-v6mr5074936plz.116.1533332040787; Fri, 03 Aug 2018 14:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533332040; cv=none; d=google.com; s=arc-20160816; b=FfaVIYTVFxRaHIYCmPodFzdPGY0admx5AC5riZ+LO8zNqSwjqaKxui12YrXZFeV+nv sKkxF0hrVwvrYF+06G+Wy7+6KrCLV2xWlzE/F+b7vB0ZwscLgD7mZgL7XMwyhsKbcxDn iVlcxQzdcl2QYpoPs/jlw+L+BZ33+jjddUTtCp9N5VW3Hw5RGxxdh8ED6993kJr6XkvM M63Dn5Drhpa0Zcn3w2kcklcq0r7EXAEwrGiEb646Rn3dP9dJzWSybBzhmKmWm0JDipAu jKE0XDx1tYWSC+X1oULQ4Q7GqIOxByJKg7RycDz8hz0KQVZMoNLXX0D4gcNDxZ5lDFEJ sAYg== 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:arc-authentication-results; bh=/sp4oHtE944qeF4b0EUypk2qoPD8DKf/RJBsECJovsQ=; b=YX8b8kUBaVjmV5THI8HikPKquK1INjebJXEys5MEU/hzG5hJ2MnvGtKFWpkONFoutL wAu8yC6Kz/AORckOQke4d/lJdJONvtPwhgACqkmPDvFxg0tURwAajiFTwH8xE8LTjpnz HwFxvEc04Ng1DNjry3pJ8yAXejWBrwhd33j++BdG74dyEZcYU55CDwpSFzXA8itytIZZ wiB4DEZXq40nWSTX9pGvMZhonv0g9r6mnaaEONjJ8scNtbfO3DWBMdeuidjjAU3NOH0C oBUiPf+RS9E6GlpMpwrZXY29gNbAZHPyQJFKg8kYOh2MxFRbc3EU+qNHzv8g6i224rCw L1tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jVCvSE2w; 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 b205-v6si6337707pfb.358.2018.08.03.14.33.46; Fri, 03 Aug 2018 14:34:00 -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=jVCvSE2w; 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 S1732168AbeHCXam (ORCPT + 99 others); Fri, 3 Aug 2018 19:30:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:34070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729985AbeHCXam (ORCPT ); Fri, 3 Aug 2018 19:30:42 -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 6F65F2178D; Fri, 3 Aug 2018 21:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533331959; bh=RGOyEGl8Tncs+hrkmz1YrlcjRs/qwRp4IOWikHw8ZUA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jVCvSE2wNRlA8tEnyZ0Px7ZMiq6jg8pufr2BzKxGTwDX0nYMgMKFp7BK84sz28FlG Q6Mmsw0BYg11b75Pu6ilDx4ikPjuu6a7TDiUkK/8GWasqqaMyve3K6hqsIyxA0tvqf Ijycv9m0N5lWPnIUd40hqbiYOaUgLVu53zXnH6rI= Date: Fri, 3 Aug 2018 22:32:33 +0100 From: Jonathan Cameron To: Stefan Popa Cc: , , , , , , , , , , , , , Subject: Re: [PATCH v3 6/6] iio:adxl372: Add filter bandwidth support Message-ID: <20180803223233.13641247@archlinux> In-Reply-To: <1533301341-26560-7-git-send-email-stefan.popa@analog.com> References: <1533301341-26560-1-git-send-email-stefan.popa@analog.com> <1533301341-26560-7-git-send-email-stefan.popa@analog.com> 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=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 Fri, 3 Aug 2018 16:02:21 +0300 Stefan Popa wrote: > This patch adds the option for the user to select the filter bandwidth. The > user can also read the available bandwidths which are always adjusted to be > at most half of the sampling frequency. Furthermore, the currently selected > bandwidth can be read via the read_raw function, while the write_raw sets a > new bandwidth value. > > Signed-off-by: Stefan Popa Another good one. Same comment as previous :) Jonathan > --- > drivers/iio/accel/adxl372.c | 38 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 36 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c > index 80b1838..3a9d55a 100644 > --- a/drivers/iio/accel/adxl372.c > +++ b/drivers/iio/accel/adxl372.c > @@ -196,6 +196,10 @@ static const int adxl372_samp_freq_tbl[5] = { > 400, 800, 1600, 3200, 6400, > }; > > +static const int adxl372_bw_freq_tbl[5] = { > + 200, 400, 800, 1600, 3200, > +}; > + > struct adxl372_axis_lookup { > unsigned int bits; > enum adxl372_fifo_format fifo_format; > @@ -218,7 +222,8 @@ static const struct adxl372_axis_lookup adxl372_axis_lookup_table[] = { > .channel2 = IIO_MOD_##axis, \ > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ > - BIT(IIO_CHAN_INFO_SAMP_FREQ), \ > + BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ > + BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \ > .scan_index = index, \ > .scan_type = { \ > .sign = 's', \ > @@ -656,6 +661,9 @@ static int adxl372_read_raw(struct iio_dev *indio_dev, > case IIO_CHAN_INFO_SAMP_FREQ: > *val = adxl372_samp_freq_tbl[st->odr]; > return IIO_VAL_INT; > + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: > + *val = adxl372_bw_freq_tbl[st->bw]; > + return IIO_VAL_INT; > } > > return -EINVAL; > @@ -666,7 +674,7 @@ static int adxl372_write_raw(struct iio_dev *indio_dev, > int val, int val2, long info) > { > struct adxl372_state *st = iio_priv(indio_dev); > - int odr_index, ret; > + int odr_index, bw_index, ret; > > switch (info) { > case IIO_CHAN_INFO_SAMP_FREQ: > @@ -698,11 +706,34 @@ static int adxl372_write_raw(struct iio_dev *indio_dev, > ret = adxl372_set_bandwidth(st, odr_index); > > return ret; > + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: > + bw_index = adxl372_find_closest_match(adxl372_bw_freq_tbl, > + ARRAY_SIZE(adxl372_bw_freq_tbl), > + val); > + return adxl372_set_bandwidth(st, bw_index); > default: > return -EINVAL; > } > } > > +static ssize_t adxl372_show_filter_freq_avail(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct iio_dev *indio_dev = dev_to_iio_dev(dev); > + struct adxl372_state *st = iio_priv(indio_dev); > + int i; > + size_t len = 0; > + > + for (i = 0; i <= st->odr; i++) > + len += scnprintf(buf + len, PAGE_SIZE - len, > + "%d ", adxl372_bw_freq_tbl[i]); > + > + buf[len - 1] = '\n'; > + > + return len; > +} > + > static ssize_t adxl372_get_fifo_enabled(struct device *dev, > struct device_attribute *attr, > char *buf) > @@ -826,9 +857,12 @@ static const struct iio_trigger_ops adxl372_trigger_ops = { > }; > > static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("400 800 1600 3200 6400"); > +static IIO_DEVICE_ATTR(in_accel_filter_low_pass_3db_frequency_available, > + 0444, adxl372_show_filter_freq_avail, NULL, 0); > > static struct attribute *adxl372_attributes[] = { > &iio_const_attr_sampling_frequency_available.dev_attr.attr, > + &iio_dev_attr_in_accel_filter_low_pass_3db_frequency_available.dev_attr.attr, > NULL, > }; >