RFC/patch 3/6: usb: move initialization of wusb and auth defaults to usb_alloc_dev()

Inaky Perez-Gonzalez <[email protected]>
Newsgroups gmane.linux.usb.devel
Organization Intel Corporation
Message-ID <[email protected]>
# HG changeset patch
# User Inaky Perez-Gonzalez <[email protected]>
# Date 1177445170 25200
# Node ID ea995fd510552dfce57a0283205277950655024b
# Parent  862192faf844ea7c9ed50e7b189019ef601324a2
usb: move initialization of wusb and auth defaults to usb_alloc_dev()

Initialize early the authorization and wusb attributes so we don't
have any place taking them as initialized.

Signed-off-by: Inaky Perez-Gonzalez <[email protected]>

diff -r 862192faf844 -r ea995fd51055 drivers/usb/core/hub.c
--- a/drivers/usb/core/hub.c	Mon Apr 23 18:37:21 2007 -0700
+++ b/drivers/usb/core/hub.c	Tue Apr 24 13:06:10 2007 -0700
@@ -1473,11 +1473,8 @@ static int hub_port_wait_reset(struct us
 		/* if we`ve finished resetting, then break out of the loop */
 		if (!(portstatus & USB_PORT_STAT_RESET) &&
 		    (portstatus & USB_PORT_STAT_ENABLE)) {
-			if (hub_is_wusb(hub)) {
+			if (hub_is_wusb(hub))
 				udev->speed = USB_SPEED_VARIABLE;
- 				udev->authorized = 0;
- 				udev->wusb = 1;
-			}
 			else if (portstatus & USB_PORT_STAT_HIGH_SPEED)
 				udev->speed = USB_SPEED_HIGH;
 			else if (portstatus & USB_PORT_STAT_LOW_SPEED)
diff -r 862192faf844 -r ea995fd51055 drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c	Mon Apr 23 18:37:21 2007 -0700
+++ b/drivers/usb/core/usb.c	Tue Apr 24 13:06:10 2007 -0700
@@ -239,6 +239,15 @@ static void usb_autosuspend_work(struct 
 
 #endif	/* CONFIG_PM */
 
+
+/* Returns 1 if @usb_bus is WUSB, 0 otherwise */
+static unsigned usb_bus_is_wusb(struct usb_bus *bus)
+{
+	struct usb_hcd *hcd = container_of(bus, struct usb_hcd, self);
+	return hcd->wireless;
+}
+
+
 /**
  * usb_alloc_dev - usb device constructor (usbcore-internal)
  * @parent: hub to which device is connected; null to allocate a root hub
@@ -319,7 +328,14 @@ usb_alloc_dev(struct usb_device *parent,
 	INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work);
 	dev->autosuspend_delay = usb_autosuspend_delay * HZ;
 #endif
-	dev->authorized = 1;	/* If WUSB, will default to NOT auth */
+	if (usb_bus_is_wusb(bus)) {	/* If WUSB, will default to NOT auth */
+		dev->authorized = 0;
+		dev->wusb = 1;
+	}
+	else {
+		dev->authorized = 1;
+		dev->wusb = 0;
+	}
 	return dev;
 }
 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.