diff options
| author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2010-10-04 23:18:05 +0000 |
|---|---|---|
| committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2010-10-04 23:18:05 +0000 |
| commit | 963169b4af5d1a347560f060254e1df9541b2350 (patch) | |
| tree | c082c15f2b4af936b99eda2cd4c67777fdf391ee /sys/dev/usb/usb_parse.c | |
| parent | 2ecb4e919f3df1edf00be35c9a85bd067495be2e (diff) | |
Notes
Diffstat (limited to 'sys/dev/usb/usb_parse.c')
| -rw-r--r-- | sys/dev/usb/usb_parse.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/sys/dev/usb/usb_parse.c b/sys/dev/usb/usb_parse.c index deb52ea50e83..8663c1e07832 100644 --- a/sys/dev/usb/usb_parse.c +++ b/sys/dev/usb/usb_parse.c @@ -180,7 +180,7 @@ usb_edesc_foreach(struct usb_config_descriptor *cd, } if (desc->bDescriptorType == UDESC_ENDPOINT) { if (desc->bLength < sizeof(*ped)) { - /* endpoint index is invalid */ + /* endpoint descriptor is invalid */ break; } return ((struct usb_endpoint_descriptor *)desc); @@ -190,6 +190,42 @@ usb_edesc_foreach(struct usb_config_descriptor *cd, } /*------------------------------------------------------------------------* + * usb_ed_comp_foreach + * + * This function will iterate all the endpoint companion descriptors + * within an endpoint descriptor in an interface descriptor. Starting + * value for the "ped" argument should be a valid endpoint companion + * descriptor. + * + * Return values: + * NULL: End of descriptors + * Else: A valid endpoint companion descriptor + *------------------------------------------------------------------------*/ +struct usb_endpoint_ss_comp_descriptor * +usb_ed_comp_foreach(struct usb_config_descriptor *cd, + struct usb_endpoint_ss_comp_descriptor *ped) +{ + struct usb_descriptor *desc; + + desc = ((struct usb_descriptor *)ped); + + while ((desc = usb_desc_foreach(cd, desc))) { + if (desc->bDescriptorType == UDESC_INTERFACE) + break; + if (desc->bDescriptorType == UDESC_ENDPOINT) + break; + if (desc->bDescriptorType == UDESC_ENDPOINT_SS_COMP) { + if (desc->bLength < sizeof(*ped)) { + /* endpoint companion descriptor is invalid */ + break; + } + return ((struct usb_endpoint_ss_comp_descriptor *)desc); + } + } + return (NULL); +} + +/*------------------------------------------------------------------------* * usbd_get_no_descriptors * * This function will count the total number of descriptors in the |
