aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/usbhid/hid-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/usbhid/hid-core.c')
-rw-r--r--drivers/hid/usbhid/hid-core.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index d746bf8284dd..606369ea24ca 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -796,7 +796,6 @@ static int usbhid_start(struct hid_device *hid)
796 if (insize > HID_MAX_BUFFER_SIZE) 796 if (insize > HID_MAX_BUFFER_SIZE)
797 insize = HID_MAX_BUFFER_SIZE; 797 insize = HID_MAX_BUFFER_SIZE;
798 798
799 mutex_lock(&usbhid->setup);
800 if (hid_alloc_buffers(dev, hid)) { 799 if (hid_alloc_buffers(dev, hid)) {
801 ret = -ENOMEM; 800 ret = -ENOMEM;
802 goto fail; 801 goto fail;
@@ -876,7 +875,6 @@ static int usbhid_start(struct hid_device *hid)
876 hid_dump_device(hid); 875 hid_dump_device(hid);
877 876
878 set_bit(HID_STARTED, &usbhid->iofl); 877 set_bit(HID_STARTED, &usbhid->iofl);
879 mutex_unlock(&usbhid->setup);
880 878
881 return 0; 879 return 0;
882 880
@@ -888,7 +886,6 @@ fail:
888 usbhid->urbout = NULL; 886 usbhid->urbout = NULL;
889 usbhid->urbctrl = NULL; 887 usbhid->urbctrl = NULL;
890 hid_free_buffers(dev, hid); 888 hid_free_buffers(dev, hid);
891 mutex_unlock(&usbhid->setup);
892 return ret; 889 return ret;
893} 890}
894 891
@@ -899,7 +896,6 @@ static void usbhid_stop(struct hid_device *hid)
899 if (WARN_ON(!usbhid)) 896 if (WARN_ON(!usbhid))
900 return; 897 return;
901 898
902 mutex_lock(&usbhid->setup);
903 clear_bit(HID_STARTED, &usbhid->iofl); 899 clear_bit(HID_STARTED, &usbhid->iofl);
904 spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ 900 spin_lock_irq(&usbhid->inlock); /* Sync with error handler */
905 set_bit(HID_DISCONNECTED, &usbhid->iofl); 901 set_bit(HID_DISCONNECTED, &usbhid->iofl);
@@ -928,7 +924,6 @@ static void usbhid_stop(struct hid_device *hid)
928 usbhid->urbout = NULL; 924 usbhid->urbout = NULL;
929 925
930 hid_free_buffers(hid_to_usb_dev(hid), hid); 926 hid_free_buffers(hid_to_usb_dev(hid), hid);
931 mutex_unlock(&usbhid->setup);
932} 927}
933 928
934static struct hid_ll_driver usb_hid_driver = { 929static struct hid_ll_driver usb_hid_driver = {
@@ -1016,7 +1011,6 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
1016 1011
1017 hid->driver_data = usbhid; 1012 hid->driver_data = usbhid;
1018 usbhid->hid = hid; 1013 usbhid->hid = hid;
1019 mutex_init(&usbhid->setup); /* needed on suspend/resume */
1020 1014
1021 ret = hid_add_device(hid); 1015 ret = hid_add_device(hid);
1022 if (ret) { 1016 if (ret) {
@@ -1051,18 +1045,14 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
1051 struct hid_device *hid = usb_get_intfdata (intf); 1045 struct hid_device *hid = usb_get_intfdata (intf);
1052 struct usbhid_device *usbhid = hid->driver_data; 1046 struct usbhid_device *usbhid = hid->driver_data;
1053 1047
1054 mutex_lock(&usbhid->setup); 1048 if (!test_bit(HID_STARTED, &usbhid->iofl))
1055 if (!test_bit(HID_STARTED, &usbhid->iofl)) {
1056 mutex_unlock(&usbhid->setup);
1057 return 0; 1049 return 0;
1058 }
1059 1050
1060 spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ 1051 spin_lock_irq(&usbhid->inlock); /* Sync with error handler */
1061 set_bit(HID_SUSPENDED, &usbhid->iofl); 1052 set_bit(HID_SUSPENDED, &usbhid->iofl);
1062 spin_unlock_irq(&usbhid->inlock); 1053 spin_unlock_irq(&usbhid->inlock);
1063 del_timer_sync(&usbhid->io_retry); 1054 del_timer_sync(&usbhid->io_retry);
1064 usb_kill_urb(usbhid->urbin); 1055 usb_kill_urb(usbhid->urbin);
1065 mutex_unlock(&usbhid->setup);
1066 dev_dbg(&intf->dev, "suspend\n"); 1056 dev_dbg(&intf->dev, "suspend\n");
1067 return 0; 1057 return 0;
1068} 1058}
@@ -1073,16 +1063,12 @@ static int hid_resume(struct usb_interface *intf)
1073 struct usbhid_device *usbhid = hid->driver_data; 1063 struct usbhid_device *usbhid = hid->driver_data;
1074 int status; 1064 int status;
1075 1065
1076 mutex_lock(&usbhid->setup); 1066 if (!test_bit(HID_STARTED, &usbhid->iofl))
1077 if (!test_bit(HID_STARTED, &usbhid->iofl)) {
1078 mutex_unlock(&usbhid->setup);
1079 return 0; 1067 return 0;
1080 }
1081 1068
1082 clear_bit(HID_SUSPENDED, &usbhid->iofl); 1069 clear_bit(HID_SUSPENDED, &usbhid->iofl);
1083 usbhid->retry_delay = 0; 1070 usbhid->retry_delay = 0;
1084 status = hid_start_in(hid); 1071 status = hid_start_in(hid);
1085 mutex_unlock(&usbhid->setup);
1086 dev_dbg(&intf->dev, "resume status %d\n", status); 1072 dev_dbg(&intf->dev, "resume status %d\n", status);
1087 return status; 1073 return status;
1088} 1074}