From: David Lechner <dlechner@baylibre.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"Frank Li" <Frank.Li@nxp.com>,
"Marek Vasut" <marek.vasut+renesas@gmail.com>,
linux-iio@vger.kernel.org, "Nuno Sá" <noname.nuno@gmail.com>
Cc: "Marek Vasut" <marex@denx.de>,
"Mike Looijmans" <mike.looijmans@topic.nl>,
"Nuno Sá" <nuno.sa@analog.com>,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v2 5/8] iio: adc: ti-ads1015: Use guard(mutex) and factor out code for INFO_RAW
Date: Mon, 10 Mar 2025 18:18:57 -0500 [thread overview]
Message-ID: <9cd23b18-f1a9-4222-aa6a-e1453f4bad88@baylibre.com> (raw)
In-Reply-To: <20250309165819.1346684-6-jic23@kernel.org>
On 3/9/25 11:58 AM, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> By use of automatic lock release and introducing a new utility
> function to handle the core activity of reading the ADC channel,
> many more complex code flows can be replaced by direct returns.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Marek Vasut <marex@denx.de>
> ---
...
> static int ads1015_read_event_config(struct iio_dev *indio_dev,
> @@ -710,25 +686,19 @@ static int ads1015_read_event_config(struct iio_dev *indio_dev,
> enum iio_event_direction dir)
> {
> struct ads1015_data *data = iio_priv(indio_dev);
> - int ret = 0;
>
> - mutex_lock(&data->lock);
> - if (data->event_channel == chan->address) {
> - switch (dir) {
> - case IIO_EV_DIR_RISING:
> - ret = 1;
> - break;
> - case IIO_EV_DIR_EITHER:
> - ret = (data->comp_mode == ADS1015_CFG_COMP_MODE_WINDOW);
> - break;
> - default:
> - ret = -EINVAL;
> - break;
> - }
> - }
> - mutex_unlock(&data->lock);
> + guard(mutex)(&data->lock);
> + if (data->event_channel != chan->address)
> + return -EBUSY;
The old code returned 0 in this case instead of -EBUSY, so this seems like an
unrelated or unintentional change.
>
> - return ret;
> + switch (dir) {
> + case IIO_EV_DIR_RISING:
> + return 1;
> + case IIO_EV_DIR_EITHER:
> + return (data->comp_mode == ADS1015_CFG_COMP_MODE_WINDOW);
> + default:
> + return -EINVAL;
> + }
> }
>
next prev parent reply other threads:[~2025-03-10 23:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-09 16:58 [PATCH v2 0/8] IIO: ADCs: Sparse friendly claim of direct mode Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 1/8] iio: adc: vf610: Move claim of direct mode to caller of vf610_read_sample and use guard(mutex) Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 2/8] iio: adc: vf610: Switch to sparse friendly iio_device_claim/release_direct() Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 3/8] iio: adc: ti-ads1100: Use guard(mutex) to allow direct returns Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 4/8] iio: adc: ti-ads1100: Switch to sparse friendly iio_device_claim/release_direct() Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 5/8] iio: adc: ti-ads1015: Use guard(mutex) and factor out code for INFO_RAW Jonathan Cameron
2025-03-10 23:18 ` David Lechner [this message]
2025-03-31 11:32 ` Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 6/8] iio: adc: ti-ads1015: Switch to sparse friendly iio_device_claim/release_direct() Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 7/8] iio: adc: mxs-lradc: " Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 8/8] iio: adc: rcar: " Jonathan Cameron
2025-03-10 23:21 ` [PATCH v2 0/8] IIO: ADCs: Sparse friendly claim of direct mode David Lechner
2025-03-31 11:33 ` 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=9cd23b18-f1a9-4222-aa6a-e1453f4bad88@baylibre.com \
--to=dlechner@baylibre.com \
--cc=Frank.Li@nxp.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=marek.vasut+renesas@gmail.com \
--cc=marex@denx.de \
--cc=mike.looijmans@topic.nl \
--cc=noname.nuno@gmail.com \
--cc=nuno.sa@analog.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