aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorFrank Praznik <frank.praznik@oh.rr.com>2014-04-14 10:11:31 -0400
committerJiri Kosina <jkosina@suse.cz>2014-04-24 12:53:11 -0400
commit46262047434394b81d4aec81401eed894886ed5b (patch)
tree01825d542c4dace77ff8f30430d30605525b73f3 /drivers/hid
parentb81fd5ba6002306f0c2bf82514b2eeae6ee2bf32 (diff)
HID: sony: Use inliners for work queue initialization and cancellation
Use inliners to make sure that the work queue initialization flag is always checked and set correctly when initializing or cancelling the work queue. Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-sony.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 908de2789219..243209c4dcaf 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -1578,6 +1578,20 @@ static int sony_check_add(struct sony_sc *sc)
1578 return sony_check_add_dev_list(sc); 1578 return sony_check_add_dev_list(sc);
1579} 1579}
1580 1580
1581static inline void sony_init_work(struct sony_sc *sc,
1582 void (*worker)(struct work_struct *))
1583{
1584 if (!sc->worker_initialized)
1585 INIT_WORK(&sc->state_worker, worker);
1586
1587 sc->worker_initialized = 1;
1588}
1589
1590static inline void sony_cancel_work_sync(struct sony_sc *sc)
1591{
1592 if (sc->worker_initialized)
1593 cancel_work_sync(&sc->state_worker);
1594}
1581 1595
1582static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) 1596static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
1583{ 1597{
@@ -1629,8 +1643,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
1629 hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP; 1643 hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP;
1630 hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID; 1644 hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID;
1631 ret = sixaxis_set_operational_usb(hdev); 1645 ret = sixaxis_set_operational_usb(hdev);
1632 sc->worker_initialized = 1; 1646 sony_init_work(sc, sixaxis_state_worker);
1633 INIT_WORK(&sc->state_worker, sixaxis_state_worker);
1634 } else if (sc->quirks & SIXAXIS_CONTROLLER_BT) { 1647 } else if (sc->quirks & SIXAXIS_CONTROLLER_BT) {
1635 /* 1648 /*
1636 * The Sixaxis wants output reports sent on the ctrl endpoint 1649 * The Sixaxis wants output reports sent on the ctrl endpoint
@@ -1638,8 +1651,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
1638 */ 1651 */
1639 hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP; 1652 hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP;
1640 ret = sixaxis_set_operational_bt(hdev); 1653 ret = sixaxis_set_operational_bt(hdev);
1641 sc->worker_initialized = 1; 1654 sony_init_work(sc, sixaxis_state_worker);
1642 INIT_WORK(&sc->state_worker, sixaxis_state_worker);
1643 } else if (sc->quirks & DUALSHOCK4_CONTROLLER) { 1655 } else if (sc->quirks & DUALSHOCK4_CONTROLLER) {
1644 if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) { 1656 if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) {
1645 /* 1657 /*
@@ -1661,8 +1673,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
1661 if (ret < 0) 1673 if (ret < 0)
1662 goto err_stop; 1674 goto err_stop;
1663 1675
1664 sc->worker_initialized = 1; 1676 sony_init_work(sc, dualshock4_state_worker);
1665 INIT_WORK(&sc->state_worker, dualshock4_state_worker);
1666 } else { 1677 } else {
1667 ret = 0; 1678 ret = 0;
1668 } 1679 }
@@ -1707,8 +1718,7 @@ err_stop:
1707 sony_leds_remove(hdev); 1718 sony_leds_remove(hdev);
1708 if (sc->quirks & SONY_BATTERY_SUPPORT) 1719 if (sc->quirks & SONY_BATTERY_SUPPORT)
1709 sony_battery_remove(sc); 1720 sony_battery_remove(sc);
1710 if (sc->worker_initialized) 1721 sony_cancel_work_sync(sc);
1711 cancel_work_sync(&sc->state_worker);
1712 sony_remove_dev_list(sc); 1722 sony_remove_dev_list(sc);
1713 hid_hw_stop(hdev); 1723 hid_hw_stop(hdev);
1714 return ret; 1724 return ret;
@@ -1726,8 +1736,7 @@ static void sony_remove(struct hid_device *hdev)
1726 sony_battery_remove(sc); 1736 sony_battery_remove(sc);
1727 } 1737 }
1728 1738
1729 if (sc->worker_initialized) 1739 sony_cancel_work_sync(sc);
1730 cancel_work_sync(&sc->state_worker);
1731 1740
1732 sony_remove_dev_list(sc); 1741 sony_remove_dev_list(sc);
1733 1742