From: Jonathan Cameron <jic23@kernel.org>
To: Jorge Harrisonn <jorge.harrisonn@usp.br>
Cc: lars@metafoo.de, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, laisnuto@usp.br
Subject: Re: [PATCH 1/2] iio: adc: ad7606: using claim_direct_scoped for code simplification
Date: Sat, 4 May 2024 12:34:43 +0100 [thread overview]
Message-ID: <20240504123443.46949690@jic23-huawei> (raw)
In-Reply-To: <20240501215724.26655-2-jorge.harrisonn@usp.br>
On Wed, 1 May 2024 18:57:23 -0300
Jorge Harrisonn <jorge.harrisonn@usp.br> wrote:
> Using iio_device_claim_direct_scoped instead of calling `iio_device
> _claim_direct_modeand later callingiio_device_release_direct_mode`
>
> This should make code cleaner and error handling easier
>
> Co-authored-by: Lais Nuto <laisnuto@usp.br>
> Signed-off-by: Lais Nuto <laisnuto@usp.br>
> Signed-off-by: Jorge Harrisonn <jorge.harrisonn@usp.br>
> ---
> drivers/iio/adc/ad7606.c | 19 ++++++++-----------
> 1 file changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index 1928d9ae5bcf..fa989e0d7e70 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -174,17 +174,14 @@ static int ad7606_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 = ad7606_scan_direct(indio_dev, chan->address);
> - iio_device_release_direct_mode(indio_dev);
> -
> - if (ret < 0)
> - return ret;
> - *val = (short)ret;
> - return IIO_VAL_INT;
> + iio_device_claim_direct_scoped(return -EBUSY, indio_dev) {
> + ret = ad7606_scan_direct(indio_dev, chan->address);
> + if (ret < 0)
There is a stray space on the line above after the )
Make sure to run checkpatch.pl which should have caught this
> + return ret;
> + *val = (short) ret;
Not really part of your patch so I'll leave it alone, but that cast seems rather
pointless.
Applied to the togreg branch of iio.git and pushed out as testing with the
white space above fixed. Note I'll be rebasing that tree after the
merge window so until then this will only be visible on the testing
branch.
Thanks,
Jonathan
> + return IIO_VAL_INT;
> + }
> + unreachable();
> case IIO_CHAN_INFO_SCALE:
> if (st->sw_mode_en)
> ch = chan->address;
next prev parent reply other threads:[~2024-05-04 11:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-01 21:57 [PATCH 0/2] Use of `claim_direct_scoped` for improved error handling Jorge Harrisonn
2024-05-01 21:57 ` [PATCH 1/2] iio: adc: ad7606: using claim_direct_scoped for code simplification Jorge Harrisonn
2024-05-04 11:34 ` Jonathan Cameron [this message]
2024-05-04 16:08 ` Markus Elfring
2024-05-01 21:57 ` [PATCH 2/2] iio: adc: ad7923: " Jorge Harrisonn
2024-05-04 11:38 ` 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=20240504123443.46949690@jic23-huawei \
--to=jic23@kernel.org \
--cc=jorge.harrisonn@usp.br \
--cc=laisnuto@usp.br \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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