diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-04-02 00:08:05 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-04-02 00:08:05 -0500 |
commit | 95d465fd750897ab32462a6702fbfe1b122cbbc0 (patch) | |
tree | 65c38b2f11c51bb6932e44dd6c92f15b0091abfe /drivers/usb/input | |
parent | 642fde17dceceb56c7ba2762733ac688666ae657 (diff) | |
parent | 683aa4012f53b2ada0f430487e05d37b0d94e90a (diff) |
Manual merge with Linus.
Conflicts:
arch/powerpc/kernel/setup-common.c
drivers/input/keyboard/hil_kbd.c
drivers/input/mouse/hil_ptr.c
Diffstat (limited to 'drivers/usb/input')
-rw-r--r-- | drivers/usb/input/ati_remote.c | 2 | ||||
-rw-r--r-- | drivers/usb/input/hid-core.c | 177 | ||||
-rw-r--r-- | drivers/usb/input/hid-lgff.c | 6 | ||||
-rw-r--r-- | drivers/usb/input/hid-tmff.c | 3 | ||||
-rw-r--r-- | drivers/usb/input/hid.h | 10 | ||||
-rw-r--r-- | drivers/usb/input/hiddev.c | 6 |
6 files changed, 157 insertions, 47 deletions
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index f7bdc506e613..99f986cb6e95 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c | |||
@@ -159,8 +159,6 @@ static const char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; | |||
159 | */ | 159 | */ |
160 | #define FILTER_TIME (HZ / 20) | 160 | #define FILTER_TIME (HZ / 20) |
161 | 161 | ||
162 | static DECLARE_MUTEX(disconnect_sem); | ||
163 | |||
164 | struct ati_remote { | 162 | struct ati_remote { |
165 | struct input_dev *idev; | 163 | struct input_dev *idev; |
166 | struct usb_device *udev; | 164 | struct usb_device *udev; |
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 07a012f88772..d4bf1701046b 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
@@ -66,9 +66,8 @@ static struct hid_report *hid_register_report(struct hid_device *device, unsigne | |||
66 | if (report_enum->report_id_hash[id]) | 66 | if (report_enum->report_id_hash[id]) |
67 | return report_enum->report_id_hash[id]; | 67 | return report_enum->report_id_hash[id]; |
68 | 68 | ||
69 | if (!(report = kmalloc(sizeof(struct hid_report), GFP_KERNEL))) | 69 | if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL))) |
70 | return NULL; | 70 | return NULL; |
71 | memset(report, 0, sizeof(struct hid_report)); | ||
72 | 71 | ||
73 | if (id != 0) | 72 | if (id != 0) |
74 | report_enum->numbered = 1; | 73 | report_enum->numbered = 1; |
@@ -97,12 +96,9 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned | |||
97 | return NULL; | 96 | return NULL; |
98 | } | 97 | } |
99 | 98 | ||
100 | if (!(field = kmalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage) | 99 | if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage) |
101 | + values * sizeof(unsigned), GFP_KERNEL))) return NULL; | 100 | + values * sizeof(unsigned), GFP_KERNEL))) return NULL; |
102 | 101 | ||
103 | memset(field, 0, sizeof(struct hid_field) + usages * sizeof(struct hid_usage) | ||
104 | + values * sizeof(unsigned)); | ||
105 | |||
106 | field->index = report->maxfield++; | 102 | field->index = report->maxfield++; |
107 | report->field[field->index] = field; | 103 | report->field[field->index] = field; |
108 | field->usage = (struct hid_usage *)(field + 1); | 104 | field->usage = (struct hid_usage *)(field + 1); |
@@ -651,17 +647,14 @@ static struct hid_device *hid_parse_report(__u8 *start, unsigned size) | |||
651 | hid_parser_reserved | 647 | hid_parser_reserved |
652 | }; | 648 | }; |
653 | 649 | ||
654 | if (!(device = kmalloc(sizeof(struct hid_device), GFP_KERNEL))) | 650 | if (!(device = kzalloc(sizeof(struct hid_device), GFP_KERNEL))) |
655 | return NULL; | 651 | return NULL; |
656 | memset(device, 0, sizeof(struct hid_device)); | ||
657 | 652 | ||
658 | if (!(device->collection = kmalloc(sizeof(struct hid_collection) * | 653 | if (!(device->collection = kzalloc(sizeof(struct hid_collection) * |
659 | HID_DEFAULT_NUM_COLLECTIONS, GFP_KERNEL))) { | 654 | HID_DEFAULT_NUM_COLLECTIONS, GFP_KERNEL))) { |
660 | kfree(device); | 655 | kfree(device); |
661 | return NULL; | 656 | return NULL; |
662 | } | 657 | } |
663 | memset(device->collection, 0, sizeof(struct hid_collection) * | ||
664 | HID_DEFAULT_NUM_COLLECTIONS); | ||
665 | device->collection_size = HID_DEFAULT_NUM_COLLECTIONS; | 658 | device->collection_size = HID_DEFAULT_NUM_COLLECTIONS; |
666 | 659 | ||
667 | for (i = 0; i < HID_REPORT_TYPES; i++) | 660 | for (i = 0; i < HID_REPORT_TYPES; i++) |
@@ -675,13 +668,12 @@ static struct hid_device *hid_parse_report(__u8 *start, unsigned size) | |||
675 | memcpy(device->rdesc, start, size); | 668 | memcpy(device->rdesc, start, size); |
676 | device->rsize = size; | 669 | device->rsize = size; |
677 | 670 | ||
678 | if (!(parser = kmalloc(sizeof(struct hid_parser), GFP_KERNEL))) { | 671 | if (!(parser = kzalloc(sizeof(struct hid_parser), GFP_KERNEL))) { |
679 | kfree(device->rdesc); | 672 | kfree(device->rdesc); |
680 | kfree(device->collection); | 673 | kfree(device->collection); |
681 | kfree(device); | 674 | kfree(device); |
682 | return NULL; | 675 | return NULL; |
683 | } | 676 | } |
684 | memset(parser, 0, sizeof(struct hid_parser)); | ||
685 | parser->device = device; | 677 | parser->device = device; |
686 | 678 | ||
687 | end = start + size; | 679 | end = start + size; |
@@ -911,6 +903,99 @@ static int hid_input_report(int type, struct urb *urb, int interrupt, struct pt_ | |||
911 | } | 903 | } |
912 | 904 | ||
913 | /* | 905 | /* |
906 | * Input submission and I/O error handler. | ||
907 | */ | ||
908 | |||
909 | static void hid_io_error(struct hid_device *hid); | ||
910 | |||
911 | /* Start up the input URB */ | ||
912 | static int hid_start_in(struct hid_device *hid) | ||
913 | { | ||
914 | unsigned long flags; | ||
915 | int rc = 0; | ||
916 | |||
917 | spin_lock_irqsave(&hid->inlock, flags); | ||
918 | if (hid->open > 0 && !test_bit(HID_SUSPENDED, &hid->iofl) && | ||
919 | !test_and_set_bit(HID_IN_RUNNING, &hid->iofl)) { | ||
920 | rc = usb_submit_urb(hid->urbin, GFP_ATOMIC); | ||
921 | if (rc != 0) | ||
922 | clear_bit(HID_IN_RUNNING, &hid->iofl); | ||
923 | } | ||
924 | spin_unlock_irqrestore(&hid->inlock, flags); | ||
925 | return rc; | ||
926 | } | ||
927 | |||
928 | /* I/O retry timer routine */ | ||
929 | static void hid_retry_timeout(unsigned long _hid) | ||
930 | { | ||
931 | struct hid_device *hid = (struct hid_device *) _hid; | ||
932 | |||
933 | dev_dbg(&hid->intf->dev, "retrying intr urb\n"); | ||
934 | if (hid_start_in(hid)) | ||
935 | hid_io_error(hid); | ||
936 | } | ||
937 | |||
938 | /* Workqueue routine to reset the device */ | ||
939 | static void hid_reset(void *_hid) | ||
940 | { | ||
941 | struct hid_device *hid = (struct hid_device *) _hid; | ||
942 | int rc_lock, rc; | ||
943 | |||
944 | dev_dbg(&hid->intf->dev, "resetting device\n"); | ||
945 | rc = rc_lock = usb_lock_device_for_reset(hid->dev, hid->intf); | ||
946 | if (rc_lock >= 0) { | ||
947 | rc = usb_reset_device(hid->dev); | ||
948 | if (rc_lock) | ||
949 | usb_unlock_device(hid->dev); | ||
950 | } | ||
951 | clear_bit(HID_RESET_PENDING, &hid->iofl); | ||
952 | |||
953 | if (rc == 0) { | ||
954 | hid->retry_delay = 0; | ||
955 | if (hid_start_in(hid)) | ||
956 | hid_io_error(hid); | ||
957 | } else if (!(rc == -ENODEV || rc == -EHOSTUNREACH || rc == -EINTR)) | ||
958 | err("can't reset device, %s-%s/input%d, status %d", | ||
959 | hid->dev->bus->bus_name, | ||
960 | hid->dev->devpath, | ||
961 | hid->ifnum, rc); | ||
962 | } | ||
963 | |||
964 | /* Main I/O error handler */ | ||
965 | static void hid_io_error(struct hid_device *hid) | ||
966 | { | ||
967 | unsigned long flags; | ||
968 | |||
969 | spin_lock_irqsave(&hid->inlock, flags); | ||
970 | |||
971 | /* Stop when disconnected */ | ||
972 | if (usb_get_intfdata(hid->intf) == NULL) | ||
973 | goto done; | ||
974 | |||
975 | /* When an error occurs, retry at increasing intervals */ | ||
976 | if (hid->retry_delay == 0) { | ||
977 | hid->retry_delay = 13; /* Then 26, 52, 104, 104, ... */ | ||
978 | hid->stop_retry = jiffies + msecs_to_jiffies(1000); | ||
979 | } else if (hid->retry_delay < 100) | ||
980 | hid->retry_delay *= 2; | ||
981 | |||
982 | if (time_after(jiffies, hid->stop_retry)) { | ||
983 | |||
984 | /* Retries failed, so do a port reset */ | ||
985 | if (!test_and_set_bit(HID_RESET_PENDING, &hid->iofl)) { | ||
986 | if (schedule_work(&hid->reset_work)) | ||
987 | goto done; | ||
988 | clear_bit(HID_RESET_PENDING, &hid->iofl); | ||
989 | } | ||
990 | } | ||
991 | |||
992 | mod_timer(&hid->io_retry, | ||
993 | jiffies + msecs_to_jiffies(hid->retry_delay)); | ||
994 | done: | ||
995 | spin_unlock_irqrestore(&hid->inlock, flags); | ||
996 | } | ||
997 | |||
998 | /* | ||
914 | * Input interrupt completion handler. | 999 | * Input interrupt completion handler. |
915 | */ | 1000 | */ |
916 | 1001 | ||
@@ -921,25 +1006,35 @@ static void hid_irq_in(struct urb *urb, struct pt_regs *regs) | |||
921 | 1006 | ||
922 | switch (urb->status) { | 1007 | switch (urb->status) { |
923 | case 0: /* success */ | 1008 | case 0: /* success */ |
1009 | hid->retry_delay = 0; | ||
924 | hid_input_report(HID_INPUT_REPORT, urb, 1, regs); | 1010 | hid_input_report(HID_INPUT_REPORT, urb, 1, regs); |
925 | break; | 1011 | break; |
926 | case -ECONNRESET: /* unlink */ | 1012 | case -ECONNRESET: /* unlink */ |
927 | case -ENOENT: | 1013 | case -ENOENT: |
928 | case -EPERM: | ||
929 | case -ESHUTDOWN: /* unplug */ | 1014 | case -ESHUTDOWN: /* unplug */ |
930 | case -EILSEQ: /* unplug timeout on uhci */ | 1015 | clear_bit(HID_IN_RUNNING, &hid->iofl); |
931 | return; | 1016 | return; |
1017 | case -EILSEQ: /* protocol error or unplug */ | ||
1018 | case -EPROTO: /* protocol error or unplug */ | ||
932 | case -ETIMEDOUT: /* NAK */ | 1019 | case -ETIMEDOUT: /* NAK */ |
933 | break; | 1020 | clear_bit(HID_IN_RUNNING, &hid->iofl); |
1021 | hid_io_error(hid); | ||
1022 | return; | ||
934 | default: /* error */ | 1023 | default: /* error */ |
935 | warn("input irq status %d received", urb->status); | 1024 | warn("input irq status %d received", urb->status); |
936 | } | 1025 | } |
937 | 1026 | ||
938 | status = usb_submit_urb(urb, SLAB_ATOMIC); | 1027 | status = usb_submit_urb(urb, SLAB_ATOMIC); |
939 | if (status) | 1028 | if (status) { |
940 | err("can't resubmit intr, %s-%s/input%d, status %d", | 1029 | clear_bit(HID_IN_RUNNING, &hid->iofl); |
941 | hid->dev->bus->bus_name, hid->dev->devpath, | 1030 | if (status != -EPERM) { |
942 | hid->ifnum, status); | 1031 | err("can't resubmit intr, %s-%s/input%d, status %d", |
1032 | hid->dev->bus->bus_name, | ||
1033 | hid->dev->devpath, | ||
1034 | hid->ifnum, status); | ||
1035 | hid_io_error(hid); | ||
1036 | } | ||
1037 | } | ||
943 | } | 1038 | } |
944 | 1039 | ||
945 | /* | 1040 | /* |
@@ -1101,8 +1196,9 @@ static void hid_irq_out(struct urb *urb, struct pt_regs *regs) | |||
1101 | case 0: /* success */ | 1196 | case 0: /* success */ |
1102 | break; | 1197 | break; |
1103 | case -ESHUTDOWN: /* unplug */ | 1198 | case -ESHUTDOWN: /* unplug */ |
1104 | case -EILSEQ: /* unplug timeout on uhci */ | ||
1105 | unplug = 1; | 1199 | unplug = 1; |
1200 | case -EILSEQ: /* protocol error or unplug */ | ||
1201 | case -EPROTO: /* protocol error or unplug */ | ||
1106 | case -ECONNRESET: /* unlink */ | 1202 | case -ECONNRESET: /* unlink */ |
1107 | case -ENOENT: | 1203 | case -ENOENT: |
1108 | break; | 1204 | break; |
@@ -1119,7 +1215,7 @@ static void hid_irq_out(struct urb *urb, struct pt_regs *regs) | |||
1119 | 1215 | ||
1120 | if (hid->outhead != hid->outtail) { | 1216 | if (hid->outhead != hid->outtail) { |
1121 | if (hid_submit_out(hid)) { | 1217 | if (hid_submit_out(hid)) { |
1122 | clear_bit(HID_OUT_RUNNING, &hid->iofl);; | 1218 | clear_bit(HID_OUT_RUNNING, &hid->iofl); |
1123 | wake_up(&hid->wait); | 1219 | wake_up(&hid->wait); |
1124 | } | 1220 | } |
1125 | spin_unlock_irqrestore(&hid->outlock, flags); | 1221 | spin_unlock_irqrestore(&hid->outlock, flags); |
@@ -1149,8 +1245,9 @@ static void hid_ctrl(struct urb *urb, struct pt_regs *regs) | |||
1149 | hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs); | 1245 | hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs); |
1150 | break; | 1246 | break; |
1151 | case -ESHUTDOWN: /* unplug */ | 1247 | case -ESHUTDOWN: /* unplug */ |
1152 | case -EILSEQ: /* unplug timectrl on uhci */ | ||
1153 | unplug = 1; | 1248 | unplug = 1; |
1249 | case -EILSEQ: /* protocol error or unplug */ | ||
1250 | case -EPROTO: /* protocol error or unplug */ | ||
1154 | case -ECONNRESET: /* unlink */ | 1251 | case -ECONNRESET: /* unlink */ |
1155 | case -ENOENT: | 1252 | case -ENOENT: |
1156 | case -EPIPE: /* report not available */ | 1253 | case -EPIPE: /* report not available */ |
@@ -1263,14 +1360,9 @@ static int hid_get_class_descriptor(struct usb_device *dev, int ifnum, | |||
1263 | 1360 | ||
1264 | int hid_open(struct hid_device *hid) | 1361 | int hid_open(struct hid_device *hid) |
1265 | { | 1362 | { |
1266 | if (hid->open++) | 1363 | ++hid->open; |
1267 | return 0; | 1364 | if (hid_start_in(hid)) |
1268 | 1365 | hid_io_error(hid); | |
1269 | hid->urbin->dev = hid->dev; | ||
1270 | |||
1271 | if (usb_submit_urb(hid->urbin, GFP_KERNEL)) | ||
1272 | return -EIO; | ||
1273 | |||
1274 | return 0; | 1366 | return 0; |
1275 | } | 1367 | } |
1276 | 1368 | ||
@@ -1460,6 +1552,9 @@ void hid_init_reports(struct hid_device *hid) | |||
1460 | #define USB_VENDOR_ID_HP 0x03f0 | 1552 | #define USB_VENDOR_ID_HP 0x03f0 |
1461 | #define USB_DEVICE_ID_HP_USBHUB_KB 0x020c | 1553 | #define USB_DEVICE_ID_HP_USBHUB_KB 0x020c |
1462 | 1554 | ||
1555 | #define USB_VENDOR_ID_CREATIVELABS 0x062a | ||
1556 | #define USB_DEVICE_ID_CREATIVELABS_SILVERCREST 0x0201 | ||
1557 | |||
1463 | /* | 1558 | /* |
1464 | * Alphabetically sorted blacklist by quirk type. | 1559 | * Alphabetically sorted blacklist by quirk type. |
1465 | */ | 1560 | */ |
@@ -1576,6 +1671,7 @@ static const struct hid_blacklist { | |||
1576 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, | 1671 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, |
1577 | { USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_KEYBOARD, HID_QUIRK_NOGET}, | 1672 | { USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_KEYBOARD, HID_QUIRK_NOGET}, |
1578 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET}, | 1673 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET}, |
1674 | { USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_CREATIVELABS_SILVERCREST, HID_QUIRK_NOGET }, | ||
1579 | { USB_VENDOR_ID_HP, USB_DEVICE_ID_HP_USBHUB_KB, HID_QUIRK_NOGET }, | 1675 | { USB_VENDOR_ID_HP, USB_DEVICE_ID_HP_USBHUB_KB, HID_QUIRK_NOGET }, |
1580 | { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET }, | 1676 | { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET }, |
1581 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, | 1677 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, |
@@ -1795,6 +1891,10 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1795 | 1891 | ||
1796 | init_waitqueue_head(&hid->wait); | 1892 | init_waitqueue_head(&hid->wait); |
1797 | 1893 | ||
1894 | INIT_WORK(&hid->reset_work, hid_reset, hid); | ||
1895 | setup_timer(&hid->io_retry, hid_retry_timeout, (unsigned long) hid); | ||
1896 | |||
1897 | spin_lock_init(&hid->inlock); | ||
1798 | spin_lock_init(&hid->outlock); | 1898 | spin_lock_init(&hid->outlock); |
1799 | spin_lock_init(&hid->ctrllock); | 1899 | spin_lock_init(&hid->ctrllock); |
1800 | 1900 | ||
@@ -1863,11 +1963,16 @@ static void hid_disconnect(struct usb_interface *intf) | |||
1863 | if (!hid) | 1963 | if (!hid) |
1864 | return; | 1964 | return; |
1865 | 1965 | ||
1966 | spin_lock_irq(&hid->inlock); /* Sync with error handler */ | ||
1866 | usb_set_intfdata(intf, NULL); | 1967 | usb_set_intfdata(intf, NULL); |
1968 | spin_unlock_irq(&hid->inlock); | ||
1867 | usb_kill_urb(hid->urbin); | 1969 | usb_kill_urb(hid->urbin); |
1868 | usb_kill_urb(hid->urbout); | 1970 | usb_kill_urb(hid->urbout); |
1869 | usb_kill_urb(hid->urbctrl); | 1971 | usb_kill_urb(hid->urbctrl); |
1870 | 1972 | ||
1973 | del_timer_sync(&hid->io_retry); | ||
1974 | flush_scheduled_work(); | ||
1975 | |||
1871 | if (hid->claimed & HID_CLAIMED_INPUT) | 1976 | if (hid->claimed & HID_CLAIMED_INPUT) |
1872 | hidinput_disconnect(hid); | 1977 | hidinput_disconnect(hid); |
1873 | if (hid->claimed & HID_CLAIMED_HIDDEV) | 1978 | if (hid->claimed & HID_CLAIMED_HIDDEV) |
@@ -1942,6 +2047,10 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message) | |||
1942 | { | 2047 | { |
1943 | struct hid_device *hid = usb_get_intfdata (intf); | 2048 | struct hid_device *hid = usb_get_intfdata (intf); |
1944 | 2049 | ||
2050 | spin_lock_irq(&hid->inlock); /* Sync with error handler */ | ||
2051 | set_bit(HID_SUSPENDED, &hid->iofl); | ||
2052 | spin_unlock_irq(&hid->inlock); | ||
2053 | del_timer(&hid->io_retry); | ||
1945 | usb_kill_urb(hid->urbin); | 2054 | usb_kill_urb(hid->urbin); |
1946 | dev_dbg(&intf->dev, "suspend\n"); | 2055 | dev_dbg(&intf->dev, "suspend\n"); |
1947 | return 0; | 2056 | return 0; |
@@ -1952,10 +2061,8 @@ static int hid_resume(struct usb_interface *intf) | |||
1952 | struct hid_device *hid = usb_get_intfdata (intf); | 2061 | struct hid_device *hid = usb_get_intfdata (intf); |
1953 | int status; | 2062 | int status; |
1954 | 2063 | ||
1955 | if (hid->open) | 2064 | clear_bit(HID_SUSPENDED, &hid->iofl); |
1956 | status = usb_submit_urb(hid->urbin, GFP_NOIO); | 2065 | status = hid_start_in(hid); |
1957 | else | ||
1958 | status = 0; | ||
1959 | dev_dbg(&intf->dev, "resume status %d\n", status); | 2066 | dev_dbg(&intf->dev, "resume status %d\n", status); |
1960 | return status; | 2067 | return status; |
1961 | } | 2068 | } |
diff --git a/drivers/usb/input/hid-lgff.c b/drivers/usb/input/hid-lgff.c index f82c9c9e5d51..f07d44357ff1 100644 --- a/drivers/usb/input/hid-lgff.c +++ b/drivers/usb/input/hid-lgff.c | |||
@@ -154,10 +154,9 @@ int hid_lgff_init(struct hid_device* hid) | |||
154 | return -1; | 154 | return -1; |
155 | } | 155 | } |
156 | 156 | ||
157 | private = kmalloc(sizeof(struct lgff_device), GFP_KERNEL); | 157 | private = kzalloc(sizeof(struct lgff_device), GFP_KERNEL); |
158 | if (!private) | 158 | if (!private) |
159 | return -1; | 159 | return -1; |
160 | memset(private, 0, sizeof(struct lgff_device)); | ||
161 | hid->ff_private = private; | 160 | hid->ff_private = private; |
162 | 161 | ||
163 | /* Input init */ | 162 | /* Input init */ |
@@ -228,13 +227,12 @@ static struct hid_report* hid_lgff_duplicate_report(struct hid_report* report) | |||
228 | } | 227 | } |
229 | *ret->field[0] = *report->field[0]; | 228 | *ret->field[0] = *report->field[0]; |
230 | 229 | ||
231 | ret->field[0]->value = kmalloc(sizeof(s32[8]), GFP_KERNEL); | 230 | ret->field[0]->value = kzalloc(sizeof(s32[8]), GFP_KERNEL); |
232 | if (!ret->field[0]->value) { | 231 | if (!ret->field[0]->value) { |
233 | kfree(ret->field[0]); | 232 | kfree(ret->field[0]); |
234 | kfree(ret); | 233 | kfree(ret); |
235 | return NULL; | 234 | return NULL; |
236 | } | 235 | } |
237 | memset(ret->field[0]->value, 0, sizeof(s32[8])); | ||
238 | 236 | ||
239 | return ret; | 237 | return ret; |
240 | } | 238 | } |
diff --git a/drivers/usb/input/hid-tmff.c b/drivers/usb/input/hid-tmff.c index 023fd5ac31c8..534425c69c0a 100644 --- a/drivers/usb/input/hid-tmff.c +++ b/drivers/usb/input/hid-tmff.c | |||
@@ -113,11 +113,10 @@ int hid_tmff_init(struct hid_device *hid) | |||
113 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | 113 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
114 | struct input_dev *input_dev = hidinput->input; | 114 | struct input_dev *input_dev = hidinput->input; |
115 | 115 | ||
116 | private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL); | 116 | private = kzalloc(sizeof(struct tmff_device), GFP_KERNEL); |
117 | if (!private) | 117 | if (!private) |
118 | return -ENOMEM; | 118 | return -ENOMEM; |
119 | 119 | ||
120 | memset(private, 0, sizeof(struct tmff_device)); | ||
121 | hid->ff_private = private; | 120 | hid->ff_private = private; |
122 | 121 | ||
123 | /* Find the report to use */ | 122 | /* Find the report to use */ |
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index 8b0d4346ce9c..4e1b784fe527 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h | |||
@@ -31,6 +31,8 @@ | |||
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/list.h> | 33 | #include <linux/list.h> |
34 | #include <linux/timer.h> | ||
35 | #include <linux/workqueue.h> | ||
34 | 36 | ||
35 | /* | 37 | /* |
36 | * USB HID (Human Interface Device) interface class code | 38 | * USB HID (Human Interface Device) interface class code |
@@ -370,6 +372,9 @@ struct hid_control_fifo { | |||
370 | 372 | ||
371 | #define HID_CTRL_RUNNING 1 | 373 | #define HID_CTRL_RUNNING 1 |
372 | #define HID_OUT_RUNNING 2 | 374 | #define HID_OUT_RUNNING 2 |
375 | #define HID_IN_RUNNING 3 | ||
376 | #define HID_RESET_PENDING 4 | ||
377 | #define HID_SUSPENDED 5 | ||
373 | 378 | ||
374 | struct hid_input { | 379 | struct hid_input { |
375 | struct list_head list; | 380 | struct list_head list; |
@@ -393,12 +398,17 @@ struct hid_device { /* device report descriptor */ | |||
393 | int ifnum; /* USB interface number */ | 398 | int ifnum; /* USB interface number */ |
394 | 399 | ||
395 | unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ | 400 | unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ |
401 | struct timer_list io_retry; /* Retry timer */ | ||
402 | unsigned long stop_retry; /* Time to give up, in jiffies */ | ||
403 | unsigned int retry_delay; /* Delay length in ms */ | ||
404 | struct work_struct reset_work; /* Task context for resets */ | ||
396 | 405 | ||
397 | unsigned int bufsize; /* URB buffer size */ | 406 | unsigned int bufsize; /* URB buffer size */ |
398 | 407 | ||
399 | struct urb *urbin; /* Input URB */ | 408 | struct urb *urbin; /* Input URB */ |
400 | char *inbuf; /* Input buffer */ | 409 | char *inbuf; /* Input buffer */ |
401 | dma_addr_t inbuf_dma; /* Input buffer dma */ | 410 | dma_addr_t inbuf_dma; /* Input buffer dma */ |
411 | spinlock_t inlock; /* Input fifo spinlock */ | ||
402 | 412 | ||
403 | struct urb *urbctrl; /* Control URB */ | 413 | struct urb *urbctrl; /* Control URB */ |
404 | struct usb_ctrlrequest *cr; /* Control request struct */ | 414 | struct usb_ctrlrequest *cr; /* Control request struct */ |
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index 925f5aba06f5..6dd666696178 100644 --- a/drivers/usb/input/hiddev.c +++ b/drivers/usb/input/hiddev.c | |||
@@ -257,9 +257,8 @@ static int hiddev_open(struct inode * inode, struct file * file) { | |||
257 | if (i >= HIDDEV_MINORS || !hiddev_table[i]) | 257 | if (i >= HIDDEV_MINORS || !hiddev_table[i]) |
258 | return -ENODEV; | 258 | return -ENODEV; |
259 | 259 | ||
260 | if (!(list = kmalloc(sizeof(struct hiddev_list), GFP_KERNEL))) | 260 | if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL))) |
261 | return -ENOMEM; | 261 | return -ENOMEM; |
262 | memset(list, 0, sizeof(struct hiddev_list)); | ||
263 | 262 | ||
264 | list->hiddev = hiddev_table[i]; | 263 | list->hiddev = hiddev_table[i]; |
265 | list->next = hiddev_table[i]->list; | 264 | list->next = hiddev_table[i]->list; |
@@ -754,9 +753,8 @@ int hiddev_connect(struct hid_device *hid) | |||
754 | if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDDEV) == 0) | 753 | if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDDEV) == 0) |
755 | return -1; | 754 | return -1; |
756 | 755 | ||
757 | if (!(hiddev = kmalloc(sizeof(struct hiddev), GFP_KERNEL))) | 756 | if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL))) |
758 | return -1; | 757 | return -1; |
759 | memset(hiddev, 0, sizeof(struct hiddev)); | ||
760 | 758 | ||
761 | retval = usb_register_dev(hid->intf, &hiddev_class); | 759 | retval = usb_register_dev(hid->intf, &hiddev_class); |
762 | if (retval) { | 760 | if (retval) { |