From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Crt Mori <cmo@melexis.com>, linux-iio <linux-iio@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 2/3] iio: temperature: mlx90632 Read sampling frequency
Date: Thu, 15 Sep 2022 15:09:18 +0100 [thread overview]
Message-ID: <20220915150918.6cdf7586@jic23-huawei> (raw)
In-Reply-To: <CAHp75VdF+Qe_QvKqchZPYM4E6oG0=kJcK-32H0hejyT8nJNhdw@mail.gmail.com>
On Tue, 6 Sep 2022 13:21:36 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Tue, Sep 6, 2022 at 12:04 PM <cmo@melexis.com> wrote:
> >
> > From: Crt Mori <cmo@melexis.com>
> >
> > Allow users to read sensor sampling frequency to better plan the
> > application measurement requests.
> >
> > Signed-off-by: Crt Mori <cmo@melexis.com>
> > ---
> > drivers/iio/temperature/mlx90632.c | 51 ++++++++++++++++++++++++++++++
> > 1 file changed, 51 insertions(+)
> >
> > diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c
> > index e41a18edbc65..6b33284eb0b6 100644
> > --- a/drivers/iio/temperature/mlx90632.c
> > +++ b/drivers/iio/temperature/mlx90632.c
> > @@ -81,6 +81,9 @@
> > #define MLX90632_PWR_STATUS_CONTINUOUS MLX90632_PWR_STATUS(3) /* continuous */
> >
> > #define MLX90632_EE_RR GENMASK(10, 8) /* Only Refresh Rate bits */
> > +#define MLX90632_REFRESH_RATE(ee_val) FIELD_GET(MLX90632_EE_RR, ee_val)
> > + /* Extract Refresh Rate from ee register */
> > +#define MLX90632_REFRESH_RATE_STATUS(refresh_rate) (refresh_rate << 8)
> >
> > /* Measurement types */
> > #define MLX90632_MTYP_MEDICAL 0
> > @@ -915,6 +918,24 @@ static int mlx90632_calc_ambient_dsp105(struct mlx90632_data *data, int *val)
> > return ret;
> > }
> >
> > +static int mlx90632_get_refresh_rate(struct mlx90632_data *data,
> > + int *refresh_rate)
> > +{
> > + unsigned int meas1;
> > + int ret;
> > +
> > + ret = regmap_read(data->regmap, MLX90632_EE_MEDICAL_MEAS1, &meas1);
> > + if (ret < 0)
> > + return ret;
> > +
> > + *refresh_rate = MLX90632_REFRESH_RATE(meas1);
> > +
> > + return ret;
> > +}
> > +
> > +static const int mlx90632_freqs[][2] = { {0, 500000}, {1, 0}, {2, 0}, {4, 0},
> > + {8, 0}, {16, 0}, {32, 0}, {64, 0} };
>
> I would indent this as
> _freqs ... = {
> ...pairs...
> };
>
As you are going around again, I agree with Andy on this.
Burn a few lines for better readability!
> Either way,
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
> > +
> > /**
> > * mlx90632_pm_interraction_wakeup() - Measure time between user interactions to change powermode
> > * @data: pointer to mlx90632_data object containing interaction_ts information
> > @@ -993,6 +1014,15 @@ static int mlx90632_read_raw(struct iio_dev *indio_dev,
> > *val = data->object_ambient_temperature;
> > ret = IIO_VAL_INT;
> > break;
> > + case IIO_CHAN_INFO_SAMP_FREQ:
> > + ret = mlx90632_get_refresh_rate(data, &cr);
> > + if (ret < 0)
> > + goto mlx90632_read_raw_pm;
> > +
> > + *val = mlx90632_freqs[cr][0];
> > + *val2 = mlx90632_freqs[cr][1];
> > + ret = IIO_VAL_INT_PLUS_MICRO;
> > + break;
> > default:
> > ret = -EINVAL;
> > break;
> > @@ -1026,12 +1056,30 @@ static int mlx90632_write_raw(struct iio_dev *indio_dev,
> > }
> > }
> >
> > +static int mlx90632_read_avail(struct iio_dev *indio_dev,
> > + struct iio_chan_spec const *chan,
> > + const int **vals, int *type, int *length,
> > + long mask)
> > +{
> > + switch (mask) {
> > + case IIO_CHAN_INFO_SAMP_FREQ:
> > + *vals = (int *)mlx90632_freqs;
> > + *type = IIO_VAL_INT_PLUS_MICRO;
> > + *length = 2 * ARRAY_SIZE(mlx90632_freqs);
> > + return IIO_AVAIL_LIST;
> > + default:
> > + return -EINVAL;
> > + }
> > +}
> > +
> > static const struct iio_chan_spec mlx90632_channels[] = {
> > {
> > .type = IIO_TEMP,
> > .modified = 1,
> > .channel2 = IIO_MOD_TEMP_AMBIENT,
> > .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
> > + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> > + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> > },
> > {
> > .type = IIO_TEMP,
> > @@ -1039,12 +1087,15 @@ static const struct iio_chan_spec mlx90632_channels[] = {
> > .channel2 = IIO_MOD_TEMP_OBJECT,
> > .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
> > BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) | BIT(IIO_CHAN_INFO_CALIBAMBIENT),
> > + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> > + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> > },
> > };
> >
> > static const struct iio_info mlx90632_info = {
> > .read_raw = mlx90632_read_raw,
> > .write_raw = mlx90632_write_raw,
> > + .read_avail = mlx90632_read_avail,
> > };
> >
> > static int mlx90632_sleep(struct mlx90632_data *data)
> > --
> > 2.34.1
> >
>
>
next prev parent reply other threads:[~2022-09-15 14:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-06 9:06 [PATCH v3 0/3] iio: temperature: mlx90632: Add powermanagement cmo
2022-09-06 9:04 ` [PATCH v3 1/3] iio: temperature: mlx90632 Add runtime powermanagement modes cmo
2022-09-06 10:20 ` Andy Shevchenko
2022-09-06 10:51 ` Crt Mori
2022-09-06 12:36 ` Andy Shevchenko
2022-09-06 13:04 ` Crt Mori
2022-09-06 13:16 ` Andy Shevchenko
2022-09-08 12:43 ` Jonathan Cameron
2022-09-15 14:07 ` Jonathan Cameron
2022-09-15 14:35 ` Crt Mori
2022-09-16 15:22 ` Jonathan Cameron
2022-09-06 9:04 ` [PATCH v3 2/3] iio: temperature: mlx90632 Read sampling frequency cmo
2022-09-06 10:21 ` Andy Shevchenko
2022-09-15 14:09 ` Jonathan Cameron [this message]
2022-09-06 9:04 ` [PATCH v3 3/3] iio: temperature: mlx90632 Change return value of sensor measurement channel cmo
2022-09-06 10:23 ` Andy Shevchenko
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=20220915150918.6cdf7586@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=cmo@melexis.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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