From: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
To: Antoni Pokusinski <apokusinski01@gmail.com>
Cc: jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
andy@kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] iio: mpl3115: add threshold events support
Date: Thu, 6 Nov 2025 22:55:01 -0300 [thread overview]
Message-ID: <aQ1Rdcbi3e8lzOvM@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <20251105095615.4310-3-apokusinski01@gmail.com>
Hi Antoni,
v3 looks mostly good to me.
A couple of minor suggestions in addition to Andy's.
On 11/05, Antoni Pokusinski wrote:
> Add support for pressure and temperature rising threshold events. For
> both channels *_en and *_value (in raw units) attributes are exposed.
>
> Since in write_event_config() the ctrl_reg1.active and ctrl_reg4
> are modified, accessing the data->ctrl_reg{1,4} in set_trigger_state()
> and write_event_config() needs to be now guarded by data->lock.
> Otherwise, it would be possible that 2 concurrent threads executing
> these functions would access the data->ctrl_reg{1,4} at the same time
> and then one would overwrite the other's result.
>
> Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com>
> ---
...
> +
> +static int mpl3115_write_thresh(struct iio_dev *indio_dev,
> + const struct iio_chan_spec *chan,
> + enum iio_event_type type,
> + enum iio_event_direction dir,
> + enum iio_event_info info,
> + int val, int val2)
> +{
> + struct mpl3115_data *data = iio_priv(indio_dev);
> + __be16 tmp;
> +
> + if (info != IIO_EV_INFO_VALUE)
> + return -EINVAL;
> +
> + switch (chan->type) {
> + case IIO_PRESSURE:
> + val >>= 1;
> +
> + if (val < 0 || val > U16_MAX)
Alternatively, could use in_range() for the check.
> + return -EINVAL;
> +
> + tmp = cpu_to_be16(val);
> +
> + return i2c_smbus_write_i2c_block_data(data->client,
> + MPL3115_PRESS_TGT,
> + sizeof(tmp), (u8 *)&tmp);
> + case IIO_TEMP:
> + if (val < S8_MIN || val > S8_MAX)
this could also use in_range().
If you opt for the macro,
#include <linux/minmax.h>
> + return -EINVAL;
> +
> + return i2c_smbus_write_byte_data(data->client,
> + MPL3115_TEMP_TGT, val);
> + default:
> + return -EINVAL;
> + }
> +}
> +
next prev parent reply other threads:[~2025-11-07 1:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-05 9:56 [PATCH v3 0/3] iio: mpl3115: support for events Antoni Pokusinski
2025-11-05 9:56 ` [PATCH v3 1/3] iio: mpl3115: use get_unaligned_be24 to retrieve pressure data Antoni Pokusinski
2025-11-05 15:20 ` Andy Shevchenko
2025-11-07 1:33 ` Marcelo Schmitt
2025-11-09 16:38 ` Jonathan Cameron
2025-11-10 15:59 ` Antoni Pokusinski
2025-11-11 19:47 ` Jonathan Cameron
2025-11-05 9:56 ` [PATCH v3 2/3] iio: mpl3115: add threshold events support Antoni Pokusinski
2025-11-05 15:25 ` Andy Shevchenko
2025-11-06 20:28 ` Antoni Pokusinski
2025-11-07 1:55 ` Marcelo Schmitt [this message]
2025-11-07 22:01 ` Antoni Pokusinski
2025-11-08 19:05 ` Marcelo Schmitt
2025-11-09 16:02 ` Andy Shevchenko
2025-11-05 9:56 ` [PATCH v3 3/3] iio: ABI: document pressure event attributes Antoni Pokusinski
2025-11-07 2:32 ` Marcelo Schmitt
2025-11-07 9:26 ` Antoni Pokusinski
2025-11-09 16:43 ` Jonathan Cameron
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=aQ1Rdcbi3e8lzOvM@debian-BULLSEYE-live-builder-AMD64 \
--to=marcelo.schmitt1@gmail.com \
--cc=andy@kernel.org \
--cc=apokusinski01@gmail.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/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