svn commit: r212486 - user/weongyo/usb/sys/dev/usb

Weongyo Jeong weongyo at FreeBSD.org
Sun Sep 12 00:08:07 UTC 2010


Author: weongyo
Date: Sun Sep 12 00:08:07 2010
New Revision: 212486
URL: http://svn.freebsd.org/changeset/base/212486

Log:
  One of things to make USB stack hard to read is that I think there are
  too many places mtx_owned(9) used.  Using mtx_owned(9) looks it makes
  code short but IMHO it leads for developers not to understand the code
  flow clearly.  As further works I'd like to remove all mtx_owned(9) if
  it could be removed.

Modified:
  user/weongyo/usb/sys/dev/usb/usb_hub.c
  user/weongyo/usb/sys/dev/usb/usb_hub.h

Modified: user/weongyo/usb/sys/dev/usb/usb_hub.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/usb_hub.c	Sat Sep 11 23:09:25 2010	(r212485)
+++ user/weongyo/usb/sys/dev/usb/usb_hub.c	Sun Sep 12 00:08:07 2010	(r212486)
@@ -540,7 +540,7 @@ uhub_root_intr(struct usb_bus *bus, cons
 {
 	USB_BUS_LOCK_ASSERT(bus, MA_OWNED);
 
-	usb_needs_explore(bus, 0);
+	usb_needs_explore_locked(bus, 0);
 }
 
 /*------------------------------------------------------------------------*
@@ -1587,7 +1587,20 @@ usb_bus_port_set_device(struct usb_bus *
 void
 usb_needs_explore(struct usb_bus *bus, uint8_t do_probe)
 {
-	uint8_t do_unlock;
+
+	DPRINTF("\n");
+	if (bus == NULL) {
+		DPRINTF("No bus pointer!\n");
+		return;
+	}
+	USB_BUS_LOCK(bus);
+	usb_needs_explore_locked(bus, do_probe);
+	USB_BUS_UNLOCK(bus);
+}
+
+void
+usb_needs_explore_locked(struct usb_bus *bus, uint8_t do_probe)
+{
 
 	DPRINTF("\n");
 
@@ -1595,17 +1608,14 @@ usb_needs_explore(struct usb_bus *bus, u
 		DPRINTF("No bus pointer!\n");
 		return;
 	}
+
+	USB_BUS_LOCK_ASSERT(bus, MA_OWNED);
+
 	if ((bus->devices == NULL) ||
 	    (bus->devices[USB_ROOT_HUB_ADDR] == NULL)) {
 		DPRINTF("No root HUB\n");
 		return;
 	}
-	if (mtx_owned(&bus->bus_mtx)) {
-		do_unlock = 0;
-	} else {
-		USB_BUS_LOCK(bus);
-		do_unlock = 1;
-	}
 	if (do_probe) {
 		bus->do_probe = 1;
 	}
@@ -1613,9 +1623,6 @@ usb_needs_explore(struct usb_bus *bus, u
 	    &bus->explore_msg[0], &bus->explore_msg[1])) {
 		/* ignore */
 	}
-	if (do_unlock) {
-		USB_BUS_UNLOCK(bus);
-	}
 }
 
 /*------------------------------------------------------------------------*

Modified: user/weongyo/usb/sys/dev/usb/usb_hub.h
==============================================================================
--- user/weongyo/usb/sys/dev/usb/usb_hub.h	Sat Sep 11 23:09:25 2010	(r212485)
+++ user/weongyo/usb/sys/dev/usb/usb_hub.h	Sun Sep 12 00:08:07 2010	(r212486)
@@ -74,6 +74,7 @@ void	usb_bus_port_set_device(struct usb_
 struct usb_device *usb_bus_port_get_device(struct usb_bus *bus,
 	    struct usb_port *up);
 void	usb_needs_explore(struct usb_bus *bus, uint8_t do_probe);
+void	usb_needs_explore_locked(struct usb_bus *bus, uint8_t do_probe);
 void	usb_needs_explore_all(void);
 void	usb_bus_power_update(struct usb_bus *bus);
 void	usb_bus_powerd(struct usb_bus *bus);


More information about the svn-src-user mailing list