Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: adc: adc7266: Use iio_device_claim_direct_scoped()
@ 2024-05-08 15:54 Fernando Yang
  2024-05-11  4:16 ` Marcelo Schmitt
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Fernando Yang @ 2024-05-08 15:54 UTC (permalink / raw)
  To: linux-iio
  Cc: Fernando Yang, Lars-Peter Clausen, Michael Hennerich,
	Jonathan Cameron, Eduardo Figueredo

Switching to the _scoped() version can make the error
handling more natural instead of delayed until direct
mode was released.

Co-developed-by: Eduardo Figueredo <eduardofp@usp.br>
Signed-off-by: Eduardo Figueredo <eduardofp@usp.br>
Signed-off-by: Fernando Yang <hagisf@usp.br>
---
 drivers/iio/adc/ad7266.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
index 8b03d4469..3fc34a3a8 100644
--- a/drivers/iio/adc/ad7266.c
+++ b/drivers/iio/adc/ad7266.c
@@ -63,12 +63,14 @@ static int ad7266_powerdown(struct ad7266_state *st)
 static int ad7266_preenable(struct iio_dev *indio_dev)
 {
 	struct ad7266_state *st = iio_priv(indio_dev);
+
 	return ad7266_wakeup(st);
 }
 
 static int ad7266_postdisable(struct iio_dev *indio_dev)
 {
 	struct ad7266_state *st = iio_priv(indio_dev);
+
 	return ad7266_powerdown(st);
 }
 
@@ -151,15 +153,16 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
 
 	switch (m) {
 	case IIO_CHAN_INFO_RAW:
-		iio_device_claim_direct_scoped(return -EBUSY, indio_dev)
+		iio_device_claim_direct_scoped(return -EBUSY, indio_dev) {
 			ret = ad7266_read_single(st, val, chan->address);
 
-		*val = (*val >> 2) & 0xfff;
-		if (chan->scan_type.sign == 's')
-			*val = sign_extend32(*val,
-						 chan->scan_type.realbits - 1);
+			*val = (*val >> 2) & 0xfff;
+			if (chan->scan_type.sign == 's')
+				*val = sign_extend32(*val,
+							 chan->scan_type.realbits - 1);
 
-		return IIO_VAL_INT;
+			return IIO_VAL_INT;
+		}
 		unreachable();
 	case IIO_CHAN_INFO_SCALE:
 		scale_mv = st->vref_mv;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-06-08 14:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-08 15:54 [PATCH] iio: adc: adc7266: Use iio_device_claim_direct_scoped() Fernando Yang
2024-05-11  4:16 ` Marcelo Schmitt
2024-05-11 13:30 ` Jonathan Cameron
2024-06-03 18:07 ` [PATCH v2 1/3] iio: adc: ad7266: Fix variable checking bug Fernando Yang
2024-06-03 18:07   ` [PATCH v2 2/3] iio: adc: ad7266: Use iio_device_claim_direct_scoped() Fernando Yang
2024-06-08  5:21     ` Marcelo Schmitt
2024-06-03 18:07   ` [PATCH v2 3/3] iio: adc: ad7266: Fix codestyle error Fernando Yang
2024-06-08  5:29     ` Marcelo Schmitt
2024-06-08  5:06   ` [PATCH v2 1/3] iio: adc: ad7266: Fix variable checking bug Marcelo Schmitt
2024-06-08 14:11     ` Jonathan Cameron
2024-06-08 14:41   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox