diff mbox series

iio: imu: st_lsm6dsx: move max_fifo_size in st_lsm6dsx_fifo_ops

Message ID b2981cb9a00784a84fec0ea62183629216ec3b38.1632388011.git.lorenzo@kernel.org (mailing list archive)
State Changes Requested
Headers show
Series iio: imu: st_lsm6dsx: move max_fifo_size in st_lsm6dsx_fifo_ops | expand

Commit Message

Lorenzo Bianconi Sept. 23, 2021, 9:08 a.m. UTC
This patch does not introduce any logic change, just small code
rearrangement.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  4 ++--
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 16 +++++++++-------
 2 files changed, 11 insertions(+), 9 deletions(-)

Comments

Jonathan Cameron Sept. 26, 2021, 11:59 a.m. UTC | #1
On Thu, 23 Sep 2021 11:08:24 +0200
Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> This patch does not introduce any logic change, just small code
> rearrangement.
Hi Lorenzo, 

Why?  I can make an educated guess that it is to put all the fifo related stuff
in one place, but you probably need to state that in the patch description.

Thanks,

Jonathan

> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  4 ++--
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 16 +++++++++-------
>  2 files changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index 5ef55763a6cc..6ac4eac36458 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -143,6 +143,7 @@ struct st_lsm6dsx_fs_table_entry {
>   * @read_fifo: Read FIFO callback.
>   * @fifo_th: FIFO threshold register info (addr + mask).
>   * @fifo_diff: FIFO diff status register info (addr + mask).
> + * @max_size: Sensor max fifo length in FIFO words.
>   * @th_wl: FIFO threshold word length.
>   */
>  struct st_lsm6dsx_fifo_ops {
> @@ -156,6 +157,7 @@ struct st_lsm6dsx_fifo_ops {
>  		u8 addr;
>  		u16 mask;
>  	} fifo_diff;
> +	u16 max_size;
>  	u8 th_wl;
>  };
>  
> @@ -271,7 +273,6 @@ struct st_lsm6dsx_ext_dev_settings {
>   * @reset: register address for reset.
>   * @boot: register address for boot.
>   * @bdu: register address for Block Data Update.
> - * @max_fifo_size: Sensor max fifo length in FIFO words.
>   * @id: List of hw id/device name supported by the driver configuration.
>   * @channels: IIO channels supported by the device.
>   * @irq_config: interrupts related registers.
> @@ -288,7 +289,6 @@ struct st_lsm6dsx_settings {
>  	struct st_lsm6dsx_reg reset;
>  	struct st_lsm6dsx_reg boot;
>  	struct st_lsm6dsx_reg bdu;
> -	u16 max_fifo_size;
>  	struct {
>  		enum st_lsm6dsx_hw_id hw_id;
>  		const char *name;
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index db45f1fc0b81..0f54df85134a 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -102,7 +102,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  			.addr = 0x22,
>  			.mask = BIT(6),
>  		},
> -		.max_fifo_size = 32,
>  		.id = {
>  			{
>  				.hw_id = ST_LSM9DS1_ID,
> @@ -194,6 +193,9 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  				.mask = BIT(4),
>  			},
>  		},
> +		.fifo_ops = {
> +			.max_size = 32,
> +		},
>  	},
>  	{
>  		.reset = {
> @@ -208,7 +210,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  			.addr = 0x12,
>  			.mask = BIT(6),
>  		},
> -		.max_fifo_size = 1365,
>  		.id = {
>  			{
>  				.hw_id = ST_LSM6DS3_ID,
> @@ -329,6 +330,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  				.addr = 0x3a,
>  				.mask = GENMASK(11, 0),
>  			},
> +			.max_size = 1365,
>  			.th_wl = 3, /* 1LSB = 2B */
>  		},
>  		.ts_settings = {
> @@ -374,7 +376,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  			.addr = 0x12,
>  			.mask = BIT(6),
>  		},
> -		.max_fifo_size = 682,
>  		.id = {
>  			{
>  				.hw_id = ST_LSM6DS3H_ID,
> @@ -495,6 +496,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  				.addr = 0x3a,
>  				.mask = GENMASK(11, 0),
>  			},
> +			.max_size = 682,
>  			.th_wl = 3, /* 1LSB = 2B */
>  		},
>  		.ts_settings = {
> @@ -540,7 +542,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  			.addr = 0x12,
>  			.mask = BIT(6),
>  		},
> -		.max_fifo_size = 682,
>  		.id = {
>  			{
>  				.hw_id = ST_LSM6DSL_ID,
> @@ -677,6 +678,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  				.addr = 0x3a,
>  				.mask = GENMASK(10, 0),
>  			},
> +			.max_size = 682,
>  			.th_wl = 3, /* 1LSB = 2B */
>  		},
>  		.ts_settings = {
> @@ -759,7 +761,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  			.addr = 0x12,
>  			.mask = BIT(6),
>  		},
> -		.max_fifo_size = 512,
>  		.id = {
>  			{
>  				.hw_id = ST_LSM6DSR_ID,
> @@ -910,6 +911,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  				.addr = 0x3a,
>  				.mask = GENMASK(9, 0),
>  			},
> +			.max_size = 512,
>  			.th_wl = 1,
>  		},
>  		.ts_settings = {
> @@ -984,7 +986,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  			.addr = 0x12,
>  			.mask = BIT(6),
>  		},
> -		.max_fifo_size = 512,
>  		.id = {
>  			{
>  				.hw_id = ST_ASM330LHH_ID,
> @@ -1119,6 +1120,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  				.addr = 0x3a,
>  				.mask = GENMASK(9, 0),
>  			},
> +			.max_size = 512,
>  			.th_wl = 1,
>  		},
>  		.ts_settings = {
> @@ -1603,7 +1605,7 @@ int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
>  	struct st_lsm6dsx_hw *hw = sensor->hw;
>  	int err;
>  
> -	if (val < 1 || val > hw->settings->max_fifo_size)
> +	if (val < 1 || val > hw->settings->fifo_ops.max_size)
>  		return -EINVAL;
>  
>  	mutex_lock(&hw->conf_lock);
Lorenzo Bianconi Sept. 26, 2021, 12:58 p.m. UTC | #2
> On Thu, 23 Sep 2021 11:08:24 +0200
> Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> 
> > This patch does not introduce any logic change, just small code
> > rearrangement.
> Hi Lorenzo, 
> 
> Why?  I can make an educated guess that it is to put all the fifo related stuff
> in one place, but you probably need to state that in the patch description.

yes, it seems to me it is logically correct to have fifo configuration in
fifo_ops. I will post v2 adding this in the commit log.

Regards,
Lorenzo

> 
> Thanks,
> 
> Jonathan
> 
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> >  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  4 ++--
> >  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 16 +++++++++-------
> >  2 files changed, 11 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > index 5ef55763a6cc..6ac4eac36458 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > @@ -143,6 +143,7 @@ struct st_lsm6dsx_fs_table_entry {
> >   * @read_fifo: Read FIFO callback.
> >   * @fifo_th: FIFO threshold register info (addr + mask).
> >   * @fifo_diff: FIFO diff status register info (addr + mask).
> > + * @max_size: Sensor max fifo length in FIFO words.
> >   * @th_wl: FIFO threshold word length.
> >   */
> >  struct st_lsm6dsx_fifo_ops {
> > @@ -156,6 +157,7 @@ struct st_lsm6dsx_fifo_ops {
> >  		u8 addr;
> >  		u16 mask;
> >  	} fifo_diff;
> > +	u16 max_size;
> >  	u8 th_wl;
> >  };
> >  
> > @@ -271,7 +273,6 @@ struct st_lsm6dsx_ext_dev_settings {
> >   * @reset: register address for reset.
> >   * @boot: register address for boot.
> >   * @bdu: register address for Block Data Update.
> > - * @max_fifo_size: Sensor max fifo length in FIFO words.
> >   * @id: List of hw id/device name supported by the driver configuration.
> >   * @channels: IIO channels supported by the device.
> >   * @irq_config: interrupts related registers.
> > @@ -288,7 +289,6 @@ struct st_lsm6dsx_settings {
> >  	struct st_lsm6dsx_reg reset;
> >  	struct st_lsm6dsx_reg boot;
> >  	struct st_lsm6dsx_reg bdu;
> > -	u16 max_fifo_size;
> >  	struct {
> >  		enum st_lsm6dsx_hw_id hw_id;
> >  		const char *name;
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > index db45f1fc0b81..0f54df85134a 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > @@ -102,7 +102,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >  			.addr = 0x22,
> >  			.mask = BIT(6),
> >  		},
> > -		.max_fifo_size = 32,
> >  		.id = {
> >  			{
> >  				.hw_id = ST_LSM9DS1_ID,
> > @@ -194,6 +193,9 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >  				.mask = BIT(4),
> >  			},
> >  		},
> > +		.fifo_ops = {
> > +			.max_size = 32,
> > +		},
> >  	},
> >  	{
> >  		.reset = {
> > @@ -208,7 +210,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >  			.addr = 0x12,
> >  			.mask = BIT(6),
> >  		},
> > -		.max_fifo_size = 1365,
> >  		.id = {
> >  			{
> >  				.hw_id = ST_LSM6DS3_ID,
> > @@ -329,6 +330,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >  				.addr = 0x3a,
> >  				.mask = GENMASK(11, 0),
> >  			},
> > +			.max_size = 1365,
> >  			.th_wl = 3, /* 1LSB = 2B */
> >  		},
> >  		.ts_settings = {
> > @@ -374,7 +376,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >  			.addr = 0x12,
> >  			.mask = BIT(6),
> >  		},
> > -		.max_fifo_size = 682,
> >  		.id = {
> >  			{
> >  				.hw_id = ST_LSM6DS3H_ID,
> > @@ -495,6 +496,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >  				.addr = 0x3a,
> >  				.mask = GENMASK(11, 0),
> >  			},
> > +			.max_size = 682,
> >  			.th_wl = 3, /* 1LSB = 2B */
> >  		},
> >  		.ts_settings = {
> > @@ -540,7 +542,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >  			.addr = 0x12,
> >  			.mask = BIT(6),
> >  		},
> > -		.max_fifo_size = 682,
> >  		.id = {
> >  			{
> >  				.hw_id = ST_LSM6DSL_ID,
> > @@ -677,6 +678,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >  				.addr = 0x3a,
> >  				.mask = GENMASK(10, 0),
> >  			},
> > +			.max_size = 682,
> >  			.th_wl = 3, /* 1LSB = 2B */
> >  		},
> >  		.ts_settings = {
> > @@ -759,7 +761,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >  			.addr = 0x12,
> >  			.mask = BIT(6),
> >  		},
> > -		.max_fifo_size = 512,
> >  		.id = {
> >  			{
> >  				.hw_id = ST_LSM6DSR_ID,
> > @@ -910,6 +911,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >  				.addr = 0x3a,
> >  				.mask = GENMASK(9, 0),
> >  			},
> > +			.max_size = 512,
> >  			.th_wl = 1,
> >  		},
> >  		.ts_settings = {
> > @@ -984,7 +986,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >  			.addr = 0x12,
> >  			.mask = BIT(6),
> >  		},
> > -		.max_fifo_size = 512,
> >  		.id = {
> >  			{
> >  				.hw_id = ST_ASM330LHH_ID,
> > @@ -1119,6 +1120,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >  				.addr = 0x3a,
> >  				.mask = GENMASK(9, 0),
> >  			},
> > +			.max_size = 512,
> >  			.th_wl = 1,
> >  		},
> >  		.ts_settings = {
> > @@ -1603,7 +1605,7 @@ int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
> >  	struct st_lsm6dsx_hw *hw = sensor->hw;
> >  	int err;
> >  
> > -	if (val < 1 || val > hw->settings->max_fifo_size)
> > +	if (val < 1 || val > hw->settings->fifo_ops.max_size)
> >  		return -EINVAL;
> >  
> >  	mutex_lock(&hw->conf_lock);
>
diff mbox series

Patch

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index 5ef55763a6cc..6ac4eac36458 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -143,6 +143,7 @@  struct st_lsm6dsx_fs_table_entry {
  * @read_fifo: Read FIFO callback.
  * @fifo_th: FIFO threshold register info (addr + mask).
  * @fifo_diff: FIFO diff status register info (addr + mask).
+ * @max_size: Sensor max fifo length in FIFO words.
  * @th_wl: FIFO threshold word length.
  */
 struct st_lsm6dsx_fifo_ops {
@@ -156,6 +157,7 @@  struct st_lsm6dsx_fifo_ops {
 		u8 addr;
 		u16 mask;
 	} fifo_diff;
+	u16 max_size;
 	u8 th_wl;
 };
 
@@ -271,7 +273,6 @@  struct st_lsm6dsx_ext_dev_settings {
  * @reset: register address for reset.
  * @boot: register address for boot.
  * @bdu: register address for Block Data Update.
- * @max_fifo_size: Sensor max fifo length in FIFO words.
  * @id: List of hw id/device name supported by the driver configuration.
  * @channels: IIO channels supported by the device.
  * @irq_config: interrupts related registers.
@@ -288,7 +289,6 @@  struct st_lsm6dsx_settings {
 	struct st_lsm6dsx_reg reset;
 	struct st_lsm6dsx_reg boot;
 	struct st_lsm6dsx_reg bdu;
-	u16 max_fifo_size;
 	struct {
 		enum st_lsm6dsx_hw_id hw_id;
 		const char *name;
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index db45f1fc0b81..0f54df85134a 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -102,7 +102,6 @@  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 			.addr = 0x22,
 			.mask = BIT(6),
 		},
-		.max_fifo_size = 32,
 		.id = {
 			{
 				.hw_id = ST_LSM9DS1_ID,
@@ -194,6 +193,9 @@  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 				.mask = BIT(4),
 			},
 		},
+		.fifo_ops = {
+			.max_size = 32,
+		},
 	},
 	{
 		.reset = {
@@ -208,7 +210,6 @@  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 			.addr = 0x12,
 			.mask = BIT(6),
 		},
-		.max_fifo_size = 1365,
 		.id = {
 			{
 				.hw_id = ST_LSM6DS3_ID,
@@ -329,6 +330,7 @@  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 				.addr = 0x3a,
 				.mask = GENMASK(11, 0),
 			},
+			.max_size = 1365,
 			.th_wl = 3, /* 1LSB = 2B */
 		},
 		.ts_settings = {
@@ -374,7 +376,6 @@  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 			.addr = 0x12,
 			.mask = BIT(6),
 		},
-		.max_fifo_size = 682,
 		.id = {
 			{
 				.hw_id = ST_LSM6DS3H_ID,
@@ -495,6 +496,7 @@  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 				.addr = 0x3a,
 				.mask = GENMASK(11, 0),
 			},
+			.max_size = 682,
 			.th_wl = 3, /* 1LSB = 2B */
 		},
 		.ts_settings = {
@@ -540,7 +542,6 @@  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 			.addr = 0x12,
 			.mask = BIT(6),
 		},
-		.max_fifo_size = 682,
 		.id = {
 			{
 				.hw_id = ST_LSM6DSL_ID,
@@ -677,6 +678,7 @@  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 				.addr = 0x3a,
 				.mask = GENMASK(10, 0),
 			},
+			.max_size = 682,
 			.th_wl = 3, /* 1LSB = 2B */
 		},
 		.ts_settings = {
@@ -759,7 +761,6 @@  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 			.addr = 0x12,
 			.mask = BIT(6),
 		},
-		.max_fifo_size = 512,
 		.id = {
 			{
 				.hw_id = ST_LSM6DSR_ID,
@@ -910,6 +911,7 @@  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 				.addr = 0x3a,
 				.mask = GENMASK(9, 0),
 			},
+			.max_size = 512,
 			.th_wl = 1,
 		},
 		.ts_settings = {
@@ -984,7 +986,6 @@  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 			.addr = 0x12,
 			.mask = BIT(6),
 		},
-		.max_fifo_size = 512,
 		.id = {
 			{
 				.hw_id = ST_ASM330LHH_ID,
@@ -1119,6 +1120,7 @@  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 				.addr = 0x3a,
 				.mask = GENMASK(9, 0),
 			},
+			.max_size = 512,
 			.th_wl = 1,
 		},
 		.ts_settings = {
@@ -1603,7 +1605,7 @@  int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
 	struct st_lsm6dsx_hw *hw = sensor->hw;
 	int err;
 
-	if (val < 1 || val > hw->settings->max_fifo_size)
+	if (val < 1 || val > hw->settings->fifo_ops.max_size)
 		return -EINVAL;
 
 	mutex_lock(&hw->conf_lock);