* [PATCH] iio: imu: st_lsm6dsx: inline per-sensor data
[not found] <cover.1554842769.git.lorenzo@kernel.org>
@ 2019-04-09 20:49 ` Lorenzo Bianconi
2019-04-14 13:59 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Bianconi @ 2019-04-09 20:49 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, lorenzo.bianconi
As it has been already done for other st sensors in 'commit 9049531c91b4
("iio: accel: st_accel: inline per-sensor data")', get rid of some
defines and just open code the values into the appropriate struct
elements since the semantic meaning is inherent in the name of the
C99-addressable fields and there is no reason to duplicate the code
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 50 +++++++-------------
1 file changed, 16 insertions(+), 34 deletions(-)
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 04124cc277dd..cf82c9049945 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -62,37 +62,19 @@
#define ST_LSM6DSX_REG_INT2_ON_INT1_ADDR 0x13
#define ST_LSM6DSX_REG_INT2_ON_INT1_MASK BIT(5)
-#define ST_LSM6DSX_REG_ACC_ODR_ADDR 0x10
-#define ST_LSM6DSX_REG_ACC_ODR_MASK GENMASK(7, 4)
-#define ST_LSM6DSX_REG_ACC_FS_ADDR 0x10
-#define ST_LSM6DSX_REG_ACC_FS_MASK GENMASK(3, 2)
#define ST_LSM6DSX_REG_ACC_OUT_X_L_ADDR 0x28
#define ST_LSM6DSX_REG_ACC_OUT_Y_L_ADDR 0x2a
#define ST_LSM6DSX_REG_ACC_OUT_Z_L_ADDR 0x2c
-#define ST_LSM6DSX_REG_GYRO_ODR_ADDR 0x11
-#define ST_LSM6DSX_REG_GYRO_ODR_MASK GENMASK(7, 4)
-#define ST_LSM6DSX_REG_GYRO_FS_ADDR 0x11
-#define ST_LSM6DSX_REG_GYRO_FS_MASK GENMASK(3, 2)
#define ST_LSM6DSX_REG_GYRO_OUT_X_L_ADDR 0x22
#define ST_LSM6DSX_REG_GYRO_OUT_Y_L_ADDR 0x24
#define ST_LSM6DSX_REG_GYRO_OUT_Z_L_ADDR 0x26
-#define ST_LSM6DSX_ACC_FS_2G_GAIN IIO_G_TO_M_S_2(61)
-#define ST_LSM6DSX_ACC_FS_4G_GAIN IIO_G_TO_M_S_2(122)
-#define ST_LSM6DSX_ACC_FS_8G_GAIN IIO_G_TO_M_S_2(244)
-#define ST_LSM6DSX_ACC_FS_16G_GAIN IIO_G_TO_M_S_2(488)
-
-#define ST_LSM6DSX_GYRO_FS_245_GAIN IIO_DEGREE_TO_RAD(8750)
-#define ST_LSM6DSX_GYRO_FS_500_GAIN IIO_DEGREE_TO_RAD(17500)
-#define ST_LSM6DSX_GYRO_FS_1000_GAIN IIO_DEGREE_TO_RAD(35000)
-#define ST_LSM6DSX_GYRO_FS_2000_GAIN IIO_DEGREE_TO_RAD(70000)
-
static const struct st_lsm6dsx_odr_table_entry st_lsm6dsx_odr_table[] = {
[ST_LSM6DSX_ID_ACC] = {
.reg = {
- .addr = ST_LSM6DSX_REG_ACC_ODR_ADDR,
- .mask = ST_LSM6DSX_REG_ACC_ODR_MASK,
+ .addr = 0x10,
+ .mask = GENMASK(7, 4),
},
.odr_avl[0] = { 13, 0x01 },
.odr_avl[1] = { 26, 0x02 },
@@ -103,8 +85,8 @@ static const struct st_lsm6dsx_odr_table_entry st_lsm6dsx_odr_table[] = {
},
[ST_LSM6DSX_ID_GYRO] = {
.reg = {
- .addr = ST_LSM6DSX_REG_GYRO_ODR_ADDR,
- .mask = ST_LSM6DSX_REG_GYRO_ODR_MASK,
+ .addr = 0x11,
+ .mask = GENMASK(7, 4),
},
.odr_avl[0] = { 13, 0x01 },
.odr_avl[1] = { 26, 0x02 },
@@ -118,23 +100,23 @@ static const struct st_lsm6dsx_odr_table_entry st_lsm6dsx_odr_table[] = {
static const struct st_lsm6dsx_fs_table_entry st_lsm6dsx_fs_table[] = {
[ST_LSM6DSX_ID_ACC] = {
.reg = {
- .addr = ST_LSM6DSX_REG_ACC_FS_ADDR,
- .mask = ST_LSM6DSX_REG_ACC_FS_MASK,
+ .addr = 0x10,
+ .mask = GENMASK(3, 2),
},
- .fs_avl[0] = { ST_LSM6DSX_ACC_FS_2G_GAIN, 0x0 },
- .fs_avl[1] = { ST_LSM6DSX_ACC_FS_4G_GAIN, 0x2 },
- .fs_avl[2] = { ST_LSM6DSX_ACC_FS_8G_GAIN, 0x3 },
- .fs_avl[3] = { ST_LSM6DSX_ACC_FS_16G_GAIN, 0x1 },
+ .fs_avl[0] = { IIO_G_TO_M_S_2(61), 0x0 },
+ .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 },
+ .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 },
+ .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 },
},
[ST_LSM6DSX_ID_GYRO] = {
.reg = {
- .addr = ST_LSM6DSX_REG_GYRO_FS_ADDR,
- .mask = ST_LSM6DSX_REG_GYRO_FS_MASK,
+ .addr = 0x11,
+ .mask = GENMASK(3, 2),
},
- .fs_avl[0] = { ST_LSM6DSX_GYRO_FS_245_GAIN, 0x0 },
- .fs_avl[1] = { ST_LSM6DSX_GYRO_FS_500_GAIN, 0x1 },
- .fs_avl[2] = { ST_LSM6DSX_GYRO_FS_1000_GAIN, 0x2 },
- .fs_avl[3] = { ST_LSM6DSX_GYRO_FS_2000_GAIN, 0x3 },
+ .fs_avl[0] = { IIO_DEGREE_TO_RAD(8750), 0x0 },
+ .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 },
+ .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 },
+ .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 },
}
};
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: imu: st_lsm6dsx: inline per-sensor data
2019-04-09 20:49 ` [PATCH] iio: imu: st_lsm6dsx: inline per-sensor data Lorenzo Bianconi
@ 2019-04-14 13:59 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2019-04-14 13:59 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-iio, lorenzo.bianconi
On Tue, 9 Apr 2019 22:49:09 +0200
Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> As it has been already done for other st sensors in 'commit 9049531c91b4
> ("iio: accel: st_accel: inline per-sensor data")', get rid of some
> defines and just open code the values into the appropriate struct
> elements since the semantic meaning is inherent in the name of the
> C99-addressable fields and there is no reason to duplicate the code
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Nice cleanup.
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.
thanks,
Jonathan
> ---
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 50 +++++++-------------
> 1 file changed, 16 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 04124cc277dd..cf82c9049945 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -62,37 +62,19 @@
> #define ST_LSM6DSX_REG_INT2_ON_INT1_ADDR 0x13
> #define ST_LSM6DSX_REG_INT2_ON_INT1_MASK BIT(5)
>
> -#define ST_LSM6DSX_REG_ACC_ODR_ADDR 0x10
> -#define ST_LSM6DSX_REG_ACC_ODR_MASK GENMASK(7, 4)
> -#define ST_LSM6DSX_REG_ACC_FS_ADDR 0x10
> -#define ST_LSM6DSX_REG_ACC_FS_MASK GENMASK(3, 2)
> #define ST_LSM6DSX_REG_ACC_OUT_X_L_ADDR 0x28
> #define ST_LSM6DSX_REG_ACC_OUT_Y_L_ADDR 0x2a
> #define ST_LSM6DSX_REG_ACC_OUT_Z_L_ADDR 0x2c
>
> -#define ST_LSM6DSX_REG_GYRO_ODR_ADDR 0x11
> -#define ST_LSM6DSX_REG_GYRO_ODR_MASK GENMASK(7, 4)
> -#define ST_LSM6DSX_REG_GYRO_FS_ADDR 0x11
> -#define ST_LSM6DSX_REG_GYRO_FS_MASK GENMASK(3, 2)
> #define ST_LSM6DSX_REG_GYRO_OUT_X_L_ADDR 0x22
> #define ST_LSM6DSX_REG_GYRO_OUT_Y_L_ADDR 0x24
> #define ST_LSM6DSX_REG_GYRO_OUT_Z_L_ADDR 0x26
>
> -#define ST_LSM6DSX_ACC_FS_2G_GAIN IIO_G_TO_M_S_2(61)
> -#define ST_LSM6DSX_ACC_FS_4G_GAIN IIO_G_TO_M_S_2(122)
> -#define ST_LSM6DSX_ACC_FS_8G_GAIN IIO_G_TO_M_S_2(244)
> -#define ST_LSM6DSX_ACC_FS_16G_GAIN IIO_G_TO_M_S_2(488)
> -
> -#define ST_LSM6DSX_GYRO_FS_245_GAIN IIO_DEGREE_TO_RAD(8750)
> -#define ST_LSM6DSX_GYRO_FS_500_GAIN IIO_DEGREE_TO_RAD(17500)
> -#define ST_LSM6DSX_GYRO_FS_1000_GAIN IIO_DEGREE_TO_RAD(35000)
> -#define ST_LSM6DSX_GYRO_FS_2000_GAIN IIO_DEGREE_TO_RAD(70000)
> -
> static const struct st_lsm6dsx_odr_table_entry st_lsm6dsx_odr_table[] = {
> [ST_LSM6DSX_ID_ACC] = {
> .reg = {
> - .addr = ST_LSM6DSX_REG_ACC_ODR_ADDR,
> - .mask = ST_LSM6DSX_REG_ACC_ODR_MASK,
> + .addr = 0x10,
> + .mask = GENMASK(7, 4),
> },
> .odr_avl[0] = { 13, 0x01 },
> .odr_avl[1] = { 26, 0x02 },
> @@ -103,8 +85,8 @@ static const struct st_lsm6dsx_odr_table_entry st_lsm6dsx_odr_table[] = {
> },
> [ST_LSM6DSX_ID_GYRO] = {
> .reg = {
> - .addr = ST_LSM6DSX_REG_GYRO_ODR_ADDR,
> - .mask = ST_LSM6DSX_REG_GYRO_ODR_MASK,
> + .addr = 0x11,
> + .mask = GENMASK(7, 4),
> },
> .odr_avl[0] = { 13, 0x01 },
> .odr_avl[1] = { 26, 0x02 },
> @@ -118,23 +100,23 @@ static const struct st_lsm6dsx_odr_table_entry st_lsm6dsx_odr_table[] = {
> static const struct st_lsm6dsx_fs_table_entry st_lsm6dsx_fs_table[] = {
> [ST_LSM6DSX_ID_ACC] = {
> .reg = {
> - .addr = ST_LSM6DSX_REG_ACC_FS_ADDR,
> - .mask = ST_LSM6DSX_REG_ACC_FS_MASK,
> + .addr = 0x10,
> + .mask = GENMASK(3, 2),
> },
> - .fs_avl[0] = { ST_LSM6DSX_ACC_FS_2G_GAIN, 0x0 },
> - .fs_avl[1] = { ST_LSM6DSX_ACC_FS_4G_GAIN, 0x2 },
> - .fs_avl[2] = { ST_LSM6DSX_ACC_FS_8G_GAIN, 0x3 },
> - .fs_avl[3] = { ST_LSM6DSX_ACC_FS_16G_GAIN, 0x1 },
> + .fs_avl[0] = { IIO_G_TO_M_S_2(61), 0x0 },
> + .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 },
> + .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 },
> + .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 },
> },
> [ST_LSM6DSX_ID_GYRO] = {
> .reg = {
> - .addr = ST_LSM6DSX_REG_GYRO_FS_ADDR,
> - .mask = ST_LSM6DSX_REG_GYRO_FS_MASK,
> + .addr = 0x11,
> + .mask = GENMASK(3, 2),
> },
> - .fs_avl[0] = { ST_LSM6DSX_GYRO_FS_245_GAIN, 0x0 },
> - .fs_avl[1] = { ST_LSM6DSX_GYRO_FS_500_GAIN, 0x1 },
> - .fs_avl[2] = { ST_LSM6DSX_GYRO_FS_1000_GAIN, 0x2 },
> - .fs_avl[3] = { ST_LSM6DSX_GYRO_FS_2000_GAIN, 0x3 },
> + .fs_avl[0] = { IIO_DEGREE_TO_RAD(8750), 0x0 },
> + .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 },
> + .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 },
> + .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 },
> }
> };
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-14 13:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1554842769.git.lorenzo@kernel.org>
2019-04-09 20:49 ` [PATCH] iio: imu: st_lsm6dsx: inline per-sensor data Lorenzo Bianconi
2019-04-14 13:59 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).