From: Arthur Pilone Date: Mon, 21 Apr 2025 14:55:34 +0000 (-0300) Subject: iio: adc: ad7091r-base: Remove duplicate code on volatile reg check X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=fc0b0e82260f3b93f63325a89b4e4e17737b1421;p=linux-2.6-microblaze.git 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 Signed-off-by: Bruno Stephan Co-developed-by: Andre de Lima Signed-off-by: Andre de Lima Signed-off-by: Arthur Pilone Reviewed-by: Marcelo Schmitt Link: https://patch.msgid.link/20250421145534.91146-1-arthurpilone@usp.br Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c index 931ff71b2888..647a7852dd8d 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -387,13 +387,8 @@ EXPORT_SYMBOL_NS_GPL(ad7091r_writeable_reg, "IIO_AD7091R"); bool ad7091r_volatile_reg(struct device *dev, unsigned int reg) { - switch (reg) { - case AD7091R_REG_RESULT: - case AD7091R_REG_ALERT: - return true; - default: - return false; - } + /* The volatile ad7091r registers are also the only RO ones. */ + return !ad7091r_writeable_reg(dev, reg); } EXPORT_SYMBOL_NS_GPL(ad7091r_volatile_reg, "IIO_AD7091R");