[PATCH v5 12/13] iio: position: hid-sensor-custom-intel-hinge: convert probe and teardown to devm-managed resources
Sanjay Chitroda via B4 Relay <[email protected]> Thu, 06 Aug 2026 17:55:58 +0530
| Newsgroups | org.kernel.vger.linux-input,org.kernel.feeds.b4-sent,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260806-28-apr-iio-redundant-argument-v5-temp-v5-12-f1f92c1d830f@gmail.com> |
From: Sanjay Chitroda <[email protected]> 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 <[email protected]> --- .../iio/position/hid-sensor-custom-intel-hinge.c | 38 ++++------------------ 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/drivers/iio/position/hid-sensor-custom-intel-hinge.c b/drivers/iio/position/hid-sensor-custom-intel-hinge.c index 7f6186fea004..101d84b533c9 100644 --- a/drivers/iio/position/hid-sensor-custom-intel-hinge.c +++ b/drivers/iio/position/hid-sensor-custom-intel-hinge.c @@ -263,7 +263,8 @@ static int hinge_parse_report(struct platform_device *pdev, /* Function to initialize the processing for usage id */ static int hid_hinge_probe(struct platform_device *pdev) { - struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev); + struct device *dev = &pdev->dev; + struct hid_sensor_hub_device *hsdev = dev_get_platdata(dev); struct hinge_state *st; struct iio_dev *indio_dev; int ret; @@ -310,8 +311,8 @@ static int hid_hinge_probe(struct platform_device *pdev) indio_dev->modes = INDIO_DIRECT_MODE; atomic_set(&st->common_attributes.data_ready, 0); - ret = hid_sensor_setup_trigger(indio_dev, indio_dev->name, - &st->common_attributes); + ret = devm_hid_sensor_setup_trigger(dev, indio_dev, indio_dev->name, + &st->common_attributes); if (ret < 0) { dev_err(&pdev->dev, "trigger setup failed\n"); return ret; @@ -320,37 +321,13 @@ static int hid_hinge_probe(struct platform_device *pdev) st->callbacks.send_event = hinge_proc_event; st->callbacks.capture_sample = hinge_capture_sample; st->callbacks.pdev = pdev; - ret = sensor_hub_register_callback(hsdev, hsdev->usage, &st->callbacks); + ret = devm_sensor_hub_register_callback(dev, hsdev, hsdev->usage, &st->callbacks); if (ret < 0) { dev_err(&pdev->dev, "callback reg failed\n"); - goto error_remove_trigger; - } - - ret = iio_device_register(indio_dev); - if (ret) { - dev_err(&pdev->dev, "device register failed\n"); - goto error_remove_callback; + return ret; } - return ret; - -error_remove_callback: - sensor_hub_remove_callback(hsdev, hsdev->usage); -error_remove_trigger: - hid_sensor_remove_trigger(&st->common_attributes); - return ret; -} - -/* Function to deinitialize the processing for usage id */ -static void hid_hinge_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 hinge_state *st = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - sensor_hub_remove_callback(hsdev, hsdev->usage); - hid_sensor_remove_trigger(&st->common_attributes); + return devm_iio_device_register(dev, indio_dev); } static const struct platform_device_id hid_hinge_ids[] = { @@ -369,7 +346,6 @@ static struct platform_driver hid_hinge_platform_driver = { .pm = &hid_sensor_pm_ops, }, .probe = hid_hinge_probe, - .remove = hid_hinge_remove, }; module_platform_driver(hid_hinge_platform_driver); -- 2.34.1