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: adc: ad7124: Micro-optimize channel disabling

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.

Also do the same in the .disable_all() callback by using the
.disable_one() callback there.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250120140708.1093655-2-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Uwe Kleine-König and committed by
Jonathan Cameron
cf67879b 3ea0944d

+9 -8
+9 -8
drivers/iio/adc/ad7124.c
··· 540 540 return 0; 541 541 } 542 542 543 + static int ad7124_disable_one(struct ad_sigma_delta *sd, unsigned int chan) 544 + { 545 + struct ad7124_state *st = container_of(sd, struct ad7124_state, sd); 546 + 547 + /* The relevant thing here is that AD7124_CHANNEL_EN_MSK is cleared. */ 548 + return ad_sd_write_reg(&st->sd, AD7124_CHANNEL(chan), 2, 0); 549 + } 550 + 543 551 static int ad7124_disable_all(struct ad_sigma_delta *sd) 544 552 { 545 553 struct ad7124_state *st = container_of(sd, struct ad7124_state, sd); ··· 555 547 int i; 556 548 557 549 for (i = 0; i < st->num_channels; i++) { 558 - ret = ad7124_spi_write_mask(st, AD7124_CHANNEL(i), AD7124_CHANNEL_EN_MSK, 0, 2); 550 + ret = ad7124_disable_one(sd, i); 559 551 if (ret < 0) 560 552 return ret; 561 553 } 562 554 563 555 return 0; 564 - } 565 - 566 - static int ad7124_disable_one(struct ad_sigma_delta *sd, unsigned int chan) 567 - { 568 - struct ad7124_state *st = container_of(sd, struct ad7124_state, sd); 569 - 570 - return ad7124_spi_write_mask(st, AD7124_CHANNEL(chan), AD7124_CHANNEL_EN_MSK, 0, 2); 571 556 } 572 557 573 558 static const struct ad_sigma_delta_info ad7124_sigma_delta_info = {