mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 00:34:20 +08:00
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: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
ff50593026
commit
50ff457d1b
@ -41,13 +41,17 @@ struct st_lsm6dsx_reg {
|
||||
u8 mask;
|
||||
};
|
||||
|
||||
struct st_lsm6dsx_hw;
|
||||
|
||||
/**
|
||||
* struct st_lsm6dsx_fifo_ops - ST IMU FIFO settings
|
||||
* @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 (*read_fifo)(struct st_lsm6dsx_hw *hw);
|
||||
struct {
|
||||
u8 addr;
|
||||
u16 mask;
|
||||
@ -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_set_fifo_mode(struct st_lsm6dsx_hw *hw,
|
||||
enum st_lsm6dsx_fifo_mode fifo_mode);
|
||||
int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw);
|
||||
|
||||
#endif /* ST_LSM6DSX_H */
|
||||
|
@ -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
|
||||
*/
|
||||
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_diff_mask = hw->settings->fifo_ops.fifo_diff.mask;
|
||||
@ -407,7 +407,7 @@ int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw)
|
||||
|
||||
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);
|
||||
|
||||
mutex_unlock(&hw->fifo_lock);
|
||||
@ -479,7 +479,7 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private)
|
||||
int count;
|
||||
|
||||
mutex_lock(&hw->fifo_lock);
|
||||
count = st_lsm6dsx_read_fifo(hw);
|
||||
count = hw->settings->fifo_ops.read_fifo(hw);
|
||||
mutex_unlock(&hw->fifo_lock);
|
||||
|
||||
return !count ? IRQ_NONE : IRQ_HANDLED;
|
||||
|
@ -171,6 +171,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
|
||||
},
|
||||
},
|
||||
.fifo_ops = {
|
||||
.read_fifo = st_lsm6dsx_read_fifo,
|
||||
.fifo_th = {
|
||||
.addr = 0x06,
|
||||
.mask = GENMASK(11, 0),
|
||||
@ -217,6 +218,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
|
||||
},
|
||||
},
|
||||
.fifo_ops = {
|
||||
.read_fifo = st_lsm6dsx_read_fifo,
|
||||
.fifo_th = {
|
||||
.addr = 0x06,
|
||||
.mask = GENMASK(11, 0),
|
||||
@ -265,6 +267,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
|
||||
},
|
||||
},
|
||||
.fifo_ops = {
|
||||
.read_fifo = st_lsm6dsx_read_fifo,
|
||||
.fifo_th = {
|
||||
.addr = 0x06,
|
||||
.mask = GENMASK(10, 0),
|
||||
|
Loading…
Reference in New Issue
Block a user