Commit 50ff457d authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Jonathan Cameron

iio: imu: st_lsm6dsx: add read_fifo callback to fifo_ops

Remove static qualifier from st_lsm6dsx_read_fifo definition and
introduce read_fifo function pointer in fifo_ops data structure
in order to run the proper read_fifo routine since other compliant
devices will use a different FIFO queueing scheme.
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent ff505930
...@@ -41,13 +41,17 @@ struct st_lsm6dsx_reg { ...@@ -41,13 +41,17 @@ struct st_lsm6dsx_reg {
u8 mask; u8 mask;
}; };
struct st_lsm6dsx_hw;
/** /**
* struct st_lsm6dsx_fifo_ops - ST IMU FIFO settings * struct st_lsm6dsx_fifo_ops - ST IMU FIFO settings
* @read_fifo: Read FIFO callback.
* @fifo_th: FIFO threshold register info (addr + mask). * @fifo_th: FIFO threshold register info (addr + mask).
* @fifo_diff: FIFO diff status register info (addr + mask). * @fifo_diff: FIFO diff status register info (addr + mask).
* @th_wl: FIFO threshold word length. * @th_wl: FIFO threshold word length.
*/ */
struct st_lsm6dsx_fifo_ops { struct st_lsm6dsx_fifo_ops {
int (*read_fifo)(struct st_lsm6dsx_hw *hw);
struct { struct {
u8 addr; u8 addr;
u16 mask; u16 mask;
...@@ -175,5 +179,6 @@ int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, ...@@ -175,5 +179,6 @@ int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor,
int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw); int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw);
int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
enum st_lsm6dsx_fifo_mode fifo_mode); enum st_lsm6dsx_fifo_mode fifo_mode);
int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw);
#endif /* ST_LSM6DSX_H */ #endif /* ST_LSM6DSX_H */
...@@ -283,7 +283,7 @@ static inline int st_lsm6dsx_read_block(struct st_lsm6dsx_hw *hw, u8 *data, ...@@ -283,7 +283,7 @@ static inline int st_lsm6dsx_read_block(struct st_lsm6dsx_hw *hw, u8 *data,
* *
* Return: Number of bytes read from the FIFO * Return: Number of bytes read from the FIFO
*/ */
static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)
{ {
u16 fifo_len, pattern_len = hw->sip * ST_LSM6DSX_SAMPLE_SIZE; u16 fifo_len, pattern_len = hw->sip * ST_LSM6DSX_SAMPLE_SIZE;
u16 fifo_diff_mask = hw->settings->fifo_ops.fifo_diff.mask; u16 fifo_diff_mask = hw->settings->fifo_ops.fifo_diff.mask;
...@@ -407,7 +407,7 @@ int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw) ...@@ -407,7 +407,7 @@ int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw)
mutex_lock(&hw->fifo_lock); mutex_lock(&hw->fifo_lock);
st_lsm6dsx_read_fifo(hw); hw->settings->fifo_ops.read_fifo(hw);
err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_BYPASS); err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_BYPASS);
mutex_unlock(&hw->fifo_lock); mutex_unlock(&hw->fifo_lock);
...@@ -479,7 +479,7 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) ...@@ -479,7 +479,7 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private)
int count; int count;
mutex_lock(&hw->fifo_lock); mutex_lock(&hw->fifo_lock);
count = st_lsm6dsx_read_fifo(hw); count = hw->settings->fifo_ops.read_fifo(hw);
mutex_unlock(&hw->fifo_lock); mutex_unlock(&hw->fifo_lock);
return !count ? IRQ_NONE : IRQ_HANDLED; return !count ? IRQ_NONE : IRQ_HANDLED;
......
...@@ -171,6 +171,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { ...@@ -171,6 +171,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
}, },
}, },
.fifo_ops = { .fifo_ops = {
.read_fifo = st_lsm6dsx_read_fifo,
.fifo_th = { .fifo_th = {
.addr = 0x06, .addr = 0x06,
.mask = GENMASK(11, 0), .mask = GENMASK(11, 0),
...@@ -217,6 +218,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { ...@@ -217,6 +218,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
}, },
}, },
.fifo_ops = { .fifo_ops = {
.read_fifo = st_lsm6dsx_read_fifo,
.fifo_th = { .fifo_th = {
.addr = 0x06, .addr = 0x06,
.mask = GENMASK(11, 0), .mask = GENMASK(11, 0),
...@@ -265,6 +267,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { ...@@ -265,6 +267,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
}, },
}, },
.fifo_ops = { .fifo_ops = {
.read_fifo = st_lsm6dsx_read_fifo,
.fifo_th = { .fifo_th = {
.addr = 0x06, .addr = 0x06,
.mask = GENMASK(10, 0), .mask = GENMASK(10, 0),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment