diff options
| -rw-r--r-- | drivers/hid/hid-sony.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 12354055d474..2f19b15f47f2 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c | |||
| @@ -42,6 +42,7 @@ | |||
| 42 | #define DUALSHOCK4_CONTROLLER_BT BIT(6) | 42 | #define DUALSHOCK4_CONTROLLER_BT BIT(6) |
| 43 | 43 | ||
| 44 | #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER_USB | BUZZ_CONTROLLER | DUALSHOCK4_CONTROLLER_USB) | 44 | #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER_USB | BUZZ_CONTROLLER | DUALSHOCK4_CONTROLLER_USB) |
| 45 | #define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER_USB | DUALSHOCK4_CONTROLLER_USB) | ||
| 45 | 46 | ||
| 46 | #define MAX_LEDS 4 | 47 | #define MAX_LEDS 4 |
| 47 | 48 | ||
| @@ -499,6 +500,7 @@ struct sony_sc { | |||
| 499 | __u8 right; | 500 | __u8 right; |
| 500 | #endif | 501 | #endif |
| 501 | 502 | ||
| 503 | __u8 worker_initialized; | ||
| 502 | __u8 led_state[MAX_LEDS]; | 504 | __u8 led_state[MAX_LEDS]; |
| 503 | __u8 led_count; | 505 | __u8 led_count; |
| 504 | }; | 506 | }; |
| @@ -993,22 +995,11 @@ static int sony_init_ff(struct hid_device *hdev) | |||
| 993 | return input_ff_create_memless(input_dev, NULL, sony_play_effect); | 995 | return input_ff_create_memless(input_dev, NULL, sony_play_effect); |
| 994 | } | 996 | } |
| 995 | 997 | ||
| 996 | static void sony_destroy_ff(struct hid_device *hdev) | ||
| 997 | { | ||
| 998 | struct sony_sc *sc = hid_get_drvdata(hdev); | ||
| 999 | |||
| 1000 | cancel_work_sync(&sc->state_worker); | ||
| 1001 | } | ||
| 1002 | |||
| 1003 | #else | 998 | #else |
| 1004 | static int sony_init_ff(struct hid_device *hdev) | 999 | static int sony_init_ff(struct hid_device *hdev) |
| 1005 | { | 1000 | { |
| 1006 | return 0; | 1001 | return 0; |
| 1007 | } | 1002 | } |
| 1008 | |||
| 1009 | static void sony_destroy_ff(struct hid_device *hdev) | ||
| 1010 | { | ||
| 1011 | } | ||
| 1012 | #endif | 1003 | #endif |
| 1013 | 1004 | ||
| 1014 | static int sony_set_output_report(struct sony_sc *sc, int req_id, int req_size) | 1005 | static int sony_set_output_report(struct sony_sc *sc, int req_id, int req_size) |
| @@ -1077,6 +1068,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 1077 | if (sc->quirks & SIXAXIS_CONTROLLER_USB) { | 1068 | if (sc->quirks & SIXAXIS_CONTROLLER_USB) { |
| 1078 | hdev->hid_output_raw_report = sixaxis_usb_output_raw_report; | 1069 | hdev->hid_output_raw_report = sixaxis_usb_output_raw_report; |
| 1079 | ret = sixaxis_set_operational_usb(hdev); | 1070 | ret = sixaxis_set_operational_usb(hdev); |
| 1071 | |||
| 1072 | sc->worker_initialized = 1; | ||
| 1080 | INIT_WORK(&sc->state_worker, sixaxis_state_worker); | 1073 | INIT_WORK(&sc->state_worker, sixaxis_state_worker); |
| 1081 | } | 1074 | } |
| 1082 | else if (sc->quirks & SIXAXIS_CONTROLLER_BT) | 1075 | else if (sc->quirks & SIXAXIS_CONTROLLER_BT) |
| @@ -1087,6 +1080,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 1087 | if (ret < 0) | 1080 | if (ret < 0) |
| 1088 | goto err_stop; | 1081 | goto err_stop; |
| 1089 | 1082 | ||
| 1083 | sc->worker_initialized = 1; | ||
| 1090 | INIT_WORK(&sc->state_worker, dualshock4_state_worker); | 1084 | INIT_WORK(&sc->state_worker, dualshock4_state_worker); |
| 1091 | } else { | 1085 | } else { |
| 1092 | ret = 0; | 1086 | ret = 0; |
| @@ -1101,9 +1095,11 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 1101 | goto err_stop; | 1095 | goto err_stop; |
| 1102 | } | 1096 | } |
| 1103 | 1097 | ||
| 1104 | ret = sony_init_ff(hdev); | 1098 | if (sc->quirks & SONY_FF_SUPPORT) { |
| 1105 | if (ret < 0) | 1099 | ret = sony_init_ff(hdev); |
| 1106 | goto err_stop; | 1100 | if (ret < 0) |
| 1101 | goto err_stop; | ||
| 1102 | } | ||
| 1107 | 1103 | ||
| 1108 | return 0; | 1104 | return 0; |
| 1109 | err_stop: | 1105 | err_stop: |
| @@ -1120,7 +1116,8 @@ static void sony_remove(struct hid_device *hdev) | |||
| 1120 | if (sc->quirks & SONY_LED_SUPPORT) | 1116 | if (sc->quirks & SONY_LED_SUPPORT) |
| 1121 | sony_leds_remove(hdev); | 1117 | sony_leds_remove(hdev); |
| 1122 | 1118 | ||
| 1123 | sony_destroy_ff(hdev); | 1119 | if (sc->worker_initialized) |
| 1120 | cancel_work_sync(&sc->state_worker); | ||
| 1124 | 1121 | ||
| 1125 | hid_hw_stop(hdev); | 1122 | hid_hw_stop(hdev); |
| 1126 | } | 1123 | } |
