PERFORCE change 182030 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Sat Aug 7 15:19:08 UTC 2010
http://p4web.freebsd.org/@@182030?ac=10
Change 182030 by hselasky at hselasky_laptop001 on 2010/08/07 15:18:30
USB core:
- refactor set address related code due
to super speed USB.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/usb_bus.h#20 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_controller.h#25 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_device.c#74 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_request.c#40 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/usb_bus.h#20 (text+ko) ====
@@ -91,7 +91,6 @@
uint16_t isoc_time_last; /* in milliseconds */
- uint8_t no_set_address; /* Do not send set address requests */
uint8_t alloc_failed; /* Set if memory allocation failed. */
uint8_t driver_added_refcount; /* Current driver generation count */
enum usb_revision usbrev; /* USB revision. See "USB_REV_XXX". */
==== //depot/projects/usb/src/sys/dev/usb/usb_controller.h#25 (text+ko) ====
@@ -121,7 +121,11 @@
/* Optional for device and host mode */
- void (*start_dma_delay)(struct usb_xfer *);
+ void (*start_dma_delay) (struct usb_xfer *);
+
+ /* Optional for host mode */
+
+ usb_error_t (*set_address) (struct usb_device *, struct mtx *, uint16_t);
};
/*
==== //depot/projects/usb/src/sys/dev/usb/usb_device.c#74 (text+ko) ====
@@ -1660,9 +1660,6 @@
"(%s, ignored)\n", udev->address,
usbd_errstr(err));
}
- /* allow device time to set new address */
- usb_pause_mtx(NULL,
- USB_MS_TO_TICKS(USB_SET_ADDRESS_SETTLE));
} else {
/* We are not self powered */
udev->flags.self_powered = 0;
==== //depot/projects/usb/src/sys/dev/usb/usb_request.c#40 (text+ko) ====
@@ -1368,7 +1368,7 @@
usbd_req_set_address(struct usb_device *udev, struct mtx *mtx, uint16_t addr)
{
struct usb_device_request req;
- uint16_t flags;
+ usb_error_t err;
DPRINTFN(6, "setting device address=%d\n", addr);
@@ -1378,15 +1378,25 @@
USETW(req.wIndex, 0);
USETW(req.wLength, 0);
- flags = USB_DELAY_STATUS_STAGE;
+ err = USB_ERR_INVAL;
/* check if USB controller handles set address */
- if ((udev->parent_hub != NULL) && (udev->bus->no_set_address != 0))
- flags |= USB_DRY_RUN;
+ if (udev->bus->methods->set_address != NULL)
+ err = (udev->bus->methods->set_address) (udev, mtx, addr);
+
+ if (err != USB_ERR_INVAL)
+ goto done;
/* Setting the address should not take more than 1 second ! */
- return (usbd_do_request_flags(udev, mtx, &req, NULL,
- flags, NULL, 1000));
+ err = usbd_do_request_flags(udev, mtx, &req, NULL,
+ USB_DELAY_STATUS_STAGE, NULL, 1000);
+
+done:
+ /* allow device time to set new address */
+ usb_pause_mtx(mtx,
+ USB_MS_TO_TICKS(USB_SET_ADDRESS_SETTLE));
+
+ return (err);
}
/*------------------------------------------------------------------------*
@@ -1809,9 +1819,6 @@
if (udev->address == USB_START_ADDR)
udev->address = old_addr;
- /* allow device time to set new address */
- usb_pause_mtx(mtx, USB_MS_TO_TICKS(USB_SET_ADDRESS_SETTLE));
-
/* get the device descriptor */
err = usbd_req_get_desc(udev, mtx, NULL, &udev->ddesc,
USB_MAX_IPACKET, USB_MAX_IPACKET, 0, UDESC_DEVICE, 0, 0);
More information about the p4-projects
mailing list