Skip to content

Commit 67dbf54

Browse files
janaszewskijic23
authored andcommitted
iio: lps331ap: Fix wrong in_pressure_scale output value
This patch fixes improper in_pressure_scale output that is returned by the lps331ap barometer sensor driver. According to the documentation the pressure after applying the scale has to be expressed in kilopascal units. With erroneous implementation the scale value larger by two orders of magnitude is returned - 2441410 instead of 24414. Signed-off-by: Jacek Anaszewski <[email protected]> Signed-off-by: Kyungmin Park <[email protected]> Acked-by: Denis Ciocca <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 8f6817a commit 67dbf54

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/iio/pressure/st_pressure_core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
#include <linux/iio/common/st_sensors.h>
2929
#include "st_pressure.h"
3030

31-
#define ST_PRESS_MBAR_TO_KPASCAL(x) (x * 10)
31+
#define ST_PRESS_LSB_PER_MBAR 4096UL
32+
#define ST_PRESS_KPASCAL_NANO_SCALE (100000000UL / \
33+
ST_PRESS_LSB_PER_MBAR)
3234
#define ST_PRESS_NUMBER_DATA_CHANNELS 1
3335

3436
/* DEFAULT VALUE FOR SENSORS */
@@ -51,8 +53,8 @@
5153
#define ST_PRESS_1_FS_ADDR 0x23
5254
#define ST_PRESS_1_FS_MASK 0x30
5355
#define ST_PRESS_1_FS_AVL_1260_VAL 0x00
54-
#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_MBAR_TO_KPASCAL(244141)
5556
#define ST_PRESS_1_FS_AVL_TEMP_GAIN 2083000
57+
#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE
5658
#define ST_PRESS_1_BDU_ADDR 0x20
5759
#define ST_PRESS_1_BDU_MASK 0x04
5860
#define ST_PRESS_1_DRDY_IRQ_ADDR 0x22

0 commit comments

Comments
 (0)