diff mbox

[1/4] iio: imu: st_lsm6dsx: convert max_fifo_size in fifo words

Message ID 20170927192928.16160-2-lorenzo.bianconi@st.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lorenzo Bianconi Sept. 27, 2017, 7:29 p.m. UTC
Express max fifo depth in fifo words instead of in bytes.
That change will be necessary to properly support more devices
in st_lsm6dsx driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Jonathan Cameron Oct. 1, 2017, 10:40 a.m. UTC | #1
On Wed, 27 Sep 2017 21:29:25 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:

> Express max fifo depth in fifo words instead of in bytes.
> That change will be necessary to properly support more devices
> in st_lsm6dsx driver
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>

I'm not sure the term words really applies here.  Fifo entries maybe?
We are talking about a set of sample I think?

Other than terminology the patch is fine.

Jonathan

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index debf4064f474..e6e0363cd1c2 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -156,21 +156,21 @@ static const struct st_lsm6dsx_fs_table_entry st_lsm6dsx_fs_table[] = {
>  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>  	{
>  		.wai = 0x69,
> -		.max_fifo_size = 8192,
> +		.max_fifo_size = 1365,
>  		.id = {
>  			[0] = ST_LSM6DS3_ID,
>  		},
>  	},
>  	{
>  		.wai = 0x69,
> -		.max_fifo_size = 4096,
> +		.max_fifo_size = 682,
>  		.id = {
>  			[0] = ST_LSM6DS3H_ID,
>  		},
>  	},
>  	{
>  		.wai = 0x6a,
> -		.max_fifo_size = 4096,
> +		.max_fifo_size = 682,
>  		.id = {
>  			[0] = ST_LSM6DSL_ID,
>  			[1] = ST_LSM6DSM_ID,
> @@ -462,10 +462,9 @@ static int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
>  {
>  	struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
>  	struct st_lsm6dsx_hw *hw = sensor->hw;
> -	int err, max_fifo_len;
> +	int err;
>  
> -	max_fifo_len = hw->settings->max_fifo_size / ST_LSM6DSX_SAMPLE_SIZE;
> -	if (val < 1 || val > max_fifo_len)
> +	if (val < 1 || val > hw->settings->max_fifo_size)
>  		return -EINVAL;
>  
>  	err = st_lsm6dsx_update_watermark(sensor, val);

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lorenzo Bianconi Oct. 1, 2017, 1:05 p.m. UTC | #2
> On Wed, 27 Sep 2017 21:29:25 +0200
> Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
>
>> Express max fifo depth in fifo words instead of in bytes.
>> That change will be necessary to properly support more devices
>> in st_lsm6dsx driver
>>
>> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
>
> I'm not sure the term words really applies here.  Fifo entries maybe?
> We are talking about a set of sample I think?
>
> Other than terminology the patch is fine.
>

Yes, we are talking about a set of FIFO samples. For LSM6DS3,
LSM6DS3H, LSM6DSL and LSM6DSM we have at least 6B stored in FIFO (e.g:
Acc_x, Acc_y, Acc_z or Gyro_x, Gyro_y, Gyro_z).
I will modify commit log in v2.

Regards,
Lorenzo

> Jonathan
>
>> ---
>>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
>> index debf4064f474..e6e0363cd1c2 100644
>> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
>> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
>> @@ -156,21 +156,21 @@ static const struct st_lsm6dsx_fs_table_entry st_lsm6dsx_fs_table[] = {
>>  static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>>       {
>>               .wai = 0x69,
>> -             .max_fifo_size = 8192,
>> +             .max_fifo_size = 1365,
>>               .id = {
>>                       [0] = ST_LSM6DS3_ID,
>>               },
>>       },
>>       {
>>               .wai = 0x69,
>> -             .max_fifo_size = 4096,
>> +             .max_fifo_size = 682,
>>               .id = {
>>                       [0] = ST_LSM6DS3H_ID,
>>               },
>>       },
>>       {
>>               .wai = 0x6a,
>> -             .max_fifo_size = 4096,
>> +             .max_fifo_size = 682,
>>               .id = {
>>                       [0] = ST_LSM6DSL_ID,
>>                       [1] = ST_LSM6DSM_ID,
>> @@ -462,10 +462,9 @@ static int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
>>  {
>>       struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
>>       struct st_lsm6dsx_hw *hw = sensor->hw;
>> -     int err, max_fifo_len;
>> +     int err;
>>
>> -     max_fifo_len = hw->settings->max_fifo_size / ST_LSM6DSX_SAMPLE_SIZE;
>> -     if (val < 1 || val > max_fifo_len)
>> +     if (val < 1 || val > hw->settings->max_fifo_size)
>>               return -EINVAL;
>>
>>       err = st_lsm6dsx_update_watermark(sensor, val);
>
diff mbox

Patch

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index debf4064f474..e6e0363cd1c2 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -156,21 +156,21 @@  static const struct st_lsm6dsx_fs_table_entry st_lsm6dsx_fs_table[] = {
 static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 	{
 		.wai = 0x69,
-		.max_fifo_size = 8192,
+		.max_fifo_size = 1365,
 		.id = {
 			[0] = ST_LSM6DS3_ID,
 		},
 	},
 	{
 		.wai = 0x69,
-		.max_fifo_size = 4096,
+		.max_fifo_size = 682,
 		.id = {
 			[0] = ST_LSM6DS3H_ID,
 		},
 	},
 	{
 		.wai = 0x6a,
-		.max_fifo_size = 4096,
+		.max_fifo_size = 682,
 		.id = {
 			[0] = ST_LSM6DSL_ID,
 			[1] = ST_LSM6DSM_ID,
@@ -462,10 +462,9 @@  static int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
 {
 	struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
 	struct st_lsm6dsx_hw *hw = sensor->hw;
-	int err, max_fifo_len;
+	int err;
 
-	max_fifo_len = hw->settings->max_fifo_size / ST_LSM6DSX_SAMPLE_SIZE;
-	if (val < 1 || val > max_fifo_len)
+	if (val < 1 || val > hw->settings->max_fifo_size)
 		return -EINVAL;
 
 	err = st_lsm6dsx_update_watermark(sensor, val);