summaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2005-11-16 22:41:28 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-04 22:48:32 +0100
commitba9dc657af86d05d2971633e57d1f6f94ed60472 (patch)
tree2b57fe680536b5a02e9dd3b8f4d1df33d6f65017 /drivers/usb/core
parent[PATCH] USB: add dynamic id functionality to USB core (diff)
downloadlinux-ba9dc657af86d05d2971633e57d1f6f94ed60472.tar.xz
linux-ba9dc657af86d05d2971633e57d1f6f94ed60472.zip
[PATCH] USB: allow usb drivers to disable dynamic ids
This lets drivers, like the usb-serial ones, disable the ability to add ids from sysfs. The usb-serial drivers are "odd" in that they are really usb-serial bus drivers, not usb bus drivers, so the dynamic id logic will have to go into the usb-serial bus core for those drivers to get that ability. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/driver.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 1c0611045379..5e65bc258e1b 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -112,12 +112,26 @@ static int usb_create_newid_file(struct usb_driver *usb_drv)
{
int error = 0;
+ if (usb_drv->no_dynamic_id)
+ goto exit;
+
if (usb_drv->probe != NULL)
error = sysfs_create_file(&usb_drv->driver.kobj,
&driver_attr_new_id.attr);
+exit:
return error;
}
+static void usb_remove_newid_file(struct usb_driver *usb_drv)
+{
+ if (usb_drv->no_dynamic_id)
+ return;
+
+ if (usb_drv->probe != NULL)
+ sysfs_remove_file(&usb_drv->driver.kobj,
+ &driver_attr_new_id.attr);
+}
+
static void usb_free_dynids(struct usb_driver *usb_drv)
{
struct usb_dynid *dynid, *n;
@@ -135,6 +149,10 @@ static inline int usb_create_newid_file(struct usb_driver *usb_drv)
return 0;
}
+static void usb_remove_newid_file(struct usb_driver *usb_drv)
+{
+}
+
static inline void usb_free_dynids(struct usb_driver *usb_drv)
{
}
@@ -447,6 +465,7 @@ void usb_deregister(struct usb_driver *driver)
pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name);
usb_lock_all_devices();
+ usb_remove_newid_file(driver);
usb_free_dynids(driver);
driver_unregister(&driver->driver);
usb_unlock_all_devices();