aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt3
-rw-r--r--drivers/hid/hid-asus.c4
-rw-r--r--drivers/hid/hid-core.c35
-rw-r--r--drivers/hid/hid-generic.c33
-rw-r--r--drivers/hid/hid-multitouch.c2
-rw-r--r--drivers/hid/hid-ntrig.c12
-rw-r--r--drivers/hid/uhid.c12
-rw-r--r--drivers/hid/usbhid/hid-core.c12
-rw-r--r--include/linux/hid.h4
9 files changed, 54 insertions, 63 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index b98048b56ada..e0d825206681 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4352,6 +4352,9 @@
4352 usbhid.jspoll= 4352 usbhid.jspoll=
4353 [USBHID] The interval which joysticks are to be polled at. 4353 [USBHID] The interval which joysticks are to be polled at.
4354 4354
4355 usbhid.kbpoll=
4356 [USBHID] The interval which keyboards are to be polled at.
4357
4355 usb-storage.delay_use= 4358 usb-storage.delay_use=
4356 [UMS] The delay in seconds before a new device is 4359 [UMS] The delay in seconds before a new device is
4357 scanned for Logical Units (default 1). 4360 scanned for Logical Units (default 1).
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index cc738ebf93ac..88a5672f42cd 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -570,7 +570,9 @@ static int asus_input_mapping(struct hid_device *hdev,
570static int asus_start_multitouch(struct hid_device *hdev) 570static int asus_start_multitouch(struct hid_device *hdev)
571{ 571{
572 int ret; 572 int ret;
573 const unsigned char buf[] = { FEATURE_REPORT_ID, 0x00, 0x03, 0x01, 0x00 }; 573 static const unsigned char buf[] = {
574 FEATURE_REPORT_ID, 0x00, 0x03, 0x01, 0x00
575 };
574 unsigned char *dmabuf = kmemdup(buf, sizeof(buf), GFP_KERNEL); 576 unsigned char *dmabuf = kmemdup(buf, sizeof(buf), GFP_KERNEL);
575 577
576 if (!dmabuf) { 578 if (!dmabuf) {
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index a40681d5a2a3..5d7cc6bbbac6 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2199,31 +2199,40 @@ void hid_destroy_device(struct hid_device *hdev)
2199EXPORT_SYMBOL_GPL(hid_destroy_device); 2199EXPORT_SYMBOL_GPL(hid_destroy_device);
2200 2200
2201 2201
2202static int __bus_add_driver(struct device_driver *drv, void *data) 2202static int __hid_bus_reprobe_drivers(struct device *dev, void *data)
2203{ 2203{
2204 struct hid_driver *added_hdrv = data; 2204 struct hid_driver *hdrv = data;
2205 struct hid_driver *hdrv = to_hid_driver(drv); 2205 struct hid_device *hdev = to_hid_device(dev);
2206 2206
2207 if (hdrv->bus_add_driver) 2207 if (hdev->driver == hdrv &&
2208 hdrv->bus_add_driver(added_hdrv); 2208 !hdrv->match(hdev, hid_ignore_special_drivers))
2209 return device_reprobe(dev);
2209 2210
2210 return 0; 2211 return 0;
2211} 2212}
2212 2213
2213static int __bus_removed_driver(struct device_driver *drv, void *data) 2214static int __hid_bus_driver_added(struct device_driver *drv, void *data)
2214{ 2215{
2215 struct hid_driver *removed_hdrv = data;
2216 struct hid_driver *hdrv = to_hid_driver(drv); 2216 struct hid_driver *hdrv = to_hid_driver(drv);
2217 2217
2218 if (hdrv->bus_removed_driver) 2218 if (hdrv->match) {
2219 hdrv->bus_removed_driver(removed_hdrv); 2219 bus_for_each_dev(&hid_bus_type, NULL, hdrv,
2220 __hid_bus_reprobe_drivers);
2221 }
2220 2222
2221 return 0; 2223 return 0;
2222} 2224}
2223 2225
2226static int __bus_removed_driver(struct device_driver *drv, void *data)
2227{
2228 return bus_rescan_devices(&hid_bus_type);
2229}
2230
2224int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, 2231int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
2225 const char *mod_name) 2232 const char *mod_name)
2226{ 2233{
2234 int ret;
2235
2227 hdrv->driver.name = hdrv->name; 2236 hdrv->driver.name = hdrv->name;
2228 hdrv->driver.bus = &hid_bus_type; 2237 hdrv->driver.bus = &hid_bus_type;
2229 hdrv->driver.owner = owner; 2238 hdrv->driver.owner = owner;
@@ -2232,9 +2241,13 @@ int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
2232 INIT_LIST_HEAD(&hdrv->dyn_list); 2241 INIT_LIST_HEAD(&hdrv->dyn_list);
2233 spin_lock_init(&hdrv->dyn_lock); 2242 spin_lock_init(&hdrv->dyn_lock);
2234 2243
2235 bus_for_each_drv(&hid_bus_type, NULL, hdrv, __bus_add_driver); 2244 ret = driver_register(&hdrv->driver);
2245
2246 if (ret == 0)
2247 bus_for_each_drv(&hid_bus_type, NULL, NULL,
2248 __hid_bus_driver_added);
2236 2249
2237 return driver_register(&hdrv->driver); 2250 return ret;
2238} 2251}
2239EXPORT_SYMBOL_GPL(__hid_register_driver); 2252EXPORT_SYMBOL_GPL(__hid_register_driver);
2240 2253
diff --git a/drivers/hid/hid-generic.c b/drivers/hid/hid-generic.c
index 3c0a1bf433d7..c25b4718de44 100644
--- a/drivers/hid/hid-generic.c
+++ b/drivers/hid/hid-generic.c
@@ -26,37 +26,6 @@
26 26
27static struct hid_driver hid_generic; 27static struct hid_driver hid_generic;
28 28
29static int __unmap_hid_generic(struct device *dev, void *data)
30{
31 struct hid_driver *hdrv = data;
32 struct hid_device *hdev = to_hid_device(dev);
33
34 /* only unbind matching devices already bound to hid-generic */
35 if (hdev->driver != &hid_generic ||
36 hid_match_device(hdev, hdrv) == NULL)
37 return 0;
38
39 if (dev->parent) /* Needed for USB */
40 device_lock(dev->parent);
41 device_release_driver(dev);
42 if (dev->parent)
43 device_unlock(dev->parent);
44
45 return 0;
46}
47
48static void hid_generic_add_driver(struct hid_driver *hdrv)
49{
50 bus_for_each_dev(&hid_bus_type, NULL, hdrv, __unmap_hid_generic);
51}
52
53static void hid_generic_removed_driver(struct hid_driver *hdrv)
54{
55 int ret;
56
57 ret = driver_attach(&hid_generic.driver);
58}
59
60static int __check_hid_generic(struct device_driver *drv, void *data) 29static int __check_hid_generic(struct device_driver *drv, void *data)
61{ 30{
62 struct hid_driver *hdrv = to_hid_driver(drv); 31 struct hid_driver *hdrv = to_hid_driver(drv);
@@ -97,8 +66,6 @@ static struct hid_driver hid_generic = {
97 .name = "hid-generic", 66 .name = "hid-generic",
98 .id_table = hid_table, 67 .id_table = hid_table,
99 .match = hid_generic_match, 68 .match = hid_generic_match,
100 .bus_add_driver = hid_generic_add_driver,
101 .bus_removed_driver = hid_generic_removed_driver,
102}; 69};
103module_hid_driver(hid_generic); 70module_hid_driver(hid_generic);
104 71
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index ba32f0172030..dad2fbb0e3f8 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -731,7 +731,7 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
731 } 731 }
732 732
733 if (!(td->mtclass.quirks & MT_QUIRK_CONFIDENCE)) 733 if (!(td->mtclass.quirks & MT_QUIRK_CONFIDENCE))
734 s->confidence_state = 1; 734 s->confidence_state = true;
735 active = (s->touch_state || s->inrange_state) && 735 active = (s->touch_state || s->inrange_state) &&
736 s->confidence_state; 736 s->confidence_state;
737 737
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index 3d121d8ee980..43b1c7234316 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -591,8 +591,8 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
591 switch (usage->hid) { 591 switch (usage->hid) {
592 case 0xff000001: 592 case 0xff000001:
593 /* Tag indicating the start of a multitouch group */ 593 /* Tag indicating the start of a multitouch group */
594 nd->reading_mt = 1; 594 nd->reading_mt = true;
595 nd->first_contact_touch = 0; 595 nd->first_contact_touch = false;
596 break; 596 break;
597 case HID_DG_TIPSWITCH: 597 case HID_DG_TIPSWITCH:
598 nd->tipswitch = value; 598 nd->tipswitch = value;
@@ -663,7 +663,7 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
663 * even if deactivation slack is turned off. 663 * even if deactivation slack is turned off.
664 */ 664 */
665 nd->act_state = deactivate_slack - 1; 665 nd->act_state = deactivate_slack - 1;
666 nd->confidence = 0; 666 nd->confidence = false;
667 break; 667 break;
668 } 668 }
669 669
@@ -679,7 +679,7 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
679 */ 679 */
680 if (nd->w < nd->min_width || 680 if (nd->w < nd->min_width ||
681 nd->h < nd->min_height) 681 nd->h < nd->min_height)
682 nd->confidence = 0; 682 nd->confidence = false;
683 } else 683 } else
684 break; 684 break;
685 685
@@ -758,7 +758,7 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
758 if (!nd->reading_mt) /* Just to be sure */ 758 if (!nd->reading_mt) /* Just to be sure */
759 break; 759 break;
760 760
761 nd->reading_mt = 0; 761 nd->reading_mt = false;
762 762
763 763
764 /* 764 /*
@@ -910,7 +910,7 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
910 return -ENOMEM; 910 return -ENOMEM;
911 } 911 }
912 912
913 nd->reading_mt = 0; 913 nd->reading_mt = false;
914 nd->min_width = 0; 914 nd->min_width = 0;
915 nd->min_height = 0; 915 nd->min_height = 0;
916 nd->activate_slack = activate_slack; 916 nd->activate_slack = activate_slack;
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index fc43850a155e..39b60e531183 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -496,12 +496,12 @@ static int uhid_dev_create2(struct uhid_device *uhid,
496 goto err_free; 496 goto err_free;
497 } 497 }
498 498
499 len = min(sizeof(hid->name), sizeof(ev->u.create2.name)) - 1; 499 len = min(sizeof(hid->name), sizeof(ev->u.create2.name));
500 strncpy(hid->name, ev->u.create2.name, len); 500 strlcpy(hid->name, ev->u.create2.name, len);
501 len = min(sizeof(hid->phys), sizeof(ev->u.create2.phys)) - 1; 501 len = min(sizeof(hid->phys), sizeof(ev->u.create2.phys));
502 strncpy(hid->phys, ev->u.create2.phys, len); 502 strlcpy(hid->phys, ev->u.create2.phys, len);
503 len = min(sizeof(hid->uniq), sizeof(ev->u.create2.uniq)) - 1; 503 len = min(sizeof(hid->uniq), sizeof(ev->u.create2.uniq));
504 strncpy(hid->uniq, ev->u.create2.uniq, len); 504 strlcpy(hid->uniq, ev->u.create2.uniq, len);
505 505
506 hid->ll_driver = &uhid_hid_driver; 506 hid->ll_driver = &uhid_hid_driver;
507 hid->bus = ev->u.create2.bus; 507 hid->bus = ev->u.create2.bus;
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 77c50cdfff97..af0e0d061b15 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -56,6 +56,10 @@ static unsigned int hid_jspoll_interval;
56module_param_named(jspoll, hid_jspoll_interval, uint, 0644); 56module_param_named(jspoll, hid_jspoll_interval, uint, 0644);
57MODULE_PARM_DESC(jspoll, "Polling interval of joysticks"); 57MODULE_PARM_DESC(jspoll, "Polling interval of joysticks");
58 58
59static unsigned int hid_kbpoll_interval;
60module_param_named(kbpoll, hid_kbpoll_interval, uint, 0644);
61MODULE_PARM_DESC(kbpoll, "Polling interval of keyboards");
62
59static unsigned int ignoreled; 63static unsigned int ignoreled;
60module_param_named(ignoreled, ignoreled, uint, 0644); 64module_param_named(ignoreled, ignoreled, uint, 0644);
61MODULE_PARM_DESC(ignoreled, "Autosuspend with active leds"); 65MODULE_PARM_DESC(ignoreled, "Autosuspend with active leds");
@@ -1094,7 +1098,9 @@ static int usbhid_start(struct hid_device *hid)
1094 hid->name, endpoint->bInterval, interval); 1098 hid->name, endpoint->bInterval, interval);
1095 } 1099 }
1096 1100
1097 /* Change the polling interval of mice and joysticks. */ 1101 /* Change the polling interval of mice, joysticks
1102 * and keyboards.
1103 */
1098 switch (hid->collection->usage) { 1104 switch (hid->collection->usage) {
1099 case HID_GD_MOUSE: 1105 case HID_GD_MOUSE:
1100 if (hid_mousepoll_interval > 0) 1106 if (hid_mousepoll_interval > 0)
@@ -1104,6 +1110,10 @@ static int usbhid_start(struct hid_device *hid)
1104 if (hid_jspoll_interval > 0) 1110 if (hid_jspoll_interval > 0)
1105 interval = hid_jspoll_interval; 1111 interval = hid_jspoll_interval;
1106 break; 1112 break;
1113 case HID_GD_KEYBOARD:
1114 if (hid_kbpoll_interval > 0)
1115 interval = hid_kbpoll_interval;
1116 break;
1107 } 1117 }
1108 1118
1109 ret = -ENOMEM; 1119 ret = -ENOMEM;
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 0f5cc64b2e51..8da3e1f48195 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -687,8 +687,6 @@ struct hid_usage_id {
687 * @input_mapped: invoked on input registering after mapping an usage 687 * @input_mapped: invoked on input registering after mapping an usage
688 * @input_configured: invoked just before the device is registered 688 * @input_configured: invoked just before the device is registered
689 * @feature_mapping: invoked on feature registering 689 * @feature_mapping: invoked on feature registering
690 * @bus_add_driver: invoked when a HID driver is about to be added
691 * @bus_removed_driver: invoked when a HID driver has been removed
692 * @suspend: invoked on suspend (NULL means nop) 690 * @suspend: invoked on suspend (NULL means nop)
693 * @resume: invoked on resume if device was not reset (NULL means nop) 691 * @resume: invoked on resume if device was not reset (NULL means nop)
694 * @reset_resume: invoked on resume if device was reset (NULL means nop) 692 * @reset_resume: invoked on resume if device was reset (NULL means nop)
@@ -743,8 +741,6 @@ struct hid_driver {
743 void (*feature_mapping)(struct hid_device *hdev, 741 void (*feature_mapping)(struct hid_device *hdev,
744 struct hid_field *field, 742 struct hid_field *field,
745 struct hid_usage *usage); 743 struct hid_usage *usage);
746 void (*bus_add_driver)(struct hid_driver *driver);
747 void (*bus_removed_driver)(struct hid_driver *driver);
748#ifdef CONFIG_PM 744#ifdef CONFIG_PM
749 int (*suspend)(struct hid_device *hdev, pm_message_t message); 745 int (*suspend)(struct hid_device *hdev, pm_message_t message);
750 int (*resume)(struct hid_device *hdev); 746 int (*resume)(struct hid_device *hdev);