From: Arturas Moskvinas <arturas.moskvinas@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Jonathan.Cameron@huawei.com, oskar.andero@gmail.com,
lars@metafoo.de, lukas@wunner.de, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, arturas.moskvinas@gmail.com
Subject: Re: [PATCH] iio: adc: mcp320x: Simplify device removal logic
Date: Sun, 11 Feb 2024 17:36:49 +0200 [thread overview]
Message-ID: <0ddfb0ab-10e0-471c-97e1-63018884e4f7@gmail.com> (raw)
In-Reply-To: <20240210155857.59c58dcc@jic23-huawei>
On 2/10/24 17:58, Jonathan Cameron wrote:
>> Use devm_* APIs to enable regulator and to register in IIO infrastructure.
>>
>> Signed-off-by: Arturas Moskvinas <arturas.moskvinas@gmail.com>
>
> Don't get the same regulator twice so as automate turning it off.
> The devm_regulator_get_enable() call is carefully hiding the
> regulator for cases where the driver never accesses it.
>
> Here we need it to read the voltage.
>
> To convert such a case to fully devm managed, use a
> devm_add_action_or_reset() and a custom callback.
This is exactly the reason I wanted to use devm_regulator_get_enable()
instead of devm_add_action_or_reset + custom callback which I saw in
other ADCs code. It seems quite repetitive. Wondering if this could be
addressed by regulator subsystem to provide device managed method which
gets _enabled_ regulator resource and an automated disabling + resource
freeing? We will loose fine grained information where failure happened
exactly - getting resource or enabling regulator though...
>> static void mcp320x_remove(struct spi_device *spi)
>> {
>> - struct iio_dev *indio_dev = spi_get_drvdata(spi);
>> - struct mcp320x *adc = iio_priv(indio_dev);
>> -
>> - iio_device_unregister(indio_dev);
>> - regulator_disable(adc->reg);
>> }
> Had the change otherwise been ok...
>
> You should be able to remove this function completely now it is empty.
> https://elixir.bootlin.com/linux/latest/source/drivers/spi/spi.c#L446
> checks it's existence before calling it.
Ack, will address with V2 patch.
Arturas Moskvinas
prev parent reply other threads:[~2024-02-11 15:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-08 9:43 [PATCH] iio: adc: mcp320x: Simplify device removal logic Arturas Moskvinas
2024-02-10 15:58 ` Jonathan Cameron
2024-02-11 15:36 ` Arturas Moskvinas [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=0ddfb0ab-10e0-471c-97e1-63018884e4f7@gmail.com \
--to=arturas.moskvinas@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=oskar.andero@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