This series fixes some missing clean-up function calls in the error handling of
the probe.
Patch 1 and 2 fix some similar issues introduced in 2 different commits (hence 2
patches)
Patch 3 is an enhancement that creates a common function for cleaning up
thunderstrike instances.
Changes:
v1->v2:
- Add the LED_RETAIN_AT_SHUTDOWN flag to prevent
led_classdev_unregister from trying to set the LED to off before a
successful call to hid_hw_start.
- Rename err_haptics label to err_ts_create to make the label name more
accurate.
- Re-order operations in thunderstrike_destroy to be in LIFO order with
regards to the operations in thunderstrike_create.
Link: https://lore.kernel.org/linux-input/[email protected]/
Notes from Rahul:
- Thank you so much Christophe for these patches.
Christophe JAILLET (3):
HID: nvidia-shield: Fix a missing led_classdev_unregister() in the
probe error handling path
HID: nvidia-shield: Fix some missing function calls() in the probe
error handling path
HID: nvidia-shield: Introduce thunderstrike_destroy()
drivers/hid/hid-nvidia-shield.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
--
2.40.1
From: Christophe JAILLET <[email protected]>
The commit in Fixes updated the error handling path of
thunderstrike_create() and the remove function but not the error handling
path of shield_probe(), should an error occur after a successful
thunderstrike_create() call.
Add the missing calls.
Fixes: 3ab196f88237 ("HID: nvidia-shield: Add battery support for Thunderstrike")
Signed-off-by: Christophe JAILLET <[email protected]>
Reviewed-by: Rahul Rameshbabu <[email protected]>
---
Notes:
Changes:
v1->v2:
- Rename err_haptics label to err_ts_create to make the label name more
accurate.
drivers/hid/hid-nvidia-shield.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-nvidia-shield.c b/drivers/hid/hid-nvidia-shield.c
index c144641452d3..a566f9cdc97d 100644
--- a/drivers/hid/hid-nvidia-shield.c
+++ b/drivers/hid/hid-nvidia-shield.c
@@ -1058,7 +1058,7 @@ static int shield_probe(struct hid_device *hdev, const struct hid_device_id *id)
ret = hid_hw_start(hdev, HID_CONNECT_HIDINPUT);
if (ret) {
hid_err(hdev, "Failed to start HID device\n");
- goto err_haptics;
+ goto err_ts_create;
}
ret = hid_hw_open(hdev);
@@ -1073,10 +1073,12 @@ static int shield_probe(struct hid_device *hdev, const struct hid_device_id *id)
err_stop:
hid_hw_stop(hdev);
-err_haptics:
+err_ts_create:
+ power_supply_unregister(ts->base.battery_dev.psy);
if (ts->haptics_dev)
input_unregister_device(ts->haptics_dev);
led_classdev_unregister(&ts->led_dev);
+ ida_free(&thunderstrike_ida, ts->id);
return ret;
}
--
2.40.1