Message ID | 20250116180342.161323-2-u.kleine-koenig@baylibre.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | iio: adc: ad7124: Micro-optimize channel disabling | expand |
diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index 6ae27cdd3250..73c831626bf3 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -559,7 +559,8 @@ static int ad7124_disable_one(struct ad_sigma_delta *sd, unsigned int chan) { struct ad7124_state *st = container_of(sd, struct ad7124_state, sd); - return ad7124_spi_write_mask(st, AD7124_CHANNEL(chan), AD7124_CHANNEL_EN_MSK, 0, 2); + /* The relevant thing here is that AD7124_CHANNEL_EN_MSK is cleared. */ + return ad_sd_write_reg(&st->sd, AD7124_CHANNEL(chan), 2, 0); } static const struct ad_sigma_delta_info ad7124_sigma_delta_info = {
The key objective in ad7124_disable_one() is clearing the AD7124_CHANNEL_EN_MSK bit in the channel register. However there is no advantage to keep the other bits in that register because when the channel is used next time, all fields are rewritten anyhow. So instead of using ad7124_spi_write_mask() (which is a register read plus a register write) use a simple register write clearing the complete register. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> --- Hello, while looking at traces I spotted this unnecessary register read. On my machine (de10nano) this register read takes ~23 µs when doing cat /sys/bus/iio/devices/iio:device0/in_temp_raw . Compared to the time the chip needs for the actual conversion (~400 ms) this is little gain, but still. And more relevant for me: It simplifies trace studies. To state the obvious: This is totally not urgent and merge window material. Best regards Uwe drivers/iio/adc/ad7124.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) base-commit: b323d8e7bc03d27dec646bfdccb7d1a92411f189