From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Javier Carrasco <javier.carrasco.cruz@gmail.com>,
Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/2] iio: Use __cleanup for a few ROHM sensors
Date: Fri, 22 Nov 2024 08:10:08 +0200 [thread overview]
Message-ID: <37bba4fa-34c6-4b7c-ae65-75929213a8f2@gmail.com> (raw)
In-Reply-To: <2f321215-2ca3-4249-a9f0-427004c95d70@gmail.com>
Hi Javier,
On 21/11/2024 15:54, Javier Carrasco wrote:
> On 21/11/2024 14:04, Matti Vaittinen wrote:
>> Use __cleanup.
>>
>> The series converts the rest of the ROHM sensors (maintained by me) to
>> use guard(mutex). This simplifies the error paths.
>>
>> As a note, kx022a accelerometer driver is handled in another series,
>> which also adds support for two new accelerometers. I did also patch the
>> driver for the BU27008 and BU27010 - but when I was testing the changes
>> I found that the BU27008 status is set to "obsolete". I'll try to dig
>> some information about the BU27010 and decide if having the driver
>> in-tree is still worth the effort, or if I should just send out patches
>> to drop it all. Hence patch to rohm-bu27008.c is not included in the
>> series. If someone is actually using the BU27008 or BU27010 and wants
>> to patch it - feel free to pick
>> 131315de97ff ("iio: bu27008: simplify using guard(mutex)")
>> from
>> https://github.com/M-Vaittinen/linux/tree/bu27008-cleanup
>>
>> ---
>>
>> Matti Vaittinen (2):
>> iio: bu27034: simplify using guard(mutex)
>> iio: bm1390: simplify using guard(mutex)
>>
>> drivers/iio/light/rohm-bu27034.c | 73 ++++++++++------------------
>> drivers/iio/pressure/rohm-bm1390.c | 78 ++++++++++++------------------
>> 2 files changed, 55 insertions(+), 96 deletions(-)
>>
>>
>> base-commit: adc218676eef25575469234709c2d87185ca223a
>
> Hi Matti,
>
> Both patches look good to me, but I noticed that you kept a few
> mutex_lock() + mutex_unlock() in both drivers, in particular in the
> cases where a scoped_guard() could simplify the code. Did you leave
> those cases untouched on purpose?
Thanks for taking a look at the patches. Much appreciated :)
I remember leaving couple of direct calls to mutex_lock() and
mutex_unlock() - but I think I left them only to places where I saw no
real improvement by the use of guard() or scoped_guard(). It is likely I
considered the locking in these cases being trivial. (Probably only for
a duration of one or couple of function calls, with no error handling
when a lock is held). The direct mutex_lock()/mutex_unlock() has no real
room for usual errors (like leaving the function while lock was taken)
in such case.
For me,
mutex_lock();
ret = foo();
mutex_unlock();
is as clear as it gets. I don't think scoped_guard() has benefits there.
On the contrary, for me the scoped_guard() would be more complex and
less obvious :)
Yours,
-- Matti
next prev parent reply other threads:[~2024-11-22 6:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-21 13:04 [PATCH 0/2] iio: Use __cleanup for a few ROHM sensors Matti Vaittinen
2024-11-21 13:05 ` [PATCH 1/2] iio: bu27034: simplify using guard(mutex) Matti Vaittinen
2024-11-22 6:40 ` Javier Carrasco
2024-11-21 13:05 ` [PATCH 2/2] iio: bm1390: " Matti Vaittinen
2024-11-22 6:41 ` Javier Carrasco
2024-11-21 13:54 ` [PATCH 0/2] iio: Use __cleanup for a few ROHM sensors Javier Carrasco
2024-11-22 6:10 ` Matti Vaittinen [this message]
2024-11-22 6:40 ` Javier Carrasco
2024-11-23 16:46 ` 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=37bba4fa-34c6-4b7c-ae65-75929213a8f2@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.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