Skip to content

Commit e2d39e0

Browse files
author
Jiri Kosina
committed
Merge branch 'for-4.17/upstream' into for-linus
Pull a few small generic code cleanups.
2 parents 108ff0e + 2ddc8e2 commit e2d39e0

File tree

9 files changed

+54
-63
lines changed

9 files changed

+54
-63
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4352,6 +4352,9 @@
43524352
usbhid.jspoll=
43534353
[USBHID] The interval which joysticks are to be polled at.
43544354

4355+
usbhid.kbpoll=
4356+
[USBHID] The interval which keyboards are to be polled at.
4357+
43554358
usb-storage.delay_use=
43564359
[UMS] The delay in seconds before a new device is
43574360
scanned for Logical Units (default 1).

drivers/hid/hid-asus.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,9 @@ static int asus_input_mapping(struct hid_device *hdev,
570570
static int asus_start_multitouch(struct hid_device *hdev)
571571
{
572572
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+
};
574576
unsigned char *dmabuf = kmemdup(buf, sizeof(buf), GFP_KERNEL);
575577

576578
if (!dmabuf) {

drivers/hid/hid-core.c

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,31 +2199,40 @@ void hid_destroy_device(struct hid_device *hdev)
21992199
EXPORT_SYMBOL_GPL(hid_destroy_device);
22002200

22012201

2202-
static int __bus_add_driver(struct device_driver *drv, void *data)
2202+
static int __hid_bus_reprobe_drivers(struct device *dev, void *data)
22032203
{
2204-
struct hid_driver *added_hdrv = data;
2205-
struct hid_driver *hdrv = to_hid_driver(drv);
2204+
struct hid_driver *hdrv = data;
2205+
struct hid_device *hdev = to_hid_device(dev);
22062206

2207-
if (hdrv->bus_add_driver)
2208-
hdrv->bus_add_driver(added_hdrv);
2207+
if (hdev->driver == hdrv &&
2208+
!hdrv->match(hdev, hid_ignore_special_drivers))
2209+
return device_reprobe(dev);
22092210

22102211
return 0;
22112212
}
22122213

2213-
static int __bus_removed_driver(struct device_driver *drv, void *data)
2214+
static int __hid_bus_driver_added(struct device_driver *drv, void *data)
22142215
{
2215-
struct hid_driver *removed_hdrv = data;
22162216
struct hid_driver *hdrv = to_hid_driver(drv);
22172217

2218-
if (hdrv->bus_removed_driver)
2219-
hdrv->bus_removed_driver(removed_hdrv);
2218+
if (hdrv->match) {
2219+
bus_for_each_dev(&hid_bus_type, NULL, hdrv,
2220+
__hid_bus_reprobe_drivers);
2221+
}
22202222

22212223
return 0;
22222224
}
22232225

2226+
static int __bus_removed_driver(struct device_driver *drv, void *data)
2227+
{
2228+
return bus_rescan_devices(&hid_bus_type);
2229+
}
2230+
22242231
int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
22252232
const char *mod_name)
22262233
{
2234+
int ret;
2235+
22272236
hdrv->driver.name = hdrv->name;
22282237
hdrv->driver.bus = &hid_bus_type;
22292238
hdrv->driver.owner = owner;
@@ -2232,9 +2241,13 @@ int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
22322241
INIT_LIST_HEAD(&hdrv->dyn_list);
22332242
spin_lock_init(&hdrv->dyn_lock);
22342243

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);
22362249

2237-
return driver_register(&hdrv->driver);
2250+
return ret;
22382251
}
22392252
EXPORT_SYMBOL_GPL(__hid_register_driver);
22402253

drivers/hid/hid-generic.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,6 @@
2626

2727
static struct hid_driver hid_generic;
2828

29-
static 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-
48-
static 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-
53-
static void hid_generic_removed_driver(struct hid_driver *hdrv)
54-
{
55-
int ret;
56-
57-
ret = driver_attach(&hid_generic.driver);
58-
}
59-
6029
static int __check_hid_generic(struct device_driver *drv, void *data)
6130
{
6231
struct hid_driver *hdrv = to_hid_driver(drv);
@@ -97,8 +66,6 @@ static struct hid_driver hid_generic = {
9766
.name = "hid-generic",
9867
.id_table = hid_table,
9968
.match = hid_generic_match,
100-
.bus_add_driver = hid_generic_add_driver,
101-
.bus_removed_driver = hid_generic_removed_driver,
10269
};
10370
module_hid_driver(hid_generic);
10471

drivers/hid/hid-multitouch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
731731
}
732732

733733
if (!(td->mtclass.quirks & MT_QUIRK_CONFIDENCE))
734-
s->confidence_state = 1;
734+
s->confidence_state = true;
735735
active = (s->touch_state || s->inrange_state) &&
736736
s->confidence_state;
737737

