diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2005-11-16 16:41:28 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-01-04 16:48:32 -0500 |
commit | ba9dc657af86d05d2971633e57d1f6f94ed60472 (patch) | |
tree | 2b57fe680536b5a02e9dd3b8f4d1df33d6f65017 /drivers/usb/core | |
parent | 733260ff9c45bd4db60f45d17e8560a4a68dff4d (diff) |
[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.c | 19 |
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) | |||
112 | { | 112 | { |
113 | int error = 0; | 113 | int error = 0; |
114 | 114 | ||
115 | if (usb_drv->no_dynamic_id) | ||
116 | goto exit; | ||
117 | |||
115 | if (usb_drv->probe != NULL) | 118 | if (usb_drv->probe != NULL) |
116 | error = sysfs_create_file(&usb_drv->driver.kobj, | 119 | error = sysfs_create_file(&usb_drv->driver.kobj, |
117 | &driver_attr_new_id.attr); | 120 | &driver_attr_new_id.attr); |
121 | exit: | ||
118 | return error; | 122 | return error; |
119 | } | 123 | } |
120 | 124 | ||
125 | static void usb_remove_newid_file(struct usb_driver *usb_drv) | ||
126 | { | ||
127 | if (usb_drv->no_dynamic_id) | ||
128 | return; | ||
129 | |||
130 | if (usb_drv->probe != NULL) | ||
131 | sysfs_remove_file(&usb_drv->driver.kobj, | ||
132 | &driver_attr_new_id.attr); | ||
133 | } | ||
134 | |||
121 | static void usb_free_dynids(struct usb_driver *usb_drv) | 135 | static void usb_free_dynids(struct usb_driver *usb_drv) |
122 | { | 136 | { |
123 | struct usb_dynid *dynid, *n; | 137 | struct usb_dynid *dynid, *n; |
@@ -135,6 +149,10 @@ static inline int usb_create_newid_file(struct usb_driver *usb_drv) | |||
135 | return 0; | 149 | return 0; |
136 | } | 150 | } |
137 | 151 | ||
152 | static void usb_remove_newid_file(struct usb_driver *usb_drv) | ||
153 | { | ||
154 | } | ||
155 | |||
138 | static inline void usb_free_dynids(struct usb_driver *usb_drv) | 156 | static inline void usb_free_dynids(struct usb_driver *usb_drv) |
139 | { | 157 | { |
140 | } | 158 | } |
@@ -447,6 +465,7 @@ void usb_deregister(struct usb_driver *driver) | |||
447 | pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name); | 465 | pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name); |
448 | 466 | ||
449 | usb_lock_all_devices(); | 467 | usb_lock_all_devices(); |
468 | usb_remove_newid_file(driver); | ||
450 | usb_free_dynids(driver); | 469 | usb_free_dynids(driver); |
451 | driver_unregister(&driver->driver); | 470 | driver_unregister(&driver->driver); |
452 | usb_unlock_all_devices(); | 471 | usb_unlock_all_devices(); |