Author: weongyo
Date: Thu Nov 25 03:30:43 2010
New Revision: 215812
URL: http://svn.freebsd.org/changeset/base/215812

Log:
  Handles the unit number correctly that the previous commit had a problem
  (wrong unit number for a host controller) when the module is load /
  unloaded repeatly.  Attaching the USB pf is moved to usbus device's
  attach.
  
  Pointed by:   yongari

Modified:
  head/sys/dev/usb/controller/usb_controller.c
  head/sys/dev/usb/usb_pf.c

Modified: head/sys/dev/usb/controller/usb_controller.c
==============================================================================
--- head/sys/dev/usb/controller/usb_controller.c        Thu Nov 25 03:16:31 
2010        (r215811)
+++ head/sys/dev/usb/controller/usb_controller.c        Thu Nov 25 03:30:43 
2010        (r215812)
@@ -207,6 +207,8 @@ usb_detach(device_t dev)
 
        usb_proc_free(&bus->control_xfer_proc);
 
+       usbpf_detach(bus);
+
        return (0);
 }
 
@@ -435,6 +437,8 @@ usb_attach_sub(device_t dev, struct usb_
                usb_devclass_ptr = devclass_find("usbus");
        mtx_unlock(&Giant);
 
+       usbpf_attach(bus);
+
        /* Initialise USB process messages */
        bus->explore_msg[0].hdr.pm_callback = &usb_bus_explore;
        bus->explore_msg[0].bus = bus;
@@ -548,8 +552,6 @@ usb_bus_mem_alloc_all(struct usb_bus *bu
 
        TAILQ_INIT(&bus->intr_q.head);
 
-       usbpf_attach(bus);
-
 #if USB_HAVE_BUSDMA
        usb_dma_tag_setup(bus->dma_parent_tag, bus->dma_tags,
            dmat, &bus->bus_mtx, NULL, 32, USB_BUS_DMA_TAG_MAX);
@@ -597,8 +599,6 @@ usb_bus_mem_free_all(struct usb_bus *bus
        usb_dma_tag_unsetup(bus->dma_parent_tag);
 #endif
 
-       usbpf_detach(bus);
-
        mtx_destroy(&bus->bus_mtx);
 }
 

Modified: head/sys/dev/usb/usb_pf.c
==============================================================================
--- head/sys/dev/usb/usb_pf.c   Thu Nov 25 03:16:31 2010        (r215811)
+++ head/sys/dev/usb/usb_pf.c   Thu Nov 25 03:30:43 2010        (r215812)
@@ -61,10 +61,9 @@ void
 usbpf_attach(struct usb_bus *ubus)
 {
        struct ifnet *ifp;
-       devclass_t dc = devclass_find("usbus");
 
        ifp = ubus->ifp = if_alloc(IFT_USB);
-       if_initname(ifp, "usbus", devclass_get_count(dc));
+       if_initname(ifp, "usbus", device_get_unit(ubus->bdev));
        if_attach(ifp);
 
        KASSERT(sizeof(struct usbpf_pkthdr) == USBPF_HDR_LEN,
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to