From: Jonathan Cameron <jic23@kernel.org>
To: Martin Kepplinger <martin.kepplinger@puri.sm>
Cc: lorenzo.bianconi83@gmail.com, knaack.h@gmx.de, lars@metafoo.de,
pmeerw@pmeerw.net, robh+dt@kernel.org, mark.rutland@arm.com,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Lorenzo Bianconi <lorenzo@kernel.org>
Subject: Re: [PATCH v5 1/4] iio: imu: st_lsm6dsx: introduce update_fifo function pointer
Date: Mon, 26 Aug 2019 09:10:52 +0100 [thread overview]
Message-ID: <20190826091052.771e96c6@archlinux> (raw)
In-Reply-To: <20190821132520.28225-2-martin.kepplinger@puri.sm>
On Wed, 21 Aug 2019 15:25:17 +0200
Martin Kepplinger <martin.kepplinger@puri.sm> wrote:
> From: Lorenzo Bianconi <lorenzo@kernel.org>
>
> Introduce update_fifo routine pointer in st_lsm6dsx_fifo_ops data
> structure since we will need a different update FIFO configuration
> callback adding support for lsm6ds0/lsm9ds1 imu device
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 4 ++++
> .../iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 19 +++++++++++++++----
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 6 ++++++
> 3 files changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index 4e8e67ae1632..055e52dec36a 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -75,6 +75,7 @@ struct st_lsm6dsx_reg {
> u8 mask;
> };
>
> +struct st_lsm6dsx_sensor;
> struct st_lsm6dsx_hw;
>
> struct st_lsm6dsx_odr {
> @@ -101,12 +102,14 @@ struct st_lsm6dsx_fs_table_entry {
>
> /**
> * struct st_lsm6dsx_fifo_ops - ST IMU FIFO settings
> + * @update_fifo: Update FIFO configuration callback.
> * @read_fifo: Read FIFO callback.
> * @fifo_th: FIFO threshold register info (addr + mask).
> * @fifo_diff: FIFO diff status register info (addr + mask).
> * @th_wl: FIFO threshold word length.
> */
> struct st_lsm6dsx_fifo_ops {
> + int (*update_fifo)(struct st_lsm6dsx_sensor *sensor, bool enable);
> int (*read_fifo)(struct st_lsm6dsx_hw *hw);
> struct {
> u8 addr;
> @@ -327,6 +330,7 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw);
> int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val);
> int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor,
> u16 watermark);
> +int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable);
> int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw);
> int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
> enum st_lsm6dsx_fifo_mode fifo_mode);
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> index 2c03a5b80f80..b0f3da1976e4 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> @@ -602,9 +602,8 @@ int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw)
> return err;
> }
>
> -static int st_lsm6dsx_update_fifo(struct iio_dev *iio_dev, bool enable)
> +int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable)
> {
> - struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
> struct st_lsm6dsx_hw *hw = sensor->hw;
> int err;
>
> @@ -676,12 +675,24 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private)
>
> static int st_lsm6dsx_buffer_preenable(struct iio_dev *iio_dev)
> {
> - return st_lsm6dsx_update_fifo(iio_dev, true);
> + struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
> + struct st_lsm6dsx_hw *hw = sensor->hw;
> +
> + if (!hw->settings->fifo_ops.update_fifo)
> + return -ENOTSUPP;
> +
> + return hw->settings->fifo_ops.update_fifo(sensor, true);
> }
>
> static int st_lsm6dsx_buffer_postdisable(struct iio_dev *iio_dev)
> {
> - return st_lsm6dsx_update_fifo(iio_dev, false);
> + struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
> + struct st_lsm6dsx_hw *hw = sensor->hw;
> +
> + if (!hw->settings->fifo_ops.update_fifo)
> + return -ENOTSUPP;
> +
> + return hw->settings->fifo_ops.update_fifo(sensor, false);
> }
>
> static const struct iio_buffer_setup_ops st_lsm6dsx_buffer_ops = {
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 85824d6739ee..0aa93b45d772 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -154,6 +154,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> },
> },
> .fifo_ops = {
> + .update_fifo = st_lsm6dsx_update_fifo,
> .read_fifo = st_lsm6dsx_read_fifo,
> .fifo_th = {
> .addr = 0x06,
> @@ -262,6 +263,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> },
> },
> .fifo_ops = {
> + .update_fifo = st_lsm6dsx_update_fifo,
> .read_fifo = st_lsm6dsx_read_fifo,
> .fifo_th = {
> .addr = 0x06,
> @@ -379,6 +381,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> },
> },
> .fifo_ops = {
> + .update_fifo = st_lsm6dsx_update_fifo,
> .read_fifo = st_lsm6dsx_read_fifo,
> .fifo_th = {
> .addr = 0x06,
> @@ -490,6 +493,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> },
> },
> .fifo_ops = {
> + .update_fifo = st_lsm6dsx_update_fifo,
> .read_fifo = st_lsm6dsx_read_tagged_fifo,
> .fifo_th = {
> .addr = 0x07,
> @@ -616,6 +620,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> },
> },
> .fifo_ops = {
> + .update_fifo = st_lsm6dsx_update_fifo,
> .read_fifo = st_lsm6dsx_read_tagged_fifo,
> .fifo_th = {
> .addr = 0x07,
> @@ -719,6 +724,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> },
> },
> .fifo_ops = {
> + .update_fifo = st_lsm6dsx_update_fifo,
> .read_fifo = st_lsm6dsx_read_tagged_fifo,
> .fifo_th = {
> .addr = 0x07,
next prev parent reply other threads:[~2019-08-27 19:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-21 13:25 [PATCH v5 0/4] iio: imu: st_lsm6dsx: Add support for LSM9DS1 Martin Kepplinger
2019-08-21 13:25 ` [PATCH v5 1/4] iio: imu: st_lsm6dsx: introduce update_fifo function pointer Martin Kepplinger
2019-08-26 8:10 ` Jonathan Cameron [this message]
2019-08-21 13:25 ` [PATCH v5 2/4] iio: imu: st_lsm6sdx: move register definitions to sensor_settings struct Martin Kepplinger
2019-08-26 8:11 ` Jonathan Cameron
2019-08-27 6:54 ` Martin Kepplinger
2019-08-27 19:59 ` Jonathan Cameron
2019-08-21 13:25 ` [PATCH v5 3/4] iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9sd1 Martin Kepplinger
2019-08-26 8:13 ` Jonathan Cameron
2019-08-21 13:25 ` [PATCH v5 4/4] dt-bindings: iio: imu: st_lsm6dsx: add lsm9ds1 device bindings Martin Kepplinger
2019-08-26 8:10 ` Jonathan Cameron
2019-08-27 17:25 ` Rob Herring
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=20190826091052.771e96c6@archlinux \
--to=jic23@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.bianconi83@gmail.com \
--cc=lorenzo@kernel.org \
--cc=mark.rutland@arm.com \
--cc=martin.kepplinger@puri.sm \
--cc=pmeerw@pmeerw.net \
--cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).