PERFORCE change 121704 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Fri Jun 15 17:25:41 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=121704
Change 121704 by hselasky at hselasky_mini_itx on 2007/06/15 17:25:03
Enhance the usability of the usbd_find_descriptor()
function.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/if_cdce.c#19 edit
.. //depot/projects/usb/src/sys/dev/usb/umodem.c#21 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_subr.c#38 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_subr.h#40 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/if_cdce.c#19 (text+ko) ====
@@ -253,7 +253,7 @@
}
ud = usbd_find_descriptor
- (uaa->device, uaa->iface_index,
+ (uaa->device, NULL, uaa->iface_index,
UDESC_CS_INTERFACE, UDESCSUB_CDC_UNION);
if ((ud == NULL) || (ud->bLength < sizeof(*ud))) {
@@ -328,7 +328,7 @@
&cdce_ifmedia_sts_cb);
ue = usbd_find_descriptor
- (uaa->device, uaa->iface_index,
+ (uaa->device, NULL, uaa->iface_index,
UDESC_CS_INTERFACE, UDESCSUB_CDC_ENF);
if ((ue == NULL) || (ue->bLength < sizeof(*ue)) ||
==== //depot/projects/usb/src/sys/dev/usb/umodem.c#21 (text+ko) ====
@@ -903,7 +903,7 @@
umodem_get_desc(struct usb_attach_arg *uaa, u_int8_t type, u_int8_t subtype)
{
return
- usbd_find_descriptor(uaa->device, uaa->iface_index, type, subtype);
+ usbd_find_descriptor(uaa->device, NULL, uaa->iface_index, type, subtype);
}
static usbd_status
==== //depot/projects/usb/src/sys/dev/usb/usb_subr.c#38 (text+ko) ====
@@ -364,13 +364,22 @@
return (NULL);
}
+/*------------------------------------------------------------------------*
+ * usbd_find_descriptor
+ *
+ * This function will lookup the first descriptor that matches
+ * the criteria given by the arguments "type" and "subtype". Descriptors
+ * will only be searched within the interface having the index "iface_index".
+ * It is possible to specify the last descriptor returned by this function
+ * as the "id" argument. That way one can search for multiple descriptors
+ * matching the same criteria.
+ *------------------------------------------------------------------------*/
void *
-usbd_find_descriptor(struct usbd_device *udev, uint16_t iface_index,
+usbd_find_descriptor(struct usbd_device *udev, void *id, uint16_t iface_index,
int16_t type, int16_t subtype)
{
usb_descriptor_t *desc;
usb_config_descriptor_t *cd;
- usb_interface_descriptor_t *id;
struct usbd_interface *iface;
cd = usbd_get_config_descriptor(udev);
@@ -378,14 +387,16 @@
return NULL;
}
- iface = usbd_get_iface(udev, iface_index);
- if (iface == NULL) {
+ if (id == NULL) {
+ iface = usbd_get_iface(udev, iface_index);
+ if (iface == NULL) {
return NULL;
- }
+ }
- id = usbd_get_interface_descriptor(iface);
- if (id == NULL) {
+ id = usbd_get_interface_descriptor(iface);
+ if (id == NULL) {
return NULL;
+ }
}
desc = (void *)id;
@@ -396,7 +407,8 @@
break;
}
- if ((desc->bDescriptorType == type) &&
+ if (((type == USBD_TYPE_ANY) ||
+ (type == desc->bDescriptorType)) &&
((subtype == USBD_SUBTYPE_ANY) ||
(subtype == desc->bDescriptorSubtype)))
{
==== //depot/projects/usb/src/sys/dev/usb/usb_subr.h#40 (text+ko) ====
@@ -541,6 +541,7 @@
/* prototypes from usb_subr.c */
+#define USBD_TYPE_ANY (-1)
#define USBD_SUBTYPE_ANY (-1)
#ifdef __FreeBSD__
@@ -559,7 +560,7 @@
struct usb_hid_descriptor *usbd_get_hdesc(usb_config_descriptor_t *cd, usb_interface_descriptor_t *id);
usb_interface_descriptor_t *usbd_find_idesc(usb_config_descriptor_t *cd, uint16_t iface_index, uint16_t alt_index);
usb_endpoint_descriptor_t *usbd_find_edesc(usb_config_descriptor_t *cd, uint16_t iface_index, uint16_t alt_index, uint16_t endptidx);
-void * usbd_find_descriptor(struct usbd_device *udev, uint16_t iface_index, int16_t type, int16_t subtype);
+void * usbd_find_descriptor(struct usbd_device *udev, void *id, uint16_t iface_index, int16_t type, int16_t subtype);
int usbd_get_no_alts(usb_config_descriptor_t *cd, uint8_t ifaceno);
usbd_status usbd_search_and_set_config(struct usbd_device *udev, int32_t no, int32_t msg);
usbd_status usbd_set_config_index(struct usbd_device *udev, int32_t index, int32_t msg);
@@ -819,10 +820,20 @@
/* prototypes from "usb_compat_linux.c" */
void usb_linux_free_usb_device(struct usb_device *dev);
+/* USB virtual endpoint */
+struct usbd_vep {
+ struct usb_device_put_urb urb;
+ struct usbd_xfer *xfer[1];
+ uint8_t dev_addr;
+ uint8_t isread;
+};
+
/* USB clone support */
struct usbd_clone {
struct mtx mtx;
struct usb_cdev cdev;
+ struct usb_device_poll_urb status;
+ struct usbd_vep vep[USB_DEVICE_VEP_MAX];
struct usbd_bus *bus;
struct usbd_clone *next;
More information about the p4-projects
mailing list