Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Jan 2009 19:02:31 +0000 (UTC)
From:      Andrew Thompson <thompsa@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r187169 - head/sys/dev/usb2/core
Message-ID:  <200901131902.n0DJ2V65012267@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: thompsa
Date: Tue Jan 13 19:02:30 2009
New Revision: 187169
URL: http://svn.freebsd.org/changeset/base/187169

Log:
  MFp4: //depot/projects/usb@155810
  
  	Usability improvement. Make sure that setting
  	power mode ON resurrects the device if powered OFF.
  	Reported by: Alexander Best.
  
  Submitted by: Hans Petter Selasky

Modified:
  head/sys/dev/usb2/core/usb2_generic.c

Modified: head/sys/dev/usb2/core/usb2_generic.c
==============================================================================
--- head/sys/dev/usb2/core/usb2_generic.c	Tue Jan 13 19:02:17 2009	(r187168)
+++ head/sys/dev/usb2/core/usb2_generic.c	Tue Jan 13 19:02:30 2009	(r187169)
@@ -1688,15 +1688,23 @@ ugen_set_power_mode(struct usb2_fifo *f,
 {
 	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 @@ ugen_set_power_mode(struct usb2_fifo *f,
 	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?200901131902.n0DJ2V65012267>