Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Jan 2009 10:28:06 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 155810 for review
Message-ID:  <200901081028.n08AS6eS088407@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=155810

Change 155810 by hselasky@hselasky_laptop001 on 2009/01/08 10:27:16

	
	Usability improvement. Make sure that setting
	power mode ON resurrects the device if powered OFF.
	Reported by: Alexander Best.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_generic.c#40 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_generic.c#40 (text+ko) ====

@@ -1688,15 +1688,23 @@
 {
 	struct usb2_device *udev = f->udev;
 	int err;
+	uint8_t old_mode;
 
 	if ((udev == NULL) ||
 	    (udev->parent_hub == NULL)) {
 		return (EINVAL);
 	}
 	err = priv_check(curthread, PRIV_ROOT);
-	if (err) {
+	if (err)
 		return (err);
-	}
+
+	/* get old power mode */
+	old_mode = udev->power_mode;
+
+	/* if no change, then just return */
+	if (old_mode == mode)
+		return (0);
+
 	switch (mode) {
 	case USB_POWER_MODE_OFF:
 		/* get the device unconfigured */
@@ -1734,6 +1742,13 @@
 	if (err)
 		return (ENXIO);		/* I/O failure */
 
+	/* if we are powered off we need to re-enumerate first */
+	if (old_mode == USB_POWER_MODE_OFF) {
+		err = ugen_re_enumerate(f);
+		if (err)
+			return (err);
+	}
+
 	/* set new power mode */
 	usb2_set_power_mode(udev, mode);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901081028.n08AS6eS088407>