Date: Tue, 24 Apr 2007 17:27:24 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 118747 for review Message-ID: <200704241727.l3OHROTT064696@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=118747 Change 118747 by hselasky@hselasky_mini_itx on 2007/04/24 17:26:25 Bugfixes. The CDC ethernet driver reads the mac address from the wrong descriptor. usbd_find_descriptor() must take an additional argument, and that is the interface domain in which it should search for descriptors. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/if_cdce.c#13 edit .. //depot/projects/usb/src/sys/dev/usb/umodem.c#18 edit .. //depot/projects/usb/src/sys/dev/usb/usb_subr.c#33 edit .. //depot/projects/usb/src/sys/dev/usb/usb_subr.h#36 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/if_cdce.c#13 (text+ko) ==== @@ -252,9 +252,9 @@ goto alloc_transfers; } - ud = ((const void *)usbd_find_descriptor - (usbd_get_config_descriptor(uaa->device), - UDESC_CS_INTERFACE, UDESCSUB_CDC_UNION)); + ud = usbd_find_descriptor + (uaa->device, uaa->iface_index, + UDESC_CS_INTERFACE, UDESCSUB_CDC_UNION); if ((ud == NULL) || (ud->bLength < sizeof(*ud))) { device_printf(dev, "no union descriptor!\n"); @@ -327,9 +327,9 @@ &cdce_ifmedia_upd_cb, &cdce_ifmedia_sts_cb); - ue = ((const void *)usbd_find_descriptor - (usbd_get_config_descriptor(uaa->device), - UDESC_INTERFACE, UDESCSUB_CDC_ENF)); + ue = usbd_find_descriptor + (uaa->device, uaa->iface_index, + UDESC_CS_INTERFACE, UDESCSUB_CDC_ENF); if ((ue == NULL) || (ue->bLength < sizeof(*ue)) || usbreq_get_string_any(uaa->device, ue->iMacAddress, @@ -391,12 +391,8 @@ sc->sc_ifp = ifp; - mtx_unlock(&(sc->sc_mtx)); - ether_ifattach(ifp, eaddr); - mtx_lock(&(sc->sc_mtx)); - return 0; /* success */ detach: ==== //depot/projects/usb/src/sys/dev/usb/umodem.c#18 (text+ko) ==== @@ -166,7 +166,7 @@ static void umodem_stop_read(struct ucom_softc *ucom); static void umodem_start_write(struct ucom_softc *ucom); static void umodem_stop_write(struct ucom_softc *ucom); -static void umodem_get_caps(struct usbd_device *udev, u_int8_t *cm, u_int8_t *acm); +static void umodem_get_caps(struct usb_attach_arg *uaa, uint8_t *cm, uint8_t *acm); static void umodem_cfg_get_status(struct ucom_softc *ucom, u_int8_t *lsr, u_int8_t *msr); static int umodem_pre_param(struct ucom_softc *ucom, struct termios *t); static void umodem_cfg_param(struct ucom_softc *ucom, struct termios *t); @@ -174,7 +174,7 @@ static void umodem_cfg_set_dtr(struct ucom_softc *ucom, u_int8_t onoff); static void umodem_cfg_set_rts(struct ucom_softc *ucom, u_int8_t onoff); static void umodem_cfg_set_break(struct ucom_softc *ucom, u_int8_t onoff); -static void * umodem_get_desc(struct usbd_device *udev, u_int8_t type, u_int8_t subtype); +static void * umodem_get_desc(struct usb_attach_arg *uaa, uint8_t type, uint8_t subtype); static usbd_status umodem_set_comm_feature(struct usbd_device *udev, u_int8_t iface_no, uint16_t feature, uint16_t state); static void umodem_cfg_do_request(struct umodem_softc *sc, usb_device_request_t *req, void *data); @@ -313,7 +313,7 @@ goto done; } - umodem_get_caps(uaa->device, &cm, &acm); + umodem_get_caps(uaa, &cm, &acm); if (!(cm & USB_CDC_CM_DOES_CM) || !(cm & USB_CDC_CM_OVER_DATA) || !(acm & USB_CDC_ACM_HAS_LINE)) { @@ -347,12 +347,11 @@ sc->sc_ctrl_iface_index = uaa->iface_index; sc->sc_udev = uaa->device; - umodem_get_caps(uaa->device, &sc->sc_cm_cap, &sc->sc_acm_cap); + umodem_get_caps(uaa, &sc->sc_cm_cap, &sc->sc_acm_cap); /* get the data interface number */ - cmd = umodem_get_desc(uaa->device, UDESC_CS_INTERFACE, - UDESCSUB_CDC_CM); + cmd = umodem_get_desc(uaa, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM); if ((cmd == NULL) || (cmd->bLength < sizeof(*cmd))) { device_printf(dev, "no CM descriptor!\n"); @@ -491,21 +490,21 @@ } static void -umodem_get_caps(struct usbd_device *udev, u_int8_t *cm, u_int8_t *acm) +umodem_get_caps(struct usb_attach_arg *uaa, uint8_t *cm, uint8_t *acm) { usb_cdc_cm_descriptor_t *cmd; usb_cdc_acm_descriptor_t *cad; *cm = *acm = 0; - cmd = umodem_get_desc(udev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM); + cmd = umodem_get_desc(uaa, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM); if ((cmd == NULL) || (cmd->bLength < sizeof(*cmd))) { DPRINTF(0, "no CM desc\n"); return; } *cm = cmd->bmCapabilities; - cad = umodem_get_desc(udev, UDESC_CS_INTERFACE, UDESCSUB_CDC_ACM); + cad = umodem_get_desc(uaa, UDESC_CS_INTERFACE, UDESCSUB_CDC_ACM); if ((cad == NULL) || (cad->bLength < sizeof(*cad))) { DPRINTF(0, "no ACM desc\n"); return; @@ -903,9 +902,8 @@ static void * umodem_get_desc(struct usbd_device *udev, u_int8_t type, u_int8_t subtype) { - usb_config_descriptor_t *cd = usbd_get_config_descriptor(udev); - usb_descriptor_t *desc = usbd_find_descriptor(cd, type, subtype); - return desc; + return + usbd_find_descriptor(uaa->device, uaa->iface_index, type, subtype); } static usbd_status ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.c#33 (text+ko) ==== @@ -360,21 +360,46 @@ return (NULL); } -usb_descriptor_t * -usbd_find_descriptor(usb_config_descriptor_t *cd, int type, int subtype) +void * +usbd_find_descriptor(struct usbd_device *udev, uint16_t iface_index, + int16_t type, int16_t subtype) { - usb_descriptor_t *desc = NULL; + usb_descriptor_t *desc; + usb_config_descriptor_t *cd; + usb_interface_descriptor_t *id; + struct usbd_interface *iface; + + cd = usbd_get_config_descriptor(udev); + if (cd == NULL) { + return NULL; + } + + iface = usbd_get_iface(udev, iface_index); + if (iface == NULL) { + return NULL; + } + + id = usbd_get_interface_descriptor(iface); + if (id == NULL) { + return NULL; + } + + desc = (void *)id; while ((desc = usbd_desc_foreach(cd, desc))) { - if((desc->bDescriptorType == type) && - ((subtype == USBD_SUBTYPE_ANY) || - (subtype == desc->bDescriptorSubtype))) + if (desc->bDescriptorType == UDESC_INTERFACE) { + break; + } + + if ((desc->bDescriptorType == type) && + ((subtype == USBD_SUBTYPE_ANY) || + (subtype == desc->bDescriptorSubtype))) { return desc; } } - return (NULL); + return NULL; } int ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.h#36 (text+ko) ==== @@ -552,7 +552,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); -usb_descriptor_t *usbd_find_descriptor(usb_config_descriptor_t *cd, int32_t type, int32_t subtype); +void * usbd_find_descriptor(struct usbd_device *udev, 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200704241727.l3OHROTT064696>