iio: imu: fxos8700: few bug fix for fxos8700
PATCH 1/1 iio: imu: fxos8700: few bug fix for fxos8700
From: Haibo Chen <[email protected]>
1, z raw data always 0, regmap_buk_read use the wrong length. fix it and optmize read the only need data.
2, use the correct register address when try to read raw data. 3, before set scale, need to set the sensor to standby mode. otherwise the scale set is not work.
4, give the correct offset when config odr bit.
--- drivers/iio/imu/fxos8700_core.c | 66 +++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 19 deletions(-)
drivers/iio/imu/fxos8700_core.c +47 -19
@@ -162,12 +162,11 @@#define FXOS8700_DEVICE_ID 0xC7#define FXOS8700_PRE_DEVICE_ID 0xC4 -#define FXOS8700_DATA_BUF_SIZE 3struct fxos8700_data {struct regmap *regmap;struct iio_trigger *trig; -__be16 buf[FXOS8700_DATA_BUF_SIZE ]____cacheline_aligned ; +__be16 buf____cacheline_aligned ; };/* Regmap info */
@@ -345,7 +344,8 @@ static int fxos8700_set_active_mode(struct fxos8700_data *data,static int fxos8700_set_scale (struct fxos8700_data *data,enum fxos8700_sensor t,int uscale) { -int i; +int i, ret, val; +bool active_mode;static const int scale_num =ARRAY_SIZE (fxos8700_accel_scale);struct device *dev =regmap_get_device (data->regmap);
@@ -354,6 +354,23 @@ static int fxos8700_set_scale(struct fxos8700_data *data,return -EINVAL ; } + ret =regmap_read (data->regmap,FXOS8700_CTRL_REG1 , &val); +if (ret) +return ret; + + active_mode = val &FXOS8700_ACTIVE ; + +if (active_mode) { +/* +* The device must be in standby mode to change any of the +* other fields within CTRL_REG1 +*/ + ret =regmap_write (data->regmap,FXOS8700_CTRL_REG1 , + val & ~FXOS8700_ACTIVE ); +if (ret) +return ret; + } +for (i =0 ; i < scale_num; i++)if (fxos8700_accel_scale[i].uscale == uscale)break ;
@@ -361,8 +378,12 @@ static int fxos8700_set_scale(struct fxos8700_data *data,if (i == scale_num)return -EINVAL ; -return regmap_write (data->regmap,FXOS8700_XYZ_DATA_CFG , + ret =regmap_write (data->regmap,FXOS8700_XYZ_DATA_CFG , fxos8700_accel_scale[i].bits); +if (ret) +return ret; +return regmap_update_bits (data->regmap,FXOS8700_CTRL_REG1 , +FXOS8700_ACTIVE , active_mode); } static int fxos8700_get_scale(struct fxos8700_data *data,
@@ -393,23 +414,29 @@ static int fxos8700_get_scale(struct fxos8700_data *data,static int fxos8700_get_data (struct fxos8700_data *data,int chan_type,int axis,int *val) { -u8 base, reg; -int ret; +u8 base, offset;enum fxos8700_sensor type =fxos8700_to_sensor (chan_type); +u8 tmp_data[2 ]; +u16 native_data; +int ret; - base = type ?FXOS8700_OUT_X_MSB :FXOS8700_M_OUT_X_MSB ; + base = type ?FXOS8700_M_OUT_X_MSB :FXOS8700_OUT_X_MSB ; + offset = axis -IIO_MOD_X ; -/* Block read 6 bytes of device output registers to avoid data loss */ - ret =regmap_bulk_read (data->regmap, base, data->buf, -FXOS8700_DATA_BUF_SIZE ); + ret =regmap_bulk_read (data->regmap, base + offset, &tmp_data[0 ],2 );if (ret) -return ret; +return -EIO ; -/* Convert axis to buffer index */ - reg = axis -IIO_MOD_X ; + data->buf = ((tmp_data[1 ] <<8 ) &0xff00 ) | tmp_data[0 ];/* Convert to native endianness */ - *val =sign_extend32 (be16_to_cpu (data->buf[reg]),15 ); + native_data =be16_to_cpu (data->buf); + +/*accel raw data only has 14 bit */ +if (!type) + native_data = native_data >>2 ; + + *val =sign_extend32 (native_data,15 );return 0 ; }
@@ -462,6 +489,7 @@ static int fxos8700_get_odr(struct fxos8700_data *data, enum fxos8700_sensor t,return ret; val &=FXOS8700_CTRL_ODR_MSK ; + val = val >>3 ;for (i =0 ; i < odr_num; i++)if (val == fxos8700_odr[i].bits)
@@ -592,14 +620,14 @@ static int fxos8700_chip_init(struct fxos8700_data *data, bool use_spi)if (ret)return ret; -/* Max ODR (800Hz individual or 400Hz hybrid), active mode */ - ret =regmap_write (data->regmap,FXOS8700_CTRL_REG1 , -FXOS8700_CTRL_ODR_MAX |FXOS8700_ACTIVE ); +/* Set for max full-scale range (+/-8G) */ + ret =regmap_write (data->regmap,FXOS8700_XYZ_DATA_CFG ,MODE_8G );if (ret)return ret; -/* Set for max full-scale range (+/-8G) */ -return regmap_write (data->regmap,FXOS8700_XYZ_DATA_CFG ,MODE_8G ); +/* Max ODR (800Hz individual or 400Hz hybrid), active mode */ +return regmap_write (data->regmap,FXOS8700_CTRL_REG1 , +FXOS8700_CTRL_ODR_MAX <<3 |FXOS8700_ACTIVE ); }static void fxos8700_chip_uninit (void *data)
Signature · 1 line
2.25.1
Quoted 8 lines · On Tue, 22 Feb 2022 12:07:02 +0800 <[email protected]> wrote:
From: Haibo Chen <[email protected]>
1, z raw data always 0,
regmap_buk_readuse the wrong length. fix it and optmize read the only need data.
2, use the correct register address when try to read raw data. 3, before set scale, need to set the sensor to standby mode. otherwise the scale set is not work.
4, give the correct offset when config odr bit.
Sounds like 4 patches to me. Whenever you have a list of what a patch does you should probably split it up. Would be a lot easier to review as one patch per issue. For now I've just take a quick general look.
Quoted 60 lines
Signed-off-by Haibo Chen <[email protected]>Reviewed-by Clark Wang <[email protected]>--- drivers/iio/imu/fxos8700_core.c | 66 +++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 19 deletions(-)drivers/iio/imu/fxos8700_core.c +20
-3@@ -162,12 +162,11 @@#define FXOS8700_DEVICE_ID 0xC7#define FXOS8700_PRE_DEVICE_ID 0xC4 -#define FXOS8700_DATA_BUF_SIZE 3struct fxos8700_data {struct regmap *regmap;struct iio_trigger *trig; -__be16 buf[FXOS8700_DATA_BUF_SIZE ]____cacheline_aligned ; +__be16 buf____cacheline_aligned ; };/* Regmap info */ @@ -345,7 +344,8 @@ static int fxos8700_set_active_mode(struct fxos8700_data *data,static int fxos8700_set_scale (struct fxos8700_data *data,enum fxos8700_sensor t,int uscale) { -int i; +int i, ret, val; +bool active_mode;static const int scale_num =ARRAY_SIZE (fxos8700_accel_scale);struct device *dev =regmap_get_device (data->regmap);@@ -354,6 +354,23 @@ static int fxos8700_set_scale(struct fxos8700_data *data,return -EINVAL ; } + ret =regmap_read (data->regmap,FXOS8700_CTRL_REG1 , &val); +if (ret) +return ret; + + active_mode = val &FXOS8700_ACTIVE ; + +if (active_mode) { +/* +* The device must be in standby mode to change any of the +* other fields within CTRL_REG1 +*/ + ret =regmap_write (data->regmap,FXOS8700_CTRL_REG1 , + val & ~FXOS8700_ACTIVE ); +if (ret) +return ret; + } +for (i =0 ; i < scale_num; i++)if (fxos8700_accel_scale[i].uscale == uscale)break ;
drivers/iio/imu/fxos8700_core.c static int fxos8700_set_scale(struct fxos8700_data *data, · line 382
Quoted 6 lines
drivers/iio/imu/fxos8700_core.c +1
-1@@ -361,8 +378,12 @@ static int fxos8700_set_scale(struct fxos8700_data *data,if (i == scale_num)return -EINVAL ; -return regmap_write (data->regmap,FXOS8700_XYZ_DATA_CFG , + ret =regmap_write (data->regmap,FXOS8700_XYZ_DATA_CFG , fxos8700_accel_scale[i].bits);
Realign these parameters with the opening bracket.
drivers/iio/imu/fxos8700_core.c static int fxos8700_set_scale(struct fxos8700_data *data, · line 384
Quoted 2 lines
drivers/iio/imu/fxos8700_core.c +2
-0+if (ret) +return ret;
blank line here.
Quoted 6 lines
drivers/iio/imu/fxos8700_core.c +2
-0+return regmap_update_bits (data->regmap,FXOS8700_CTRL_REG1 , +FXOS8700_ACTIVE , active_mode); } static int fxos8700_get_scale(struct fxos8700_data *data,
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_scale(struct fxos8700_data *data, · line 419
Quoted 8 lines
drivers/iio/imu/fxos8700_core.c +2
-2@@ -393,23 +414,29 @@ static int fxos8700_get_scale(struct fxos8700_data *data,static int fxos8700_get_data (struct fxos8700_data *data,int chan_type,int axis,int *val) { -u8 base, reg; -int ret; +u8 base, offset;enum fxos8700_sensor type =fxos8700_to_sensor (chan_type); +u8 tmp_data[2 ];
We loop around this every now and then. It 'happens' to be the case that currently (or last time I checked) regmap_bulk_read always copied the data and hence uses a dma safe buffer internally. That is not guaranteed by the interface however so when we last asked Mark Brown he suggested we should assume that it requires the same level of dma buffer safety as the bus subsystems being used.
Thus for any driver doing bulk accesses to SPI device, you need a DMA safe buffer. Which is what the __cacheline_aligned buffer in iio_priv() is for in this driver.
Quoted 4 lines
drivers/iio/imu/fxos8700_core.c +2
-1+u16 native_data; +int ret; - base = type ?FXOS8700_OUT_X_MSB :FXOS8700_M_OUT_X_MSB ;
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_scale(struct fxos8700_data *data, · line 428
Quoted 10 lines
drivers/iio/imu/fxos8700_core.c +4
-4+ base = type ?FXOS8700_M_OUT_X_MSB :FXOS8700_OUT_X_MSB ; + offset = axis -IIO_MOD_X ; -/* Block read 6 bytes of device output registers to avoid data loss */ - ret =regmap_bulk_read (data->regmap, base, data->buf, -FXOS8700_DATA_BUF_SIZE ); + ret =regmap_bulk_read (data->regmap, base + offset, &tmp_data[0 ],2 );if (ret) -return ret; +return -EIO ;
Why eat the error return of the bulk_read and replace it with a potentially less informative one?
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_scale(struct fxos8700_data *data, · line 431
Quoted 5 lines
drivers/iio/imu/fxos8700_core.c +1
-2-/* Convert axis to buffer index */ - reg = axis -IIO_MOD_X ; + data->buf = ((tmp_data[1 ] <<8 ) &0xff00 ) | tmp_data[0 ];
tmp_data[1] is a u8 so that masking isn't doing anything other than possibly fixing some type conversion issues.
However, this is an endian operation, so express it as such get_unaligned_be16(tmp_data); or similar. Maybe even just use a __be16 and be16_to_cpu() directly on that.
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_scale(struct fxos8700_data *data, · line 433
Quoted 3 lines
drivers/iio/imu/fxos8700_core.c +1
-1/* Convert to native endianness */ - *val =sign_extend32 (be16_to_cpu (data->buf[reg]),15 ); + native_data =be16_to_cpu (data->buf);
This looks wrong. You've already done a be to cpu conversion (via the shifts above) now y ou are doing it again. Why?
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_scale(struct fxos8700_data *data, · line 435
Quoted 2 lines
drivers/iio/imu/fxos8700_core.c +2
-0+ +/*accel raw data only has 14 bit */
/* Accel ...
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_odr(struct fxos8700_data *data, enum fxos8700_sensor t, · line 492
Quoted 12 lines
drivers/iio/imu/fxos8700_core.c +5
-0+if (!type) + native_data = native_data >>2 ; + + *val =sign_extend32 (native_data,15 );return 0 ; }@@ -462,6 +489,7 @@ static int fxos8700_get_odr(struct fxos8700_data *data, enum fxos8700_sensor t,return ret; val &=FXOS8700_CTRL_ODR_MSK ; + val = val >>3 ;
FIELD_GET() would be easier to read for this.
Quoted 10 lines
drivers/iio/imu/fxos8700_core.c +0
-3for (i =0 ; i < odr_num; i++)if (val == fxos8700_odr[i].bits)@@ -592,14 +620,14 @@ static int fxos8700_chip_init(struct fxos8700_data *data, bool use_spi)if (ret)return ret; -/* Max ODR (800Hz individual or 400Hz hybrid), active mode */ - ret =regmap_write (data->regmap,FXOS8700_CTRL_REG1 , -FXOS8700_CTRL_ODR_MAX |FXOS8700_ACTIVE );
drivers/iio/imu/fxos8700_core.c static int fxos8700_chip_init(struct fxos8700_data *data, bool use_spi) · line 630
Quoted 10 lines
drivers/iio/imu/fxos8700_core.c +5
-2+/* Set for max full-scale range (+/-8G) */ + ret =regmap_write (data->regmap,FXOS8700_XYZ_DATA_CFG ,MODE_8G );if (ret)return ret; -/* Set for max full-scale range (+/-8G) */ -return regmap_write (data->regmap,FXOS8700_XYZ_DATA_CFG ,MODE_8G ); +/* Max ODR (800Hz individual or 400Hz hybrid), active mode */ +return regmap_write (data->regmap,FXOS8700_CTRL_REG1 , +FXOS8700_CTRL_ODR_MAX <<3 |FXOS8700_ACTIVE );
Preference for FIELD_PREP() to make ti clear what you are shifting left and why. Given you have FXOS8700_CTRL_ODR_MSK that is easy to add here.
Mind you it's a noop as ODR_MAX == 0 anyway :)
Quoted 3 lines
drivers/iio/imu/fxos8700_core.c +0
-0}static void fxos8700_chip_uninit (void *data)
Quoted 20 lines
-----Original Message-----
From: Jonathan Cameron [mailto:[email protected]]
Sent: 2022年2月23日 0:57
To: Bough Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>
Subject: Re: [PATCH] iio: imu: fxos8700: few bug fix for fxos8700Quoted 8 lines · On Tue, 22 Feb 2022 12:07:02 +0800 <[email protected]> wrote:
From: Haibo Chen <[email protected]>
1, z raw data always 0,
regmap_buk_readuse the wrong length. fix it and optmize read the only need data.
2, use the correct register address when try to read raw data. 3, before set scale, need to set the sensor to standby mode. otherwise the scale set is not work.
4, give the correct offset when config odr bit.
Quoted 5 lines
Sounds like 4 patches to me. Whenever you have a list of what a patch does you should probably split it up. Would be a lot easier to review as one patch per issue. For now I've just take a quick general look.
Hi Jonathan
Thanks for your suggestion, I will split few patches in the next version.
Quoted 82 lines
Quoted 28 lines
Signed-off-by Haibo Chen <[email protected]>Reviewed-by Clark Wang <[email protected]>--- drivers/iio/imu/fxos8700_core.c | 66 +++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 19 deletions(-)(quoted diff) +0
-0
b/drivers/iio/imu/fxos8700_core.cindexab288186f36e..1896d6db6d77100644drivers/iio/imu/fxos8700_core.c +1
-2@@ -162,12 +162,11 @@#define FXOS8700_DEVICE_ID 0xC7#define FXOS8700_PRE_DEVICE_ID 0xC4 -#define FXOS8700_DATA_BUF_SIZE 3struct fxos8700_data {struct regmap *regmap;struct iio_trigger *trig; -__be16 buf[FXOS8700_DATA_BUF_SIZE ]____cacheline_aligned ; +__be16 buf____cacheline_aligned ; };/* Regmap info */ @@ -345,7 +344,8 @@ static int fxos8700_set_active_mode(structQuoted 1 line
fxos8700_data*data, static int fxos8700_set_scale(struct
fxos8700_data*data,drivers/iio/imu/fxos8700_core.c static int fxos8700_set_scale(struct
Quoted 8 lines
drivers/iio/imu/fxos8700_core.c +2
-1enum fxos8700_sensor t, int uscale) { - int i; + int i, ret, val; +bool active_mode;static const int scale_num =ARRAY_SIZE (fxos8700_accel_scale);struct device *dev =regmap_get_device (data->regmap);@@ -354,6 +354,23 @@ static int fxos8700_set_scale(struct
fxos8700_data*data,drivers/iio/imu/fxos8700_core.c static int fxos8700_set_scale(struct
Quoted 24 lines
drivers/iio/imu/fxos8700_core.c +17
-0return -EINVAL ; } + ret =regmap_read (data->regmap,FXOS8700_CTRL_REG1 , &val); +if (ret) +return ret; + + active_mode = val &FXOS8700_ACTIVE ; + +if (active_mode) { +/* +* The device must be in standby mode to change any of the +* other fields within CTRL_REG1 +*/ + ret =regmap_write (data->regmap,FXOS8700_CTRL_REG1 , + val & ~FXOS8700_ACTIVE ); +if (ret) +return ret; + } +for (i =0 ; i < scale_num; i++)if (fxos8700_accel_scale[i].uscale == uscale)break ;@@ -361,8 +378,12 @@ static int fxos8700_set_scale(struct
fxos8700_data*data,drivers/iio/imu/fxos8700_core.c static int fxos8700_set_scale(struct fxos8700_data *data, · line 382
Quoted 6 lines
drivers/iio/imu/fxos8700_core.c +1
-1if (i == scale_num)return -EINVAL ; -return regmap_write (data->regmap,FXOS8700_XYZ_DATA_CFG , + ret =regmap_write (data->regmap,FXOS8700_XYZ_DATA_CFG , fxos8700_accel_scale[i].bits);Realign these parameters with the opening bracket.
drivers/iio/imu/fxos8700_core.c static int fxos8700_set_scale(struct · line 384
Quoted 2 lines
drivers/iio/imu/fxos8700_core.c +2
-0+if (ret) +return ret;blank line here.
Quoted 4 lines
drivers/iio/imu/fxos8700_core.c +2
-0+return regmap_update_bits (data->regmap,FXOS8700_CTRL_REG1 , +FXOS8700_ACTIVE , active_mode); }
Quoted 15 lines
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_scale(struct fxos8700_data *data, · line 419
Quoted 10 lines
drivers/iio/imu/fxos8700_core.c +1
-0static int fxos8700_get_scale(struct fxos8700_data *data, @@ -393,23 +414,29 @@ static int fxos8700_get_scale(struct fxos8700_data *data,static int fxos8700_get_data(struct
fxos8700_data*data, intchan_type,drivers/iio/imu/fxos8700_core.c +2
-2int axis, int *val) { - u8 base, reg; -int ret; + u8 base, offset;enum fxos8700_sensor type =fxos8700_to_sensor (chan_type); +u8 tmp_data[2 ];We loop around this every now and then. It 'happens' to be the case that currently (or last time I checked)
regmap_bulk_readalways copied the data and hence uses a dma safe buffer internally. That is not guaranteed by the interface however so when we last asked Mark Brown he suggested we should assume that it requires the same level of dma buffer safety as the
bus
Quoted 4 lines
subsystems being used.
Thus for any driver doing bulk accesses to SPI device, you need a DMA safe buffer. Which is what the
__cacheline_alignedbuffer iniio_priv()is for
in
Quoted 1 line
this driver.
Thanks for your sharing, I will take care of this.
Quoted 9 lines
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_scale(struct fxos8700_data *data,
Quoted 9 lines
drivers/iio/imu/fxos8700_core.c +4
-2+u16 native_data; +int ret; - base = type ?FXOS8700_OUT_X_MSB :FXOS8700_M_OUT_X_MSB ; + base = type ?FXOS8700_M_OUT_X_MSB :FXOS8700_OUT_X_MSB ; + offset = axis -IIO_MOD_X ; -/* Block read 6 bytes of device output registers to avoid data loss
*/
Quoted 9 lines
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_scale(struct fxos8700_data *data, · line 428
Quoted 7 lines
drivers/iio/imu/fxos8700_core.c +3
-3- ret =regmap_bulk_read (data->regmap, base, data->buf, -FXOS8700_DATA_BUF_SIZE ); + ret =regmap_bulk_read (data->regmap, base + offset, &tmp_data[0 ], +2 );if (ret) -return ret; +return -EIO ;Why eat the error return of the
bulk_readand replace it with a
potentially
Quoted 1 line
less informative one?
My bad, will fix.
Quoted 8 lines
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_scale(struct fxos8700_data *data, · line 431
Quoted 6 lines
drivers/iio/imu/fxos8700_core.c +1
-2-/* Convert axis to buffer index */ - reg = axis -IIO_MOD_X ; + data->buf = ((tmp_data[1 ] <<8 ) &0xff00 ) | tmp_data[0 ];tmp_data[1] is a u8 so that masking isn't doing anything other than
possibly
Quoted 1 line
fixing some type conversion issues.
Oh, you are correct, I will fix that.
Quoted 4 lines
However, this is an endian operation, so express it as such
get_unaligned_be16(tmp_data); or similar. Maybe even just use a__be16andbe16_to_cpu()directly on that.
I will re-do this code.
Quoted 8 lines
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_scale(struct fxos8700_data *data, · line 433
Quoted 5 lines
drivers/iio/imu/fxos8700_core.c +1
-1/* Convert to native endianness */ - *val =sign_extend32 (be16_to_cpu (data->buf[reg]),15 ); + native_data =be16_to_cpu (data->buf);This looks wrong. You've already done a be to cpu conversion (via the shifts above) now y ou are doing it again. Why?
For this sensor, according to the RM
For the first register(address 01), we get data[13~6], and for the second register(address 02), we get 8 bit data, the upper 6 bit is data[5~0], Seems I made the logic complicated.
Quoted 39 lines
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_scale(struct fxos8700_data *data, · line 435
Quoted 3 lines
drivers/iio/imu/fxos8700_core.c +2
-0+ +/*accel raw data only has 14 bit */ /* Accel ...
drivers/iio/imu/fxos8700_core.c static int fxos8700_get_odr(struct fxos8700_data
Quoted 8 lines
drivers/iio/imu/fxos8700_core.c +4
-0+if (!type) + native_data = native_data >>2 ; + + *val =sign_extend32 (native_data,15 );return 0 ; }@@ -462,6 +489,7 @@ static int fxos8700_get_odr(struct fxos8700_data*data, enum
fxos8700_sensort,drivers/iio/imu/fxos8700_core.c static int fxos8700_get_odr(struct fxos8700_data *data, enum fxos8700_sensor t, · line 492
Quoted 4 lines
drivers/iio/imu/fxos8700_core.c +1
-0return ret; val &=FXOS8700_CTRL_ODR_MSK ; + val = val >>3 ;
FIELD_GET()would be easier to read for this.drivers/iio/imu/fxos8700_core.c static int fxos8700_chip_init(struct
Quoted 4 lines
drivers/iio/imu/fxos8700_core.c +0
-0for (i =0 ; i < odr_num; i++)if (val == fxos8700_odr[i].bits)@@ -592,14 +620,14 @@ static int fxos8700_chip_init(struct
fxos8700_data*data, booluse_spi)drivers/iio/imu/fxos8700_core.c static int fxos8700_chip_init(struct fxos8700_data *data, bool use_spi)
Quoted 8 lines
drivers/iio/imu/fxos8700_core.c +2
-3if (ret)return ret; -/* Max ODR (800Hz individual or 400Hz hybrid), active mode */ - ret =regmap_write (data->regmap,FXOS8700_CTRL_REG1 , -FXOS8700_CTRL_ODR_MAX |FXOS8700_ACTIVE ); +/* Set for max full-scale range (+/-8G) */ + ret = regmap_write(data->regmap, FXOS8700_XYZ_DATA_CFG,
MODE_8G);Quoted 3 lines
drivers/iio/imu/fxos8700_core.c +0
-0if (ret)return ret;
Quoted 8 lines
drivers/iio/imu/fxos8700_core.c static int fxos8700_chip_init(struct · line 602
Quoted 2 lines
drivers/iio/imu/fxos8700_core.c +0
-2-/* Set for max full-scale range (+/-8G) */ - return regmap_write(data->regmap, FXOS8700_XYZ_DATA_CFG,
MODE_8G);drivers/iio/imu/fxos8700_core.c static int fxos8700_chip_init(struct fxos8700_data *data, bool use_spi) · line 630
Quoted 3 lines
drivers/iio/imu/fxos8700_core.c +3
-0+/* Max ODR (800Hz individual or 400Hz hybrid), active mode */ +return regmap_write (data->regmap,FXOS8700_CTRL_REG1 , +FXOS8700_CTRL_ODR_MAX <<3 |FXOS8700_ACTIVE );Preference for
FIELD_PREP()to make ti clear what you are shifting left
and
Quoted 3 lines
why.
Given you haveFXOS8700_CTRL_ODR_MSKthat is easy to add here. Mind you it's a noop asODR_MAX== 0 anyway :)
Thanks for your suggestion, I just want to optimize that I config ODR_MAX, but seems
It better only mentioned this in the comment, do not need add in the code.
Best Regards
Haibo Chen
Quoted 5 lines
Quoted 5 lines
drivers/iio/imu/fxos8700_core.c +0
-0}static void fxos8700_chip_uninit (void *data)