@@ -915,6 +915,15 @@ static struct shield_device *thunderstrike_create(struct hid_device *hdev)
915915 return ERR_PTR (ret );
916916}
917917
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+
918927static int android_input_mapping (struct hid_device * hdev , struct hid_input * hi ,
919928 struct hid_field * field ,
920929 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)
10741083err_stop :
10751084 hid_hw_stop (hdev );
10761085err_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 );
10821087 return ret ;
10831088}
10841089
@@ -1090,11 +1095,7 @@ static void shield_remove(struct hid_device *hdev)
10901095 ts = container_of (dev , struct thunderstrike , base );
10911096
10921097 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 );
10981099 del_timer_sync (& ts -> psy_stats_timer );
10991100 cancel_work_sync (& ts -> hostcmd_req_work );
11001101 hid_hw_stop (hdev );
0 commit comments