aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/usb.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 67e2e582e463..e5ff161776fa 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -223,6 +223,15 @@ static void ksuspend_usb_cleanup(void)
223 223
224#endif /* CONFIG_PM */ 224#endif /* CONFIG_PM */
225 225
226
227/* Returns 1 if @usb_bus is WUSB, 0 otherwise */
228static unsigned usb_bus_is_wusb(struct usb_bus *bus)
229{
230 struct usb_hcd *hcd = container_of(bus, struct usb_hcd, self);
231 return hcd->wireless;
232}
233
234
226/** 235/**
227 * usb_alloc_dev - usb device constructor (usbcore-internal) 236 * usb_alloc_dev - usb device constructor (usbcore-internal)
228 * @parent: hub to which device is connected; null to allocate a root hub 237 * @parent: hub to which device is connected; null to allocate a root hub
@@ -239,6 +248,8 @@ struct usb_device *
239usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1) 248usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
240{ 249{
241 struct usb_device *dev; 250 struct usb_device *dev;
251 struct usb_hcd *usb_hcd = container_of(bus, struct usb_hcd, self);
252 unsigned root_hub = 0;
242 253
243 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 254 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
244 if (!dev) 255 if (!dev)
@@ -275,6 +286,7 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
275 286
276 dev->dev.parent = bus->controller; 287 dev->dev.parent = bus->controller;
277 sprintf(&dev->dev.bus_id[0], "usb%d", bus->busnum); 288 sprintf(&dev->dev.bus_id[0], "usb%d", bus->busnum);
289 root_hub = 1;
278 } else { 290 } else {
279 /* match any labeling on the hubs; it's one-based */ 291 /* match any labeling on the hubs; it's one-based */
280 if (parent->devpath[0] == '0') 292 if (parent->devpath[0] == '0')
@@ -301,6 +313,12 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
301 INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work); 313 INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work);
302 dev->autosuspend_delay = usb_autosuspend_delay * HZ; 314 dev->autosuspend_delay = usb_autosuspend_delay * HZ;
303#endif 315#endif
316 if (root_hub) /* Root hub always ok [and always wired] */
317 dev->authorized = 1;
318 else {
319 dev->authorized = usb_hcd->authorized_default;
320 dev->wusb = usb_bus_is_wusb(bus)? 1 : 0;
321 }
304 return dev; 322 return dev;
305} 323}
306 324