linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: imu: st_lsm6dsx: remove invalid gain value for LSM9DS1
@ 2019-08-27  8:26 Lorenzo Bianconi
  2019-08-27 20:08 ` Jonathan Cameron
  0 siblings, 1 reply; 12+ messages in thread
From: Lorenzo Bianconi @ 2019-08-27  8:26 UTC (permalink / raw)
  To: jic23; +Cc: lorenzo.bianconi, linux-iio, martin.kepplinger

Get rid of invalid sensitivity value for LSM9DS1 gyro sensor

Fixes: 687a60feb9c6 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 17 +++++++++++------
 1 file changed, 11 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 fd152fff0a8c..c85c8be3a024 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -151,10 +151,9 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 					.addr = 0x10,
 					.mask = GENMASK(4, 3),
 				},
-				.fs_avl[0] = { IIO_DEGREE_TO_RAD(245), 0x0 },
-				.fs_avl[1] = { IIO_DEGREE_TO_RAD(500), 0x1 },
-				.fs_avl[2] = { IIO_DEGREE_TO_RAD(0), 0x2 },
-				.fs_avl[3] = { IIO_DEGREE_TO_RAD(2000), 0x3 },
+				.fs_avl[0] = {  IIO_DEGREE_TO_RAD(245), 0x0 },
+				.fs_avl[1] = {  IIO_DEGREE_TO_RAD(500), 0x1 },
+				.fs_avl[2] = { IIO_DEGREE_TO_RAD(2000), 0x3 },
 			},
 		},
 	},
@@ -1196,13 +1195,19 @@ static ssize_t st_lsm6dsx_sysfs_scale_avail(struct device *dev,
 					    char *buf)
 {
 	struct st_lsm6dsx_sensor *sensor = iio_priv(dev_get_drvdata(dev));
+	const struct st_lsm6dsx_fs_table_entry *fs_table;
 	enum st_lsm6dsx_sensor_id id = sensor->id;
 	struct st_lsm6dsx_hw *hw = sensor->hw;
 	int i, len = 0;
 
-	for (i = 0; i < ST_LSM6DSX_FS_LIST_SIZE; i++)
+	fs_table = &hw->settings->fs_table[id];
+	for (i = 0; i < ST_LSM6DSX_FS_LIST_SIZE; i++) {
+		if (!fs_table->fs_avl[i].gain)
+			break;
+
 		len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ",
-				 hw->settings->fs_table[id].fs_avl[i].gain);
+				 fs_table->fs_avl[i].gain);
+	}
 	buf[len - 1] = '\n';
 
 	return len;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-09-03 12:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27  8:26 [PATCH] iio: imu: st_lsm6dsx: remove invalid gain value for LSM9DS1 Lorenzo Bianconi
2019-08-27 20:08 ` Jonathan Cameron
2019-08-29  5:27   ` [BUG] " Martin Kepplinger
2019-08-29  5:50     ` [PATCH] Revert "iio: imu: st_lsm6dsx: remove invalid gain value for LSM9DS1" Martin Kepplinger
2019-08-29  8:37     ` [BUG] Re: [PATCH] iio: imu: st_lsm6dsx: remove invalid gain value for LSM9DS1 Lorenzo Bianconi
2019-08-30  6:01       ` Martin Kepplinger
2019-08-30  7:23         ` Lorenzo Bianconi
2019-08-30 12:53           ` Martin Kepplinger
2019-08-31  9:32             ` Lorenzo Bianconi
2019-09-01 14:50               ` Jonathan Cameron
2019-09-03  5:22                 ` Martin Kepplinger
2019-09-03 12:37                   ` 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).