From owner-p4-projects@FreeBSD.ORG Fri Jun 15 17:25:41 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D0E7F16A473; Fri, 15 Jun 2007 17:25:40 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4E59B16A468 for ; Fri, 15 Jun 2007 17:25:40 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 3FC1313C448 for ; Fri, 15 Jun 2007 17:25:40 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l5FHPemt062559 for ; Fri, 15 Jun 2007 17:25:40 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l5FHPdDK062548 for perforce@freebsd.org; Fri, 15 Jun 2007 17:25:39 GMT (envelope-from hselasky@FreeBSD.org) Date: Fri, 15 Jun 2007 17:25:39 GMT Message-Id: <200706151725.l5FHPdDK062548@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 121704 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2007 17:25:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=121704 Change 121704 by hselasky@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;