From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Vineet Thakran <vineet789thakran@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: light: tsl4531: Use device-managed cleanup in probe
Date: Thu, 3 Dec 2026 18:40:58 +0200 [thread overview]
Message-ID: <axGbmlFX08NTL2oD@ashevche-desk.local> (raw)
In-Reply-To: <20261201162217.111071-1-vineet789thakran@gmail.com>
On Tue, Dec 01, 2026 at 04:22:17PM +0000, Vineet Thakran wrote:
> The sensor is switched to normal mode during probe, but if a later step
> fails (writing the config register or registering the IIO device), probe
> returns an error and the sensor is left powered on, because remove() is
> not called for a failed probe.
>
> Register a devm action that powers down the sensor right after it is
> enabled, and use devm_iio_device_register(). This also lets the driver
> drop its remove() callback and the now unused i2c_set_clientdata() call,
> while keeping the same teardown order: unregister first, then power down.
>
> Compile-tested only; no hardware available.
...
> + ret = devm_add_action_or_reset(&client->dev, tsl4531_powerdown_action,
> + client);
With
struct device *dev = &client->dev;
at the top of the function this becomes
ret = devm_add_action_or_reset(dev, tsl4531_powerdown_action, client);
> + if (ret)
> + return ret;
...
> + return devm_iio_device_register(&client->dev, indio_dev);
And this respectively
return devm_iio_device_register(dev, indio_dev);
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-12-03 16:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 16:22 [PATCH] iio: light: tsl4531: Use device-managed cleanup in probe Vineet Thakran
2026-12-01 18:54 ` Arnav Kapoor
2026-12-03 16:40 ` 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=axGbmlFX08NTL2oD@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=vineet789thakran@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