Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Fernando Yang <hagisf@usp.br>
Cc: linux-iio@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Eduardo Figueredo <eduardofp@usp.br>,
	Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Subject: Re: [PATCH v3 2/3] iio: adc: ad7266: Use iio_device_claim_direct_scoped()
Date: Sat, 15 Jun 2024 11:56:04 +0100	[thread overview]
Message-ID: <20240615115604.26789693@jic23-huawei> (raw)
In-Reply-To: <20240613153920.14647-3-hagisf@usp.br>

On Thu, 13 Jun 2024 12:39:19 -0300
Fernando Yang <hagisf@usp.br> wrote:

> Switching to the _scoped() version can make the error handling more
> natural instead of delayed until direct mode was released.
> 
> Signed-off-by: Fernando Yang <hagisf@usp.br>
> ---
>  drivers/iio/adc/ad7266.c | 27 +++++++++++++--------------
>  1 file changed, 13 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
> index 13ea8a107..356c2fe07 100644
> --- a/drivers/iio/adc/ad7266.c
> +++ b/drivers/iio/adc/ad7266.c
> @@ -151,20 +151,19 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
>  
>  	switch (m) {
>  	case IIO_CHAN_INFO_RAW:
> -		ret = iio_device_claim_direct_mode(indio_dev);
> -		if (ret)
> -			return ret;
> -		ret = ad7266_read_single(st, val, chan->address);
> -		iio_device_release_direct_mode(indio_dev);
> -
> -		if (ret < 0)
> -			return ret;
> -		*val = (*val >> 2) & 0xfff;
> -		if (chan->scan_type.sign == 's')
> -			*val = sign_extend32(*val,
> -					     chan->scan_type.realbits - 1);
> -
> -		return IIO_VAL_INT;
> +		iio_device_claim_direct_scoped(return -EBUSY, indio_dev) {
> +			ret = ad7266_read_single(st, val, chan->address);
> +			
Seems to be some stray white space (tabs) on the line above.
Make sure to run checkpatch.pl.

Also reformat this to bring call and error condition together.
		iio_device_claim_direct_scoped(return -EBUSY, indio_dev) {
			ret = ad7266_read_single(st, val, chan->address);
			if (ret < 0)
				return ret;

			*val = ...

> +			if (ret < 0)
> +				return ret;
> +			*val = (*val >> 2) & 0xfff;
> +			if (chan->scan_type.sign == 's')
> +				*val = sign_extend32(*val,
> +							 chan->scan_type.realbits - 1);
> +
This doesn't look like a correct indent.  Align c with * as done in the original code
> +			return IIO_VAL_INT;
> +		}
> +		unreachable();
>  	case IIO_CHAN_INFO_SCALE:
>  		scale_mv = st->vref_mv;
>  		if (st->mode == AD7266_MODE_DIFF)


  reply	other threads:[~2024-06-15 10:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 15:39 [PATCH v3 0/3] iio: adc: ad7266: Use iio_device_claim_direct_scoped() and clean some codestyle error Fernando Yang
2024-06-13 15:39 ` [PATCH v3 1/3] iio: adc: ad7266: Fix variable checking bug Fernando Yang
2024-06-15 10:52   ` Jonathan Cameron
2024-06-13 15:39 ` [PATCH v3 2/3] iio: adc: ad7266: Use iio_device_claim_direct_scoped() Fernando Yang
2024-06-15 10:56   ` Jonathan Cameron [this message]
2024-06-13 15:39 ` [PATCH v3 3/3] iio: adc: ad7266: Fix codestyle error Fernando Yang
2024-06-15 10:56   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240615115604.26789693@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=eduardofp@usp.br \
    --cc=hagisf@usp.br \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=marcelo.schmitt1@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox