diff mbox series

iio: imu: bmi270: fix initial sampling frequency configuration

Message ID 20250304-bmi270-odr-fix-v1-1-384dbcd699fb@gmail.com (mailing list archive)
State Accepted
Headers show
Series iio: imu: bmi270: fix initial sampling frequency configuration | expand

Commit Message

Gustavo Silva March 4, 2025, 6:01 p.m. UTC
In the bmi270_configure_imu() function, the accelerometer and gyroscope
configuration registers are incorrectly written with the mask
BMI270_PWR_CONF_ADV_PWR_SAVE_MSK, which is unrelated to these registers.

As a result, the accelerometer's sampling frequency is set to 200 Hz
instead of the intended 100 Hz.

Remove the mask to ensure the correct bits are set in the configuration
registers.

Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>
---
 drivers/iio/imu/bmi270/bmi270_core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)


---
base-commit: 8cca9edca867350e5f8dc65b71e7a6ef4157981e
change-id: 20250304-bmi270-odr-fix-620e7f8daa7a

Best regards,

Comments

Alex Lanzano March 5, 2025, 4:25 a.m. UTC | #1
On Tue, Mar 04, 2025 at 03:01:02PM -0300, Gustavo Silva wrote:
> In the bmi270_configure_imu() function, the accelerometer and gyroscope
> configuration registers are incorrectly written with the mask
> BMI270_PWR_CONF_ADV_PWR_SAVE_MSK, which is unrelated to these registers.
> 
> As a result, the accelerometer's sampling frequency is set to 200 Hz
> instead of the intended 100 Hz.
> 
> Remove the mask to ensure the correct bits are set in the configuration
> registers.
> 
> Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>
> ---
>  drivers/iio/imu/bmi270/bmi270_core.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/imu/bmi270/bmi270_core.c b/drivers/iio/imu/bmi270/bmi270_core.c
> index a86be5af5ccb1f010f2282ee31c47f284c1bcc86..2e4469f30d538ca3e9eb9ef8bbc6eaa8b6a144b8 100644
> --- a/drivers/iio/imu/bmi270/bmi270_core.c
> +++ b/drivers/iio/imu/bmi270/bmi270_core.c
> @@ -918,8 +918,7 @@ static int bmi270_configure_imu(struct bmi270_data *data)
>  			      FIELD_PREP(BMI270_ACC_CONF_ODR_MSK,
>  					 BMI270_ACC_CONF_ODR_100HZ) |
>  			      FIELD_PREP(BMI270_ACC_CONF_BWP_MSK,
> -					 BMI270_ACC_CONF_BWP_NORMAL_MODE) |
> -			      BMI270_PWR_CONF_ADV_PWR_SAVE_MSK);
> +					 BMI270_ACC_CONF_BWP_NORMAL_MODE));
>  	if (ret)
>  		return dev_err_probe(dev, ret, "Failed to configure accelerometer");
>  
> @@ -927,8 +926,7 @@ static int bmi270_configure_imu(struct bmi270_data *data)
>  			      FIELD_PREP(BMI270_GYR_CONF_ODR_MSK,
>  					 BMI270_GYR_CONF_ODR_200HZ) |
>  			      FIELD_PREP(BMI270_GYR_CONF_BWP_MSK,
> -					 BMI270_GYR_CONF_BWP_NORMAL_MODE) |
> -			      BMI270_PWR_CONF_ADV_PWR_SAVE_MSK);
> +					 BMI270_GYR_CONF_BWP_NORMAL_MODE));
>  	if (ret)
>  		return dev_err_probe(dev, ret, "Failed to configure gyroscope");
>  
> 
> ---
> base-commit: 8cca9edca867350e5f8dc65b71e7a6ef4157981e
> change-id: 20250304-bmi270-odr-fix-620e7f8daa7a
> 

Good catch!

Reviewed-by: Alex Lanzano <lanzano.alex@gmail.com>
Jonathan Cameron March 5, 2025, 2:49 p.m. UTC | #2
On Tue, 04 Mar 2025 15:01:02 -0300
Gustavo Silva <gustavograzs@gmail.com> wrote:

> In the bmi270_configure_imu() function, the accelerometer and gyroscope
> configuration registers are incorrectly written with the mask
> BMI270_PWR_CONF_ADV_PWR_SAVE_MSK, which is unrelated to these registers.
> 
> As a result, the accelerometer's sampling frequency is set to 200 Hz
> instead of the intended 100 Hz.
> 
> Remove the mask to ensure the correct bits are set in the configuration
> registers.
> 
> Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>

Hi Gustavo,

Please reply to this thread with a suitable fixes tag.

Thanks,

Jonathan


