Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: accel: adxl380: Store sampling frequency index in odr struct member

The ADXL380 driver assumes that acceleration samples are always retrieved
via the high-performance DSM signal path; as a result, the sampling
frequency value depends exclusively on the decimation filter settings in
the TRIG_CFG register.
In preparation for adding support for sampling frequency values that rely
on the low-power SAR signal path (on which the decimation filters are not
supported), use the (currently unused) 'odr' member of struct adxl380_state
to store the sampling frequency value, and when userspace requests the
current frequency value, retrieve it from the struct instead of calculating
it from the decimation filter settings.

Signed-off-by: Francesco Lavra <flavra@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Francesco Lavra and committed by
Jonathan Cameron
a99b000f bac5e3d2

+2 -11
+2 -11
drivers/iio/accel/adxl380.c
··· 417 417 418 418 static int adxl380_get_odr(struct adxl380_state *st, int *odr) 419 419 { 420 - int ret; 421 - unsigned int trig_cfg, odr_idx; 422 - 423 - ret = regmap_read(st->regmap, ADXL380_TRIG_CFG_REG, &trig_cfg); 424 - if (ret) 425 - return ret; 426 - 427 - odr_idx = (FIELD_GET(ADXL380_TRIG_CFG_SINC_RATE_MSK, trig_cfg) << 1) | 428 - (FIELD_GET(ADXL380_TRIG_CFG_DEC_2X_MSK, trig_cfg) & 1); 429 - 430 - *odr = st->chip_info->samp_freq_tbl[odr_idx]; 420 + *odr = st->chip_info->samp_freq_tbl[st->odr]; 431 421 432 422 return 0; 433 423 } ··· 490 500 if (ret) 491 501 return ret; 492 502 503 + st->odr = odr; 493 504 ret = adxl380_set_measure_en(st, true); 494 505 if (ret) 495 506 return ret;