@@ -915,6 +915,15 @@ static struct shield_device *thunderstrike_create(struct hid_device *hdev)
915
915
return ERR_PTR (ret );
916
916
}
917
917
918
+ static void thunderstrike_destroy (struct thunderstrike * ts )
919
+ {
920
+ led_classdev_unregister (& ts -> led_dev );
921
+ power_supply_unregister (ts -> base .battery_dev .psy );
922
+ if (ts -> haptics_dev )
923
+ input_unregister_device (ts -> haptics_dev );
924
+ ida_free (& thunderstrike_ida , ts -> id );
925
+ }
926
+
918
927
static int android_input_mapping (struct hid_device * hdev , struct hid_input * hi ,
919
928
struct hid_field * field ,
920
929
struct hid_usage * usage , unsigned long * * bit ,
@@ -1074,11 +1083,7 @@ static int shield_probe(struct hid_device *hdev, const struct hid_device_id *id)
1074
1083
err_stop :
1075
1084
hid_hw_stop (hdev );
1076
1085
err_ts_create :
1077
- power_supply_unregister (ts -> base .battery_dev .psy );
1078
- if (ts -> haptics_dev )
1079
- input_unregister_device (ts -> haptics_dev );
1080
- led_classdev_unregister (& ts -> led_dev );
1081
- ida_free (& thunderstrike_ida , ts -> id );
1086
+ thunderstrike_destroy (ts );
1082
1087
return ret ;
1083
1088
}
1084
1089
@@ -1090,11 +1095,7 @@ static void shield_remove(struct hid_device *hdev)
1090
1095
ts = container_of (dev , struct thunderstrike , base );
1091
1096
1092
1097
hid_hw_close (hdev );
1093
- power_supply_unregister (dev -> battery_dev .psy );
1094
- if (ts -> haptics_dev )
1095
- input_unregister_device (ts -> haptics_dev );
1096
- led_classdev_unregister (& ts -> led_dev );
1097
- ida_free (& thunderstrike_ida , ts -> id );
1098
+ thunderstrike_destroy (ts );
1098
1099
del_timer_sync (& ts -> psy_stats_timer );
1099
1100
cancel_work_sync (& ts -> hostcmd_req_work );
1100
1101
hid_hw_stop (hdev );
0 commit comments