> ---
>  drivers/iio/imu/bmi270/bmi270_core.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/imu/bmi270/bmi270_core.c b/drivers/iio/imu/bmi270/bmi270_core.c
> index a86be5af5ccb1f010f2282ee31c47f284c1bcc86..2e4469f30d538ca3e9eb9ef8bbc6eaa8b6a144b8 100644
> --- a/drivers/iio/imu/bmi270/bmi270_core.c
> +++ b/drivers/iio/imu/bmi270/bmi270_core.c
> @@ -918,8 +918,7 @@ static int bmi270_configure_imu(struct bmi270_data *data)
>  			      FIELD_PREP(BMI270_ACC_CONF_ODR_MSK,
>  					 BMI270_ACC_CONF_ODR_100HZ) |
>  			      FIELD_PREP(BMI270_ACC_CONF_BWP_MSK,
> -					 BMI270_ACC_CONF_BWP_NORMAL_MODE) |
> -			      BMI270_PWR_CONF_ADV_PWR_SAVE_MSK);
> +					 BMI270_ACC_CONF_BWP_NORMAL_MODE));
>  	if (ret)
>  		return dev_err_probe(dev, ret, "Failed to configure accelerometer");
>  
> @@ -927,8 +926,7 @@ static int bmi270_configure_imu(struct bmi270_data *data)
>  			      FIELD_PREP(BMI270_GYR_CONF_ODR_MSK,
>  					 BMI270_GYR_CONF_ODR_200HZ) |
>  			      FIELD_PREP(BMI270_GYR_CONF_BWP_MSK,
> -					 BMI270_GYR_CONF_BWP_NORMAL_MODE) |
> -			      BMI270_PWR_CONF_ADV_PWR_SAVE_MSK);
> +					 BMI270_GYR_CONF_BWP_NORMAL_MODE));
>  	if (ret)
>  		return dev_err_probe(dev, ret, "Failed to configure gyroscope");
>  
> 
> ---
> base-commit: 8cca9edca867350e5f8dc65b71e7a6ef4157981e
> change-id: 20250304-bmi270-odr-fix-620e7f8daa7a
> 
> Best regards,
Gustavo Silva March 6, 2025, 12:11 a.m. UTC | #3
On Wed, Mar 05, 2025 at 02:49:28PM +0000, Jonathan Cameron wrote:
> On Tue, 04 Mar 2025 15:01:02 -0300
> Gustavo Silva <gustavograzs@gmail.com> wrote:
> 
> > In the bmi270_configure_imu() function, the accelerometer and gyroscope
> > configuration registers are incorrectly written with the mask
> > BMI270_PWR_CONF_ADV_PWR_SAVE_MSK, which is unrelated to these registers.
> > 
> > As a result, the accelerometer's sampling frequency is set to 200 Hz
> > instead of the intended 100 Hz.
> > 
> > Remove the mask to ensure the correct bits are set in the configuration
> > registers.
> > 
> > Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>
> 
> Hi Gustavo,
> 
> Please reply to this thread with a suitable fixes tag.
> 
> Thanks,
> 
> Jonathan
> 

Fixes: 3ea51548d6b2 ("iio: imu: Add i2c driver for bmi270 imu")
Jonathan Cameron March 8, 2025, 2:55 p.m. UTC | #4
On Wed, 5 Mar 2025 21:11:54 -0300
Gustavo Silva <gustavograzs@gmail.com> wrote:

> On Wed, Mar 05, 2025 at 02:49:28PM +0000, Jonathan Cameron wrote:
> > On Tue, 04 Mar 2025 15:01:02 -0300
> > Gustavo Silva <gustavograzs@gmail.com> wrote:
> >   
> > > In the bmi270_configure_imu() function, the accelerometer and gyroscope
> > > configuration registers are incorrectly written with the mask
> > > BMI270_PWR_CONF_ADV_PWR_SAVE_MSK, which is unrelated to these registers.
> > > 
> > > As a result, the accelerometer's sampling frequency is set to 200 Hz
> > > instead of the intended 100 Hz.
> > > 
> > > Remove the mask to ensure the correct bits are set in the configuration
> > > registers.
> > > 
> > > Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>  
> > 
> > Hi Gustavo,
> > 
> > Please reply to this thread with a suitable fixes tag.
> > 
> > Thanks,
> > 
> > Jonathan
> >   
> 
> Fixes: 3ea51548d6b2 ("iio: imu: Add i2c driver for bmi270 imu")

Thanks. Applied to the fixes-togreg branch of iio.git.
Given where we are in the cycle I might just drag this into the pull
request for the next merge window.

Jonathan
diff mbox series

Patch

diff --git a/drivers/iio/imu/bmi270/bmi270_core.c b/drivers/iio/imu/bmi270/bmi270_core.c
index a86be5af5ccb1f010f2282ee31c47f284c1bcc86..2e4469f30d538ca3e9eb9ef8bbc6eaa8b6a144b8 100644
--- a/drivers/iio/imu/bmi270/bmi270_core.c
+++ b/drivers/iio/imu/bmi270/bmi270_core.c
@@ -918,8 +918,7 @@  static int bmi270_configure_imu(struct bmi270_data *data)
 			      FIELD_PREP(BMI270_ACC_CONF_ODR_MSK,
 					 BMI270_ACC_CONF_ODR_100HZ) |
 			      FIELD_PREP(BMI270_ACC_CONF_BWP_MSK,
-					 BMI270_ACC_CONF_BWP_NORMAL_MODE) |
-			      BMI270_PWR_CONF_ADV_PWR_SAVE_MSK);
+					 BMI270_ACC_CONF_BWP_NORMAL_MODE));
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to configure accelerometer");
 
@@ -927,8 +926,7 @@  static int bmi270_configure_imu(struct bmi270_data *data)
 			      FIELD_PREP(BMI270_GYR_CONF_ODR_MSK,
 					 BMI270_GYR_CONF_ODR_200HZ) |
 			      FIELD_PREP(BMI270_GYR_CONF_BWP_MSK,
-					 BMI270_GYR_CONF_BWP_NORMAL_MODE) |
-			      BMI270_PWR_CONF_ADV_PWR_SAVE_MSK);
+					 BMI270_GYR_CONF_BWP_NORMAL_MODE));
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to configure gyroscope");