Commit c8de9dbb authored by Frank Praznik's avatar Frank Praznik Committed by Jiri Kosina

HID: sony: Fix work queue issues

Only initialize force feedback for devices that actually support it (Sixaxis and
Dualshock 4) to prevent calls to schedule_work() with an uninitialized work
queue.

Move the cancel_work_sync() call out of sony_destroy_ff() since the state worker
is used for the LEDs even when force-feedback is disabled.

Remove the sony_destroy_ff() function since it is no longer used.
Signed-off-by: default avatarFrank Praznik <frank.praznik@oh.rr.com>
Reviewed-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent ad142b9e
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\ #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\
DUALSHOCK4_CONTROLLER) DUALSHOCK4_CONTROLLER)
#define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER) #define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER)
#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER)
#define MAX_LEDS 4 #define MAX_LEDS 4
...@@ -729,6 +730,7 @@ struct sony_sc { ...@@ -729,6 +730,7 @@ struct sony_sc {
__u8 right; __u8 right;
#endif #endif
__u8 worker_initialized;
__u8 cable_state; __u8 cable_state;
__u8 battery_charging; __u8 battery_charging;
__u8 battery_capacity; __u8 battery_capacity;
...@@ -1367,22 +1369,12 @@ static int sony_init_ff(struct hid_device *hdev) ...@@ -1367,22 +1369,12 @@ static int sony_init_ff(struct hid_device *hdev)
return input_ff_create_memless(input_dev, NULL, sony_play_effect); return input_ff_create_memless(input_dev, NULL, sony_play_effect);
} }
static void sony_destroy_ff(struct hid_device *hdev)
{
struct sony_sc *sc = hid_get_drvdata(hdev);
cancel_work_sync(&sc->state_worker);
}
#else #else
static int sony_init_ff(struct hid_device *hdev) static int sony_init_ff(struct hid_device *hdev)
{ {
return 0; return 0;
} }
static void sony_destroy_ff(struct hid_device *hdev)
{
}
#endif #endif
static int sony_battery_get_property(struct power_supply *psy, static int sony_battery_get_property(struct power_supply *psy,
...@@ -1535,9 +1527,11 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) ...@@ -1535,9 +1527,11 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
if (sc->quirks & SIXAXIS_CONTROLLER_USB) { if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
hdev->hid_output_raw_report = sixaxis_usb_output_raw_report; hdev->hid_output_raw_report = sixaxis_usb_output_raw_report;
ret = sixaxis_set_operational_usb(hdev); ret = sixaxis_set_operational_usb(hdev);
sc->worker_initialized = 1;
INIT_WORK(&sc->state_worker, sixaxis_state_worker); INIT_WORK(&sc->state_worker, sixaxis_state_worker);
} else if (sc->quirks & SIXAXIS_CONTROLLER_BT) { } else if (sc->quirks & SIXAXIS_CONTROLLER_BT) {
ret = sixaxis_set_operational_bt(hdev); ret = sixaxis_set_operational_bt(hdev);
sc->worker_initialized = 1;
INIT_WORK(&sc->state_worker, sixaxis_state_worker); INIT_WORK(&sc->state_worker, sixaxis_state_worker);
} else if (sc->quirks & DUALSHOCK4_CONTROLLER) { } else if (sc->quirks & DUALSHOCK4_CONTROLLER) {
if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) { if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) {
...@@ -1555,6 +1549,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) ...@@ -1555,6 +1549,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
if (ret < 0) if (ret < 0)
goto err_stop; goto err_stop;
sc->worker_initialized = 1;
INIT_WORK(&sc->state_worker, dualshock4_state_worker); INIT_WORK(&sc->state_worker, dualshock4_state_worker);
} else { } else {
ret = 0; ret = 0;
...@@ -1582,9 +1577,11 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) ...@@ -1582,9 +1577,11 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
} }
} }
ret = sony_init_ff(hdev); if (sc->quirks & SONY_FF_SUPPORT) {
if (ret < 0) ret = sony_init_ff(hdev);
goto err_close; if (ret < 0)
goto err_close;
}
return 0; return 0;
err_close: err_close:
...@@ -1594,6 +1591,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) ...@@ -1594,6 +1591,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
sony_leds_remove(hdev); sony_leds_remove(hdev);
if (sc->quirks & SONY_BATTERY_SUPPORT) if (sc->quirks & SONY_BATTERY_SUPPORT)
sony_battery_remove(sc); sony_battery_remove(sc);
if (sc->worker_initialized)
cancel_work_sync(&sc->state_worker);
hid_hw_stop(hdev); hid_hw_stop(hdev);
return ret; return ret;
} }
...@@ -1610,7 +1609,8 @@ static void sony_remove(struct hid_device *hdev) ...@@ -1610,7 +1609,8 @@ static void sony_remove(struct hid_device *hdev)
sony_battery_remove(sc); sony_battery_remove(sc);
} }
sony_destroy_ff(hdev); if (sc->worker_initialized)
cancel_work_sync(&sc->state_worker);
hid_hw_stop(hdev); hid_hw_stop(hdev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment