mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/8] iio: accel: kx022a: Use cleanup.h helpers
Date: Mon, 25 Nov 2024 11:34:36 +0200	[thread overview]
Message-ID: <bda7eaff-1315-46d0-83b4-a14060c2af1c@gmail.com> (raw)
In-Reply-To: <20241123164223.25656985@jic23-huawei>

Hello Jonathan,

Thanks again!

On 23/11/2024 18:42, Jonathan Cameron wrote:
> On Thu, 21 Nov 2024 10:20:23 +0200
> Matti Vaittinen <mazziesaccount@gmail.com> wrote:
> 
>> A few functions in KX022A need to use mutex for protecting the
>> enabling/disabling of the measurement while configurations are being
>> made. Some of the functions can be slightly simplified by using the
>> __cleanup based scoped mutexes, which allows dropping the goto based
>> unlocking at error path.
>>
>> Simplify error paths using guard(mutex).
>>
>> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
> Now we have guard(), the main reason (I think) for the
> combined on + lock and off + unlock paths is gone. So can
> we just flatten those and do the locking at caller.

I did consider this too :)

Why I decided to keep it as it is, (even though we need the extra 
mutex_unlock() at certain error path) is because I kind of like the 
lock+off and unlock+on functions. This locking does not protect data, 
but really a sequence of operations that needs to be done while sensor 
is OFF state. It's almost like a doc saying that "please, ensure the 
sensor is OFF for the following operations" :)

(Another thing is that we do claim the direct mode in write_raw, and 
goto is still handy for releasing it. Scoped guards won't play nicely 
with goto. Yes, we could probably use the __cleanup for direct mode, but 
I still like the lock+off, unlock+on for the reason above)

Yours,
	-- Matti

  reply	other threads:[~2024-11-25  9:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-21  8:19 [PATCH v2 0/8] Support ROHM KX134ACR-LBZ Matti Vaittinen
2024-11-21  8:19 ` [PATCH v2 1/8] iio: accel: kx022a: Improve reset delay Matti Vaittinen
2024-11-23 16:34   ` Jonathan Cameron
2024-11-21  8:20 ` [PATCH v2 2/8] iio: gts: Simplify using __free Matti Vaittinen
2024-11-23 16:37   ` Jonathan Cameron
2024-11-25  9:16     ` Matti Vaittinen
2024-11-26 17:52       ` Jonathan Cameron
2024-11-27 14:14         ` Matti Vaittinen
2024-11-21  8:20 ` [PATCH v2 3/8] iio: accel: kx022a: Use cleanup.h helpers Matti Vaittinen
2024-11-23 16:42   ` Jonathan Cameron
2024-11-25  9:34     ` Matti Vaittinen [this message]
2024-11-26 17:55       ` Jonathan Cameron
2024-11-27 13:54         ` Matti Vaittinen
2024-11-21  8:20 ` [PATCH v2 4/8] iio: accel: kx022a: Support ICs with different G-ranges Matti Vaittinen
2024-11-21  8:20 ` [PATCH v2 5/8] dt-bindings: ROHM KX134ACR-LBZ Matti Vaittinen
2024-11-21  8:21 ` [PATCH v2 6/8] iio: kx022a: Support " Matti Vaittinen
2024-11-21  8:21 ` [PATCH v2 7/8] dt-bindings: iio: kx022a: Support KX134-1211 Matti Vaittinen
2024-11-21 19:55   ` Conor Dooley
2024-11-21  8:21 ` [PATCH v2 8/8] iio: accel: " Matti Vaittinen
2024-11-23 16:43   ` 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=bda7eaff-1315-46d0-83b4-a14060c2af1c@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=robh@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

all inboxes | Powered by JetHome®