summaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-core.c
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2017-12-08 15:29:44 +0100
committerJiri Kosina <jkosina@suse.cz>2018-03-06 16:00:51 +0100
commitc17a7476e4c41884d82e3675c25ceae982c07a63 (patch)
tree577796c9bda4e5663207717afdfd79b054764b9c /drivers/hid/hid-core.c
parent001fab49dd4fcf64b1b8ccecb8656baa3f3f1a9a (diff)
downloadlinux-c17a7476e4c41884d82e3675c25ceae982c07a63.tar.bz2
HID: core: rewrite the hid-generic automatic unbind
We actually can have the unbind/rebind logic in hid-core.c, leaving only the match function in hid-generic. This makes hid-generic simpler and the whole logic simpler too. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-core.c')
-rw-r--r--drivers/hid/hid-core.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index c2560aae5542..c058bb911ca1 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2197,31 +2197,40 @@ void hid_destroy_device(struct hid_device *hdev)
EXPORT_SYMBOL_GPL(hid_destroy_device);
-static int __bus_add_driver(struct device_driver *drv, void *data)
+static int __hid_bus_reprobe_drivers(struct device *dev, void *data)
{
- struct hid_driver *added_hdrv = data;
- struct hid_driver *hdrv = to_hid_driver(drv);
+ struct hid_driver *hdrv = data;
+ struct hid_device *hdev = to_hid_device(dev);
- if (hdrv->bus_add_driver)
- hdrv->bus_add_driver(added_hdrv);
+ if (hdev->driver == hdrv &&
+ !hdrv->match(hdev, hid_ignore_special_drivers))
+ return device_reprobe(dev);
return 0;
}
-static int __bus_removed_driver(struct device_driver *drv, void *data)
+static int __hid_bus_driver_added(struct device_driver *drv, void *data)
{
- struct hid_driver *removed_hdrv = data;
struct hid_driver *hdrv = to_hid_driver(drv);
- if (hdrv->bus_removed_driver)
- hdrv->bus_removed_driver(removed_hdrv);
+ if (hdrv->match) {
+ bus_for_each_dev(&hid_bus_type, NULL, hdrv,
+ __hid_bus_reprobe_drivers);
+ }
return 0;
}
+static int __bus_removed_driver(struct device_driver *drv, void *data)
+{
+ return bus_rescan_devices(&hid_bus_type);
+}
+
int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
const char *mod_name)
{
+ int ret;
+
hdrv->driver.name = hdrv->name;
hdrv->driver.bus = &hid_bus_type;
hdrv->driver.owner = owner;
@@ -2230,9 +2239,13 @@ int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
INIT_LIST_HEAD(&hdrv->dyn_list);
spin_lock_init(&hdrv->dyn_lock);
- bus_for_each_drv(&hid_bus_type, NULL, hdrv, __bus_add_driver);
+ ret = driver_register(&hdrv->driver);
+
+ if (ret == 0)
+ bus_for_each_drv(&hid_bus_type, NULL, NULL,
+ __hid_bus_driver_added);
- return driver_register(&hdrv->driver);
+ return ret;
}
EXPORT_SYMBOL_GPL(__hid_register_driver);