drivers/hid/hid-ntrig.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,8 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
591591
switch (usage->hid) {
592592
case 0xff000001:
593593
/* Tag indicating the start of a multitouch group */
594-
nd->reading_mt = 1;
595-
nd->first_contact_touch = 0;
594+
nd->reading_mt = true;
595+
nd->first_contact_touch = false;
596596
break;
597597
case HID_DG_TIPSWITCH:
598598
nd->tipswitch = value;
@@ -663,7 +663,7 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
663663
* even if deactivation slack is turned off.
664664
*/
665665
nd->act_state = deactivate_slack - 1;
666-
nd->confidence = 0;
666+
nd->confidence = false;
667667
break;
668668
}
669669

@@ -679,7 +679,7 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
679679
*/
680680
if (nd->w < nd->min_width ||
681681
nd->h < nd->min_height)
682-
nd->confidence = 0;
682+
nd->confidence = false;
683683
} else
684684
break;
685685

@@ -758,7 +758,7 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
758758
if (!nd->reading_mt) /* Just to be sure */
759759
break;
760760

761-
nd->reading_mt = 0;
761+
nd->reading_mt = false;
762762

763763

764764
/*
@@ -910,7 +910,7 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
910910
return -ENOMEM;
911911
}
912912

913-
nd->reading_mt = 0;
913+
nd->reading_mt = false;
914914
nd->min_width = 0;
915915
nd->min_height = 0;
916916
nd->activate_slack = activate_slack;

drivers/hid/uhid.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,12 @@ static int uhid_dev_create2(struct uhid_device *uhid,
496496
goto err_free;
497497
}
498498

499-
len = min(sizeof(hid->name), sizeof(ev->u.create2.name)) - 1;
500-
strncpy(hid->name, ev->u.create2.name, len);
501-
len = min(sizeof(hid->phys), sizeof(ev->u.create2.phys)) - 1;
502-
strncpy(hid->phys, ev->u.create2.phys, len);
503-
len = min(sizeof(hid->uniq), sizeof(ev->u.create2.uniq)) - 1;
504-
strncpy(hid->uniq, ev->u.create2.uniq, len);
499+
len = min(sizeof(hid->name), sizeof(ev->u.create2.name));
500+
strlcpy(hid->name, ev->u.create2.name, len);
501+
len = min(sizeof(hid->phys), sizeof(ev->u.create2.phys));
502+
strlcpy(hid->phys, ev->u.create2.phys, len);
503+
len = min(sizeof(hid->uniq), sizeof(ev->u.create2.uniq));
504+
strlcpy(hid->uniq, ev->u.create2.uniq, len);
505505

506506
hid->ll_driver = &uhid_hid_driver;
507507
hid->bus = ev->u.create2.bus;

drivers/hid/usbhid/hid-core.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ static unsigned int hid_jspoll_interval;
5656
module_param_named(jspoll, hid_jspoll_interval, uint, 0644);
5757
MODULE_PARM_DESC(jspoll, "Polling interval of joysticks");
5858

59+
static unsigned int hid_kbpoll_interval;
60+
module_param_named(kbpoll, hid_kbpoll_interval, uint, 0644);
61+
MODULE_PARM_DESC(kbpoll, "Polling interval of keyboards");
62+
5963
static unsigned int ignoreled;
6064
module_param_named(ignoreled, ignoreled, uint, 0644);
6165
MODULE_PARM_DESC(ignoreled, "Autosuspend with active leds");
@@ -1094,7 +1098,9 @@ static int usbhid_start(struct hid_device *hid)
10941098
hid->name, endpoint->bInterval, interval);
10951099
}
10961100

1097-
/* Change the polling interval of mice and joysticks. */
1101+
/* Change the polling interval of mice, joysticks
1102+
* and keyboards.
1103+
*/
10981104
switch (hid->collection->usage) {
10991105
case HID_GD_MOUSE:
11001106
if (hid_mousepoll_interval > 0)
@@ -1104,6 +1110,10 @@ static int usbhid_start(struct hid_device *hid)
11041110
if (hid_jspoll_interval > 0)
11051111
interval = hid_jspoll_interval;
11061112
break;
1113+
case HID_GD_KEYBOARD:
1114+
if (hid_kbpoll_interval > 0)
1115+
interval = hid_kbpoll_interval;
1116+
break;
11071117
}
11081118

11091119
ret = -ENOMEM;

include/linux/hid.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,6 @@ struct hid_usage_id {
687687
* @input_mapped: invoked on input registering after mapping an usage
688688
* @input_configured: invoked just before the device is registered
689689
* @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
692690
* @suspend: invoked on suspend (NULL means nop)
693691
* @resume: invoked on resume if device was not reset (NULL means nop)
694692
* @reset_resume: invoked on resume if device was reset (NULL means nop)
@@ -743,8 +741,6 @@ struct hid_driver {
743741
void (*feature_mapping)(struct hid_device *hdev,
744742
struct hid_field *field,
745743
struct hid_usage *usage);
746-
void (*bus_add_driver)(struct hid_driver *driver);
747-
void (*bus_removed_driver)(struct hid_driver *driver);
748744
#ifdef CONFIG_PM
749745
int (*suspend)(struct hid_device *hdev, pm_message_t message);
750746
int (*resume)(struct hid_device *hdev);

0 commit comments

Comments
 (0)