aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hid/hid-sony.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 26992e15d0e2..a51a9c0636be 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -51,6 +51,7 @@
51#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\ 51#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\
52 DUALSHOCK4_CONTROLLER) 52 DUALSHOCK4_CONTROLLER)
53#define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER) 53#define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER)
54#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER)
54 55
55#define MAX_LEDS 4 56#define MAX_LEDS 4
56 57
@@ -729,6 +730,7 @@ struct sony_sc {
729 __u8 right; 730 __u8 right;
730#endif 731#endif
731 732
733 __u8 worker_initialized;
732 __u8 cable_state; 734 __u8 cable_state;
733 __u8 battery_charging; 735 __u8 battery_charging;
734 __u8 battery_capacity; 736 __u8 battery_capacity;
@@ -1367,22 +1369,12 @@ static int sony_init_ff(struct hid_device *hdev)
1367 return input_ff_create_memless(input_dev, NULL, sony_play_effect); 1369 return input_ff_create_memless(input_dev, NULL, sony_play_effect);
1368} 1370}
1369 1371
1370static void sony_destroy_ff(struct hid_device *hdev)
1371{
1372 struct sony_sc *sc = hid_get_drvdata(hdev);
1373
1374 cancel_work_sync(&sc->state_worker);
1375}
1376
1377#else 1372#else
1378static int sony_init_ff(struct hid_device *hdev) 1373static int sony_init_ff(struct hid_device *hdev)
1379{ 1374{
1380 return 0; 1375 return 0;
1381} 1376}
1382 1377
1383static void sony_destroy_ff(struct hid_device *hdev)
1384{
1385}
1386#endif 1378#endif
1387 1379
1388static int sony_battery_get_property(struct power_supply *psy, 1380static 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 if (sc->quirks & SIXAXIS_CONTROLLER_USB) { 1527 if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
1536 hdev->hid_output_raw_report = sixaxis_usb_output_raw_report; 1528 hdev->hid_output_raw_report = sixaxis_usb_output_raw_report;
1537 ret = sixaxis_set_operational_usb(hdev); 1529 ret = sixaxis_set_operational_usb(hdev);
1530 sc->worker_initialized = 1;
1538 INIT_WORK(&sc->state_worker, sixaxis_state_worker); 1531 INIT_WORK(&sc->state_worker, sixaxis_state_worker);
1539 } else if (sc->quirks & SIXAXIS_CONTROLLER_BT) { 1532 } else if (sc->quirks & SIXAXIS_CONTROLLER_BT) {
1540 ret = sixaxis_set_operational_bt(hdev); 1533 ret = sixaxis_set_operational_bt(hdev);
1534 sc->worker_initialized = 1;
1541 INIT_WORK(&sc->state_worker, sixaxis_state_worker); 1535 INIT_WORK(&sc->state_worker, sixaxis_state_worker);
1542 } else if (sc->quirks & DUALSHOCK4_CONTROLLER) { 1536 } else if (sc->quirks & DUALSHOCK4_CONTROLLER) {
1543 if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) { 1537 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 if (ret < 0) 1549 if (ret < 0)
1556 goto err_stop; 1550 goto err_stop;
1557 1551
1552 sc->worker_initialized = 1;
1558 INIT_WORK(&sc->state_worker, dualshock4_state_worker); 1553 INIT_WORK(&sc->state_worker, dualshock4_state_worker);
1559 } else { 1554 } else {
1560 ret = 0; 1555 ret = 0;
@@ -1582,9 +1577,11 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
1582 } 1577 }
1583 } 1578 }
1584 1579
1585 ret = sony_init_ff(hdev); 1580 if (sc->quirks & SONY_FF_SUPPORT) {
1586 if (ret < 0) 1581 ret = sony_init_ff(hdev);
1587 goto err_close; 1582 if (ret < 0)
1583 goto err_close;
1584 }
1588 1585
1589 return 0; 1586 return 0;
1590err_close: 1587err_close:
@@ -1594,6 +1591,8 @@ err_stop:
1594 sony_leds_remove(hdev); 1591 sony_leds_remove(hdev);
1595 if (sc->quirks & SONY_BATTERY_SUPPORT) 1592 if (sc->quirks & SONY_BATTERY_SUPPORT)
1596 sony_battery_remove(sc); 1593 sony_battery_remove(sc);
1594 if (sc->worker_initialized)
1595 cancel_work_sync(&sc->state_worker);
1597 hid_hw_stop(hdev); 1596 hid_hw_stop(hdev);
1598 return ret; 1597 return ret;
1599} 1598}
@@ -1610,7 +1609,8 @@ static void sony_remove(struct hid_device *hdev)
1610 sony_battery_remove(sc); 1609 sony_battery_remove(sc);
1611 } 1610 }
1612 1611
1613 sony_destroy_ff(hdev); 1612 if (sc->worker_initialized)
1613 cancel_work_sync(&sc->state_worker);
1614 1614
1615 hid_hw_stop(hdev); 1615 hid_hw_stop(hdev);
1616} 1616}