Date: Sun, 23 Sep 2007 15:13:06 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 126738 for review Message-ID: <200709231513.l8NFD6u2091140@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=126738 Change 126738 by hselasky@hselasky_laptop001 on 2007/09/23 15:12:42 FYI; The comments follow the P4 diff from top to bottom. - start "usb_driver_added_refcount" at 1 - the "root_port" in "struct usbd_bus" is now gone. Instead we store the root USB device at "bus->devices[0]". USB_START_ADDR is 0 for completeness. - update description of Wireless USB to include the maximum data rate. - "usbd_probe_and_attach()" has been factored out from "usbd_new_device()". This makes the code more clear. - passing a mutex to "usbd_do_request_flags()" and all "usbreq_xxx()" functions is now mandatory. - "usbd_fill_deviceinfo()" does no longer need the last parameter. - NOTE: the prototype of "usbreq_get_desc()" has changed. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb.c#17 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb.c#17 (text+ko) ==== @@ -83,7 +83,7 @@ #define USB_UCRED #endif -uint8_t usb_driver_added_refcount; +uint8_t usb_driver_added_refcount = 1; static uint8_t usb_post_init_called = 0; @@ -165,8 +165,8 @@ bus->is_exploring = 1; - while(bus->root_port.device && - bus->root_port.device->hub && + while(bus->devices[USB_START_ADDR] && + bus->devices[USB_START_ADDR]->hub && bus->needs_explore && (bus->wait_explore == 0)) { @@ -177,8 +177,8 @@ * exiting usb_global_lock, * which is actually Giant) */ - (bus->root_port.device->hub->explore) - (bus->root_port.device); + (bus->devices[USB_START_ADDR]->hub->explore) + (bus->devices[USB_START_ADDR]); } bus->is_exploring = 0; @@ -200,7 +200,7 @@ while(1) { - if(bus->root_port.device == 0) + if(bus->devices[USB_START_ADDR] == 0) { break; } @@ -210,7 +210,7 @@ /* Check if a detach happened * during discover: */ - if(bus->root_port.device == 0) + if(bus->devices[USB_START_ADDR] == 0) { break; } @@ -260,6 +260,10 @@ mtx_lock(&usb_global_lock); usb_driver_added_refcount++; + if (usb_driver_added_refcount == 0) { + /* avoid zero, hence that is memory default */ + usb_driver_added_refcount = 1; + } dc = devclass_find("usb"); @@ -320,8 +324,6 @@ mtx_assert(&usb_global_lock, MA_OWNED); - bus->root_port.power = USB_MAX_POWER; - switch (bus->usbrev) { case USBREV_1_0: speed = USB_SPEED_FULL; @@ -340,7 +342,7 @@ case USBREV_2_5: speed = USB_SPEED_VARIABLE; - device_printf(bus->bdev, "Wireless USB v2.5\n"); + device_printf(bus->bdev, "480MBps Wireless USB v2.5\n"); break; default: @@ -348,11 +350,15 @@ return; } - err = usbd_new_device(bus->bdev, bus, 0, speed, 0, - &bus->root_port); + err = usbd_new_device(bus->bdev, bus, NULL, 0, speed, 0, 0); + + if (!err) { + err = usbd_probe_and_attach(bus->bdev, bus->devices[USB_START_ADDR]); + } + if(!err) { - if(bus->root_port.device->hub == NULL) + if(bus->devices[USB_START_ADDR]->hub == NULL) { device_printf(bus->bdev, "root device is not a hub\n"); @@ -476,13 +482,13 @@ /* detach children first */ bus_generic_detach(dev); - if(bus->root_port.device != NULL) + if(bus->devices[USB_START_ADDR] != NULL) { /* free device, but not sub-devices, * hence they are freed by the * caller of this function */ - usbd_free_device(&bus->root_port, 0); + usbd_free_device(bus->devices[USB_START_ADDR], 0); } /* kill off event thread */ @@ -715,11 +721,11 @@ } } - mtx_lock(dev->sc_mtx_ptr); - error = usbd_do_request_flags_mtx - (udev, dev->sc_mtx_ptr, &ur->ucr_request, ptr, ur->ucr_flags, - &ur->ucr_actlen, USBD_DEFAULT_TIMEOUT); - mtx_unlock(dev->sc_mtx_ptr); + error = usbd_do_request_flags + (udev, NULL, &ur->ucr_request, ptr, ur->ucr_flags, + &len, USBD_DEFAULT_TIMEOUT); + + ur->ucr_actlen = len; if (error) { error = EIO; @@ -752,7 +758,7 @@ goto done; } - error = usbd_fill_deviceinfo(udev, di, 1); + error = usbd_fill_deviceinfo(udev, di); usbd_unref_device(udev); goto done; @@ -765,7 +771,7 @@ case USB_DEVICEENUMERATE: { struct usb_device_enumerate *ude = (void *)addr; - struct usbd_port *pp; + struct usbd_device *parent_hub; usb_port_status_t ps; uint8_t old_addr; uint8_t buf[8]; @@ -777,13 +783,13 @@ } old_addr = udev->address; - pp = udev->powersrc; - if (pp == NULL) { + parent_hub = udev->parent_hub; + if (parent_hub == NULL) { error = EINVAL; goto ret002; } - error = usbreq_reset_port(pp->parent, pp->portno, &ps); + error = usbreq_reset_port(parent_hub, NULL, &ps, udev->port_no); if (error) { error = ENXIO; goto ret002; @@ -793,12 +799,13 @@ * our device should be at address * zero: */ - udev->address = 0; + udev->address = USB_START_ADDR; /* It should be allowed to read some descriptors * from address zero: */ - error = usbreq_get_desc(udev, UDESC_DEVICE, 0, 8, buf, 0); + error = usbreq_get_desc(udev, NULL, buf, + 8, 8, 0, UDESC_DEVICE, 0, 0); if (error) { error = ENXIO; goto ret002; @@ -806,7 +813,7 @@ /* Restore device address: */ - error = usbreq_set_address(udev, old_addr); + error = usbreq_set_address(udev, NULL, old_addr); if (error) { error = ENXIO; goto ret002;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709231513.l8NFD6u2091140>