From: Jonathan Cameron <jic23@kernel.org>
To: Sanjay Chitroda via B4 Relay
<devnull+sanjayembeddedse.gmail.com@kernel.org>
Cc: sanjayembeddedse@gmail.com,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Jiri Kosina" <jikos@kernel.org>,
"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
"Benjamin Tissoires" <bentiss@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-input@vger.kernel.org
Subject: Re: [PATCH v5 06/13] iio: humidity: hid-sensor-humidity: convert probe and teardown to devm-managed resources
Date: Sun, 16 Aug 2026 02:39:20 +0100 [thread overview]
Message-ID: <20260816023920.04f8c3bb@jic23-huawei> (raw)
In-Reply-To: <20260806-28-apr-iio-redundant-argument-v5-temp-v5-6-f1f92c1d830f@gmail.com>
On Thu, 06 Aug 2026 17:55:52 +0530
Sanjay Chitroda via B4 Relay <devnull+sanjayembeddedse.gmail.com@kernel.org> wrote:
> From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
>
> Convert HID IIO driver resource management to use devm-managed helpers,
> tying the lifetime of all resources to the device.
>
> HID trigger setup, IIO registration, and sensor hub callback resource
> are now managed using devm APIs. Cleanup logic previously handled
> explicitly in probe error and teardown paths.
>
> This simplifies the probe path by removing goto-based error handling,
> eliminates the remove callback entirely.
>
> Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
A passing comment inline.
> ---
> changes in v5:
> - Fully convert driver to devm usage, dropped Tested-by tag
> changes in v4:
> - No update in change, added Tested-by tag
> changes in v3:
> - Update commit message based on review comment from Andy
> - Based on discussion using parent device of HID platform driver used
> with devres framework for this driver
> - v2 link -> https://lore.kernel.org/all/20260429175918.2541914-5-sanjayembedded@gmail.com/
> ---
> drivers/iio/humidity/hid-sensor-humidity.c | 38 +++++++-----------------------
> 1 file changed, 8 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c
> index 89daf9d534d1..12c88efe66be 100644
> --- a/drivers/iio/humidity/hid-sensor-humidity.c
> +++ b/drivers/iio/humidity/hid-sensor-humidity.c
> @@ -192,11 +192,12 @@ static struct hid_sensor_hub_callbacks humidity_callbacks = {
> /* Function to initialize the processing for usage id */
> static int hid_humidity_probe(struct platform_device *pdev)
> {
> + struct device *dev = &pdev->dev;
> + struct hid_sensor_hub_device *hsdev = dev_get_platdata(dev);
> static const char *name = "humidity";
> struct iio_dev *indio_dev;
> struct hid_humidity_state *humid_st;
> struct iio_chan_spec *humid_chans;
> - struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev);
> int ret;
>
> indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*humid_st));
> @@ -233,42 +234,20 @@ static int hid_humidity_probe(struct platform_device *pdev)
>
> atomic_set(&humid_st->common_attributes.data_ready, 0);
>
> - ret = hid_sensor_setup_trigger(indio_dev, name,
> - &humid_st->common_attributes);
> + ret = devm_hid_sensor_setup_trigger(dev, indio_dev, name,
> + &humid_st->common_attributes);
> if (ret)
> return ret;
>
> platform_set_drvdata(pdev, indio_dev);
>
> humidity_callbacks.pdev = pdev;
> - ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_HUMIDITY,
> - &humidity_callbacks);
> + ret = devm_sensor_hub_register_callback(dev, hsdev, HID_USAGE_SENSOR_HUMIDITY,
> + &humidity_callbacks);
> if (ret)
> - goto error_remove_trigger;
> -
> - ret = iio_device_register(indio_dev);
> - if (ret)
> - goto error_remove_callback;
> -
> - return ret;
> -
> -error_remove_callback:
> - sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_HUMIDITY);
> -error_remove_trigger:
> - hid_sensor_remove_trigger(&humid_st->common_attributes);
> - return ret;
> -}
> -
> -/* Function to deinitialize the processing for usage id */
> -static void hid_humidity_remove(struct platform_device *pdev)
> -{
> - struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev);
> - struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> - struct hid_humidity_state *humid_st = iio_priv(indio_dev);
> + return ret;
This made me wonder what was different as we didn't have a random
ret on it's own in the other patch. Seems we have inconsistency
across the drivers on what we print on and what we don't.
If you do cleanup up the error prints either in this series
or a follow up, nice to make them consistent - either adding
messages or dropping them may make sense - I haven't thought much
about it!
Jonathan
>
> - iio_device_unregister(indio_dev);
> - sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_HUMIDITY);
> - hid_sensor_remove_trigger(&humid_st->common_attributes);
> + return devm_iio_device_register(dev, indio_dev);
> }
>
> static const struct platform_device_id hid_humidity_ids[] = {
> @@ -287,7 +266,6 @@ static struct platform_driver hid_humidity_platform_driver = {
> .pm = &hid_sensor_pm_ops,
> },
> .probe = hid_humidity_probe,
> - .remove = hid_humidity_remove,
> };
> module_platform_driver(hid_humidity_platform_driver);
>
>
next prev parent reply other threads:[~2026-08-16 1:39 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 12:25 [PATCH v5 00/13] HID: iio: Introduce devm_ APIs for HID sensors Sanjay Chitroda via B4 Relay
2026-08-06 12:25 ` [PATCH v5 01/13] iio: hid-sensors: remove unused iio_dev argument Sanjay Chitroda via B4 Relay
2026-08-06 12:37 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 02/13] iio: hid-sensors: introduce device managed API Sanjay Chitroda via B4 Relay
2026-08-06 12:25 ` [PATCH v5 03/13] HID: hid-sensor-hub: " Sanjay Chitroda via B4 Relay
2026-08-06 12:40 ` sashiko-bot
2026-08-08 20:10 ` Andy Shevchenko
2026-08-16 1:32 ` Jonathan Cameron
2026-08-06 12:25 ` [PATCH v5 04/13] iio: gyro: hid-sensor-gyro-3d: convert probe and teardown to devm-managed resources Sanjay Chitroda via B4 Relay
2026-08-06 12:40 ` sashiko-bot
2026-08-16 1:36 ` Jonathan Cameron
2026-08-06 12:25 ` [PATCH v5 05/13] iio: accel: hid-sensor-accel-3d: " Sanjay Chitroda via B4 Relay
2026-08-06 12:39 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 06/13] iio: humidity: hid-sensor-humidity: " Sanjay Chitroda via B4 Relay
2026-08-06 12:36 ` sashiko-bot
2026-08-16 1:39 ` Jonathan Cameron [this message]
2026-08-06 12:25 ` [PATCH v5 07/13] iio: light: hid-sensor-prox: " Sanjay Chitroda via B4 Relay
2026-08-06 12:39 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 08/13] iio: light: hid-sensor-als: " Sanjay Chitroda via B4 Relay
2026-08-06 12:40 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 09/13] iio: magnetometer: hid-sensor-magn-3d: " Sanjay Chitroda via B4 Relay
2026-08-06 12:25 ` [PATCH v5 10/13] iio: orientation: hid-sensor-incl-3d: " Sanjay Chitroda via B4 Relay
2026-08-06 12:25 ` [PATCH v5 11/13] iio: orientation: hid-sensor-rotation: " Sanjay Chitroda via B4 Relay
2026-08-06 12:40 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 12/13] iio: position: hid-sensor-custom-intel-hinge: " Sanjay Chitroda via B4 Relay
2026-08-06 12:48 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 13/13] iio: pressure: hid-sensor-press: " Sanjay Chitroda via B4 Relay
2026-08-06 12:44 ` sashiko-bot
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=20260816023920.04f8c3bb@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=bentiss@kernel.org \
--cc=devnull+sanjayembeddedse.gmail.com@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jikos@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=sanjayembeddedse@gmail.com \
--cc=srinivas.pandruvada@linux.intel.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