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

iio: adc: ad7091r-base: Remove duplicate code on volatile reg check

Both ad7091r_writeable_reg() and ad7091r_volatile_reg() perform the
same test, checking whether a given 'reg' code is
AD7091R_REG_RESULT or AD7091R_REG_ALERT. As the volatile ad7091r
registers happen to be the only read-only ones, the volatile_reg()
function now returns the negated output of writeable_reg().

Co-developed-by: Bruno Stephan <bruno.stephan@usp.br>
Signed-off-by: Bruno Stephan <bruno.stephan@usp.br>
Co-developed-by: Andre de Lima <aschwarz@usp.br>
Signed-off-by: Andre de Lima <aschwarz@usp.br>
Signed-off-by: Arthur Pilone <art.pilone@gmail.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Link: https://patch.msgid.link/20250421145534.91146-1-arthurpilone@usp.br
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Arthur Pilone and committed by
Jonathan Cameron
fc0b0e82 872c8014

+2 -7
+2 -7
drivers/iio/adc/ad7091r-base.c
··· 387 387 388 388 bool ad7091r_volatile_reg(struct device *dev, unsigned int reg) 389 389 { 390 - switch (reg) { 391 - case AD7091R_REG_RESULT: 392 - case AD7091R_REG_ALERT: 393 - return true; 394 - default: 395 - return false; 396 - } 390 + /* The volatile ad7091r registers are also the only RO ones. */ 391 + return !ad7091r_writeable_reg(dev, reg); 397 392 } 398 393 EXPORT_SYMBOL_NS_GPL(ad7091r_volatile_reg, "IIO_AD7091R"); 399 394