Re: [PATCH v2 4/6] iio: chemical: ens160: add triggered buffer support
From: Jonathan Cameron
Date: Sun Jun 02 2024 - 07:27:54 EST
On Tue, 28 May 2024 21:14:21 -0300
Gustavo Silva <gustavograzs@xxxxxxxxx> wrote:
> ENS160 supports a data ready interrupt. Use it in combination with
> triggered buffer for continuous data readings.
>
> Signed-off-by: Gustavo Silva <gustavograzs@xxxxxxxxx>
A couple of really minor comments inline.
Thanks,
Jonathan
> #endif
> diff --git a/drivers/iio/chemical/ens160_core.c b/drivers/iio/chemical/ens160_core.c
> index a535f62c4..74ef7f150 100644
> --- a/drivers/iio/chemical/ens160_core.c
> +++ b/drivers/iio/chemical/ens160_core.c
> @@ -10,6 +10,9 @@
>
> #include <linux/bitfield.h>
> #include <linux/iio/iio.h>
> +#include <linux/iio/trigger.h>
> +#include <linux/iio/trigger_consumer.h>
> +#include <linux/iio/triggered_buffer.h>
> #include <linux/module.h>
> #include <linux/regmap.h>
>
> @@ -19,9 +22,14 @@
>
> #define ENS160_BOOTING_TIME_MS 10U
>
> -#define ENS160_REG_PART_ID 0x00
move this in earlier patch so no need to realign here.
> +#define ENS160_REG_PART_ID 0x00
>
> -#define ENS160_REG_OPMODE 0x10
> +#define ENS160_REG_OPMODE 0x10
> +
> +#define ENS160_REG_CONFIG 0x11
> +#define ENS160_REG_CONFIG_INTEN BIT(0)
> +#define ENS160_REG_CONFIG_INTDAT BIT(1)
> +#define ENS160_REG_CONFIG_INT_CFG BIT(5)
>
> #define ENS160_REG_MODE_DEEP_SLEEP 0x00
> #define ENS160_REG_MODE_IDLE 0x01
> @@ -48,7 +56,12 @@
>
> struct ens160_data {
> struct regmap *regmap;
> - u8 fw_version[3] __aligned(IIO_DMA_MINALIGN);
> + struct mutex mutex;
Mutex needs a comment to say what data it is protecting.
> + struct {
> + __le16 chans[2];
> + s64 timestamp __aligned(8);
> + } scan __aligned(IIO_DMA_MINALIGN);
> + u8 fw_version[3];
> __le16 buf;
> };