From: Jonathan Cameron <jic23@kernel.org>
To: Angel Iglesias <ang.iglesiasg@gmail.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
Paul Cercueil <paul@crapouillou.net>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] iio: pressure: bmp280: Adds more tunable config parameters for BMP380
Date: Sat, 16 Jul 2022 17:05:40 +0100 [thread overview]
Message-ID: <20220716170540.0d767e2f@jic23-huawei> (raw)
In-Reply-To: <5f47527553a3e191e8e458401c1ad9abddd598dc.camel@gmail.com>
On Mon, 27 Jun 2022 18:10:48 +0200
Angel Iglesias <ang.iglesiasg@gmail.com> wrote:
> On dom, 2022-06-26 at 15:39 +0100, Jonathan Cameron wrote:
> > On Sat, 25 Jun 2022 17:10:36 +0200
> > Angel Iglesias <ang.iglesiasg@gmail.com> wrote:
> >
> > > Allows to configure the IIR filter coefficient and the sampling
> > > frequency
> > > The IIR filter coefficient is exposed using the sysfs attribute
> > > "filter_low_pass_3db_frequency"
> > >
> > > Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com>
> > Hi Angel
> >
> > A few comments inline,
> > > ---
>
> > > + *val2 = data->chip_info->sampling_freq_avail[data-
> > > >sampling_freq][1];
> > > + ret = IIO_VAL_INT_PLUS_MICRO;
> > > + break;
> > > + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
> > > + *val = data->chip_info-
> > > >iir_filter_coeffs_avail[data->iir_filter_coeff];
> > > + ret = IIO_VAL_INT;
> > > + break;
> > > default:
> > > ret = -EINVAL;
> > > break;
> > > @@ -577,6 +647,39 @@ static int
> > > bmp280_write_oversampling_ratio_press(struct bmp280_data *data,
> > > return -EINVAL;
> > > }
> > >
> > > +static int bmp280_write_sampling_frequency(struct bmp280_data
> > > *data,
> > > + int val, int val2)
> > > +{
> > > + int i;
> > > + const int (*avail)[2] = data->chip_info-
> > > >sampling_freq_avail;
> > > + const int n = data->chip_info->num_sampling_freq_avail;
> > > +
> > > + for (i = 0; i < n; i++) {
> > > + if (avail[i][0] == val && avail[i][1] == val2) {
> > > + data->sampling_freq = i;
> > better to only set the cached value if the write succeeds.
> >
> > e.g.
> > ret = data->chip_info->chip_config(data);
> > if (ret)
> > return ret;
> >
> > data->sampling_freq = i;
> >
> > return 0;
>
> Ok! Should I restore the previous value in case of failure?
The condition is pretty much unknowable, so normally we just assume
failure means it didn't write.
prev parent reply other threads:[~2022-07-16 15:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-25 15:10 [PATCH 3/3] iio: pressure: bmp280: Adds more tunable config parameters for BMP380 Angel Iglesias
2022-06-26 14:39 ` Jonathan Cameron
2022-06-27 16:10 ` Angel Iglesias
2022-07-16 16:05 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220716170540.0d767e2f@jic23-huawei \
--to=jic23@kernel.org \
--cc=ang.iglesiasg@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@crapouillou.net \
--cc=rafael.j.wysocki@intel.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox