]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
iio: imu: st_lsm6dsx: introduce update_fifo function pointer
authorLorenzo Bianconi <lorenzo@kernel.org>
Wed, 21 Aug 2019 13:25:17 +0000 (15:25 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 26 Aug 2019 07:52:03 +0000 (08:52 +0100)
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>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c

index 4e8e67ae16323008f7fcea190519eb00ef86c1bf..055e52dec36aa3c637a81467afd306e26bb700f5 100644 (file)
@@ -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);
index 2c03a5b80f80c72d32e9923ea4d9113d93803e5b..b0f3da1976e4f46949c2f23e097707989a9aea93 100644 (file)
@@ -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 = {
index 85824d6739eefb59a62901ce4d82a70c6a044e81..0aa93b45d772c4b208428207d5307f0945e3a6a0 100644 (file)
@@ -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,