From: Jonathan Cameron <jic23@kernel.org>
To: Jagath Jog J <jagathjog1996@gmail.com>
Cc: dan@dlrobertson.com, andy.shevchenko@gmail.com,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/5] iio: accel: bma400: Add triggered buffer support
Date: Sun, 27 Mar 2022 17:45:45 +0100 [thread overview]
Message-ID: <20220327174545.41a15150@jic23-huawei> (raw)
In-Reply-To: <20220326194146.15549-4-jagathjog1996@gmail.com>
On Sun, 27 Mar 2022 01:11:44 +0530
Jagath Jog J <jagathjog1996@gmail.com> wrote:
> Added trigger buffer support to read continuous acceleration
> data from device with data ready interrupt which is mapped
> to INT1 pin.
>
> Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
Hi Jagath,
Just a few small things noticed on this read through.
Thanks,
Jonathan
> ---
> drivers/iio/accel/Kconfig | 2 +
> drivers/iio/accel/bma400.h | 10 +-
> drivers/iio/accel/bma400_core.c | 162 ++++++++++++++++++++++++++++++--
> drivers/iio/accel/bma400_i2c.c | 2 +-
> drivers/iio/accel/bma400_spi.c | 2 +-
> 5 files changed, 168 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
> index dc273381a0a2..fa3f4b5f229f 100644
> --- a/drivers/iio/accel/bma400_core.c
> +++ b/drivers/iio/accel/bma400_core.c
> @@ -11,16 +11,22 @@
> * - Create channel for sensor time
> */
>
> +#include <linux/bitfield.h>
> #include <linux/bitops.h>
> #include <linux/device.h>
> -#include <linux/iio/iio.h>
> -#include <linux/iio/sysfs.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/mutex.h>
> #include <linux/regmap.h>
> #include <linux/regulator/consumer.h>
>
> +#include <linux/iio/iio.h>
> +#include <linux/iio/sysfs.h>
Is iio/sysfs.h actually used? It rarely is these days as it contains
the infrastructure for custom attributes and we try not to use any
of those anymore.
> +#include <linux/iio/buffer.h>
> +#include <linux/iio/trigger.h>
> +#include <linux/iio/trigger_consumer.h>
> +#include <linux/iio/triggered_buffer.h>
> +
This reorganization of headers is good but shouldn't be in this patch.
Add an earlier patch in the series to move the existing pair down here
before this patch then adds the new ones.
...
>
> static int bma400_get_temp_reg(struct bma400_data *data, int *val, int *val2)
> @@ -659,6 +687,10 @@ static int bma400_init(struct bma400_data *data)
> if (ret)
> return ret;
>
> + /* Configure INT1 pin to open drain */
> + ret = regmap_write(data->regmap, BMA400_INT_IO_CTRL_REG, 0x06);
> + if (ret)
> + return ret;
> /*
> * Once the interrupt engine is supported we might use the
> * data_src_reg, but for now ensure this is set to the
> @@ -807,6 +839,33 @@ static int bma400_write_raw_get_fmt(struct iio_dev *indio_dev,
> }
> }
>
> +static int bma400_data_rdy_trigger_set_state(struct iio_trigger *trig,
> + bool state)
> +{
> + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
> + struct bma400_data *data = iio_priv(indio_dev);
> + int ret;
> +
> + ret = regmap_update_bits(data->regmap, BMA400_INT_CONFIG0_REG,
> + BMA400_INT_DRDY_MSK,
> + FIELD_PREP(BMA400_INT_DRDY_MSK, state));
> + if (ret)
> + return ret;
> +
> + ret = regmap_update_bits(data->regmap, BMA400_INT1_MAP_REG,
> + BMA400_INT_DRDY_MSK,
> + FIELD_PREP(BMA400_INT_DRDY_MSK, state));
> + if (ret)
> + return ret;
> +
> + return 0;
return regmap_update_bits()...
> +}
...
> +static irqreturn_t bma400_interrupt(int irq, void *private)
> +{
> + struct iio_dev *indio_dev = private;
> + struct bma400_data *data = iio_priv(indio_dev);
> + irqreturn_t ret = IRQ_NONE;
> + __le16 status;
> +
> + mutex_lock(&data->mutex);
> + ret = regmap_bulk_read(data->regmap, BMA400_INT_STAT0_REG, &status,
> + sizeof(status));
> + mutex_unlock(&data->mutex);
> + if (ret)
> + return IRQ_NONE;
> +
> + if (FIELD_GET(BMA400_INT_DRDY_MSK, le16_to_cpu(status))) {
> + iio_trigger_poll_chained(data->trig);
> + ret = IRQ_HANDLED;
Preference for this style
return IRQ_HANDLED;
> + }
> +
return IRQ_NONE;
and don't initialize above.
> + return ret;
> +}
> +
next prev parent reply other threads:[~2022-03-27 16:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-26 19:41 [PATCH v2 0/5] iio: accel: bma400: Add support for buffer and step Jagath Jog J
2022-03-26 19:41 ` [PATCH v2 1/5] iio: accel: bma400: Fix the scale min and max macro values Jagath Jog J
2022-03-27 16:31 ` Jonathan Cameron
2022-03-26 19:41 ` [PATCH v2 2/5] iio: accel: bma400: conversion to device-managed function Jagath Jog J
2022-03-27 16:35 ` Jonathan Cameron
2022-03-26 19:41 ` [PATCH v2 3/5] iio: accel: bma400: Add triggered buffer support Jagath Jog J
2022-03-27 16:45 ` Jonathan Cameron [this message]
2022-03-28 18:38 ` Jagath Jog J
2022-03-27 19:45 ` Andy Shevchenko
2022-03-28 17:02 ` Jonathan Cameron
2022-03-26 19:41 ` [PATCH v2 4/5] iio: accel: bma400: Add separate channel for step counter Jagath Jog J
2022-03-27 19:43 ` Andy Shevchenko
2022-03-26 19:41 ` [PATCH v2 5/5] iio: accel: bma400: Add step change event Jagath Jog J
2022-03-27 16:50 ` Jonathan Cameron
2022-03-28 20:37 ` Jagath Jog J
2022-04-02 16:37 ` Jonathan Cameron
2022-04-03 7:48 ` Jagath Jog J
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=20220327174545.41a15150@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=dan@dlrobertson.com \
--cc=jagathjog1996@gmail.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