From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Vaibhav Chahar <vaibhav.chahar26@gmail.com>
Cc: jic23@kernel.org, marius.cristea@microchip.com,
crofts@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
andy@kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] iio: adc: palmas_gpadc: Use guard(mutex) to manage locks
Date: Mon, 23 Nov 2026 21:10:00 +0200 [thread overview]
Message-ID: <awSPiGyelASPJUr5@ashevche-desk.local> (raw)
In-Reply-To: <20261123172836.130440-3-vaibhav.chahar26@gmail.com>
On Mon, Nov 23, 2026 at 10:58:36PM +0530, Vaibhav Chahar wrote:
> Use guard(mutex) instead of manual mutex_lock() and mutex_unlock()
> calls to modernize the driver and simplify error handling paths.
>
> In palmas_gpadc_read_raw(), moved palmas_gpadc_read_done() into the exit
> paths inside the switch block so the out: label can be removed while
> preserving hardware teardown before unlocking. In
> palmas_gpadc_write_event_value(), use direct returns instead of jumping
> to out_unlock: label.
A few similar issues as in previous patch, AR: study my review and act
accordingly.
...
> #include <linux/completion.h>
> +#include <linux/cleanup.h>
l is before o.
*yes, I see that the order is a mess.
> #include <linux/of.h>
> #include <linux/iio/events.h>
> #include <linux/iio/iio.h>
...
> ret = palmas_gpadc_read_prepare(adc, adc_chan);
> - if (ret < 0)
> - goto out;
> + if (ret < 0) {
> + palmas_gpadc_read_done(adc, adc_chan);
> + return ret;
> + }
>
> ret = palmas_gpadc_start_conversion(adc, adc_chan);
> if (ret < 0) {
> dev_err(adc->dev,
> "ADC start conversion failed\n");
> - goto out;
> + palmas_gpadc_read_done(adc, adc_chan);
> + return ret;
> }
Nope. In this case split out an inner part into a low-level helper
function and call it _locked() or _unlocked() (I don't remember by
heart what the correct one is in IIO for this case).
...
> default:
> ret = -EINVAL;
> - goto out_unlock;
> + return ret;
So, what's next obvious step?
> }
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-11-23 19:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 7:08 [PATCH] iio: adc: mcp3564: Use guard() and scoped_guard() to manage mutex Vaibhav Chahar
2026-11-23 15:22 ` Joshua Crofts
2026-11-23 17:28 ` [PATCH v2 0/2] iio: adc: Use cleanup.h guards for mutex locking Vaibhav Chahar
2026-11-23 17:28 ` [PATCH v2 1/2] iio: adc: mcp3564: Use guard() and scoped_guard() to manage mutex Vaibhav Chahar
2026-11-23 19:05 ` Andy Shevchenko
2026-11-23 17:28 ` [PATCH v2 2/2] iio: adc: palmas_gpadc: Use guard(mutex) to manage locks Vaibhav Chahar
2026-11-23 19:10 ` Andy Shevchenko [this message]
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=awSPiGyelASPJUr5@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=crofts@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marius.cristea@microchip.com \
--cc=nuno.sa@analog.com \
--cc=vaibhav.chahar26@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