aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/usbip/stub_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/usbip/stub_main.c')
-rw-r--r--drivers/staging/usbip/stub_main.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c
index baf857f7cc88..9c5832abbdf1 100644
--- a/drivers/staging/usbip/stub_main.c
+++ b/drivers/staging/usbip/stub_main.c
@@ -19,6 +19,7 @@
#include <linux/string.h>
#include <linux/module.h>
+#include <linux/device.h>
#include "usbip_common.h"
#include "stub.h"
@@ -187,6 +188,34 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf,
static DRIVER_ATTR(match_busid, S_IRUSR | S_IWUSR, show_match_busid,
store_match_busid);
+static ssize_t rebind_store(struct device_driver *dev, const char *buf,
+ size_t count)
+{
+ int ret;
+ int len;
+ struct bus_id_priv *bid;
+
+ /* buf length should be less that BUSID_SIZE */
+ len = strnlen(buf, BUSID_SIZE);
+
+ if (!(len < BUSID_SIZE))
+ return -EINVAL;
+
+ bid = get_busid_priv(buf);
+ if (!bid)
+ return -ENODEV;
+
+ ret = device_attach(&bid->udev->dev);
+ if (ret < 0) {
+ dev_err(&bid->udev->dev, "rebind failed\n");
+ return ret;
+ }
+
+ return count;
+}
+
+static DRIVER_ATTR_WO(rebind);
+
static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead)
{
struct stub_priv *priv, *tmp;
@@ -254,7 +283,7 @@ static int __init usbip_host_init(void)
return -ENOMEM;
}
- ret = usb_register(&stub_driver);
+ ret = usb_register_device_driver(&stub_driver, THIS_MODULE);
if (ret) {
pr_err("usb_register failed %d\n", ret);
goto err_usb_register;
@@ -267,11 +296,18 @@ static int __init usbip_host_init(void)
goto err_create_file;
}
+ ret = driver_create_file(&stub_driver.drvwrap.driver,
+ &driver_attr_rebind);
+ if (ret) {
+ pr_err("driver_create_file failed\n");
+ goto err_create_file;
+ }
+
pr_info(DRIVER_DESC " v" USBIP_VERSION "\n");
return ret;
err_create_file:
- usb_deregister(&stub_driver);
+ usb_deregister_device_driver(&stub_driver);
err_usb_register:
kmem_cache_destroy(stub_priv_cache);
return ret;
@@ -282,11 +318,14 @@ static void __exit usbip_host_exit(void)
driver_remove_file(&stub_driver.drvwrap.driver,
&driver_attr_match_busid);
+ driver_remove_file(&stub_driver.drvwrap.driver,
+ &driver_attr_rebind);
+
/*
* deregister() calls stub_disconnect() for all devices. Device
* specific data is cleared in stub_disconnect().
*/
- usb_deregister(&stub_driver);
+ usb_deregister_device_driver(&stub_driver);
kmem_cache_destroy(stub_priv_cache);
}