diff options
author | Biju Das <biju.das.jz@bp.renesas.com> | 2023-09-03 10:00:51 +0100 |
---|---|---|
committer | Jonathan Cameron <jonathan.cameron@huawei.com> | 2023-09-12 10:42:04 +0100 |
commit | dcc3ac1381eff05e4ab546a42798dd6837b295a7 (patch) | |
tree | 5ae9f4cb9a7e770f0ae45f40b6ad99aeeb80e838 /drivers/iio/accel/adxl345_core.c | |
parent | 7d0ba6dbf8356d20b69cfd042800d5d51ac00bd7 (diff) | |
download | linux-dcc3ac1381eff05e4ab546a42798dd6837b295a7.tar.gz linux-dcc3ac1381eff05e4ab546a42798dd6837b295a7.tar.bz2 linux-dcc3ac1381eff05e4ab546a42798dd6837b295a7.zip |
iio: accel: adxl345: Simplify adxl345_read_raw()
Simplify adxl345_read_raw() by adding uscale variable to
struct adxl345_chip_info. Also convert variables adxl3{4,7}5_uscale to
macros and use it in OF/ACPI/ID match table.
Drop enum adxl345_device_type as there is no user.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20230903090051.39274-3-biju.das.jz@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/accel/adxl345_core.c')
-rw-r--r-- | drivers/iio/accel/adxl345_core.c | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 28f77b5de47d..8bd30a23ed3b 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -45,21 +45,6 @@ #define ADXL345_DEVID 0xE5 -/* - * In full-resolution mode, scale factor is maintained at ~4 mg/LSB - * in all g ranges. - * - * At +/- 16g with 13-bit resolution, scale is computed as: - * (16 + 16) * 9.81 / (2^13 - 1) = 0.0383 - */ -static const int adxl345_uscale = 38300; - -/* - * The Datasheet lists a resolution of Resolution is ~49 mg per LSB. That's - * ~480mm/s**2 per LSB. - */ -static const int adxl375_uscale = 480000; - struct adxl345_data { const struct adxl345_chip_info *info; struct regmap *regmap; @@ -110,15 +95,7 @@ static int adxl345_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = 0; - switch (data->info->type) { - case ADXL345: - *val2 = adxl345_uscale; - break; - case ADXL375: - *val2 = adxl375_uscale; - break; - } - + *val2 = data->info->uscale; return IIO_VAL_INT_PLUS_MICRO; case IIO_CHAN_INFO_CALIBBIAS: ret = regmap_read(data->regmap, |