Try to set the data multiplexed feature, but don't care if there's an

error doing so.  It seems an increasing number of phones have this
quirk, and we're not keeping up.  There appears to be nothing bad that
happens for non-quirked phones.

Minor cleanups:
o prefer device_printf over printf
o kill devinfo stuff
o minor other preening.
This commit is contained in:
imp 2007-06-09 06:37:17 +00:00
parent 780ea9cf51
commit cd413c0cb2

View File

@ -277,31 +277,21 @@ USB_ATTACH(umodem)
usb_interface_descriptor_t *id; usb_interface_descriptor_t *id;
usb_endpoint_descriptor_t *ed; usb_endpoint_descriptor_t *ed;
usb_cdc_cm_descriptor_t *cmd; usb_cdc_cm_descriptor_t *cmd;
char *devinfo = NULL;
const char *devname;
usbd_status err;
int data_ifcno; int data_ifcno;
int i; int i;
struct ucom_softc *ucom; struct ucom_softc *ucom;
devinfo = malloc(1024, M_USBDEV, M_WAITOK); id = usbd_get_interface_descriptor(sc->sc_ctl_iface);
usbd_devinfo(dev, 0, devinfo); device_printf(self, "iclass %d/%d", id->bInterfaceClass,
id->bInterfaceSubClass);
ucom = &sc->sc_ucom; ucom = &sc->sc_ucom;
ucom->sc_dev = self; ucom->sc_dev = self;
sc->sc_dev = self; sc->sc_dev = self;
device_set_desc_copy(self, devinfo);
ucom->sc_udev = dev; ucom->sc_udev = dev;
ucom->sc_iface = uaa->iface; ucom->sc_iface = uaa->iface;
/*USB_ATTACH_SETUP; */
sc->sc_udev = dev; sc->sc_udev = dev;
sc->sc_ctl_iface = uaa->iface; sc->sc_ctl_iface = uaa->iface;
devname = device_get_nameunit(sc->sc_dev);
/* XXX ? use something else ? XXX */
id = usbd_get_interface_descriptor(sc->sc_ctl_iface);
printf("%s: %s, iclass %d/%d\n", devname, devinfo,
id->bInterfaceClass, id->bInterfaceSubClass);
sc->sc_ctl_iface_no = id->bInterfaceNumber; sc->sc_ctl_iface_no = id->bInterfaceNumber;
umodem_get_caps(dev, &sc->sc_cm_cap, &sc->sc_acm_cap); umodem_get_caps(dev, &sc->sc_cm_cap, &sc->sc_acm_cap);
@ -309,15 +299,15 @@ USB_ATTACH(umodem)
/* Get the data interface no. */ /* Get the data interface no. */
cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM); cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM);
if (cmd == NULL) { if (cmd == NULL) {
printf("%s: no CM descriptor\n", devname); device_printf(sc->sc_dev, "no CM descriptor\n");
goto bad; goto bad;
} }
sc->sc_data_iface_no = data_ifcno = cmd->bDataInterface; sc->sc_data_iface_no = data_ifcno = cmd->bDataInterface;
printf("%s: data interface %d, has %sCM over data, has %sbreak\n", device_printf(sc->sc_dev,
devname, data_ifcno, "data interface %d, has %sCM over data, has %sbreak\n",
sc->sc_cm_cap & USB_CDC_CM_OVER_DATA ? "" : "no ", data_ifcno, sc->sc_cm_cap & USB_CDC_CM_OVER_DATA ? "" : "no ",
sc->sc_acm_cap & USB_CDC_ACM_HAS_BREAK ? "" : "no "); sc->sc_acm_cap & USB_CDC_ACM_HAS_BREAK ? "" : "no ");
/* Get the data interface too. */ /* Get the data interface too. */
for (i = 0; i < uaa->nifaces; i++) { for (i = 0; i < uaa->nifaces; i++) {
@ -330,7 +320,7 @@ USB_ATTACH(umodem)
} }
} }
if (sc->sc_data_iface == NULL) { if (sc->sc_data_iface == NULL) {
printf("%s: no data interface\n", devname); device_printf(sc->sc_dev, "no data interface\n");
goto bad; goto bad;
} }
ucom->sc_iface = sc->sc_data_iface; ucom->sc_iface = sc->sc_data_iface;
@ -345,8 +335,8 @@ USB_ATTACH(umodem)
for (i = 0; i < id->bNumEndpoints; i++) { for (i = 0; i < id->bNumEndpoints; i++) {
ed = usbd_interface2endpoint_descriptor(sc->sc_data_iface, i); ed = usbd_interface2endpoint_descriptor(sc->sc_data_iface, i);
if (ed == NULL) { if (ed == NULL) {
printf("%s: no endpoint descriptor for %d\n", devname, device_printf(sc->sc_dev,
i); "no endpoint descriptor for %d\n", i);
goto bad; goto bad;
} }
if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
@ -359,11 +349,11 @@ USB_ATTACH(umodem)
} }
if (ucom->sc_bulkin_no == -1) { if (ucom->sc_bulkin_no == -1) {
printf("%s: Could not find data bulk in\n", devname); device_printf(sc->sc_dev, "Could not find data bulk in\n");
goto bad; goto bad;
} }
if (ucom->sc_bulkout_no == -1) { if (ucom->sc_bulkout_no == -1) {
printf("%s: Could not find data bulk out\n", devname); device_printf(sc->sc_dev, "Could not find data bulk out\n");
goto bad; goto bad;
} }
@ -373,15 +363,8 @@ USB_ATTACH(umodem)
} else { } else {
if (sc->sc_cm_cap & USB_CDC_CM_OVER_DATA) { if (sc->sc_cm_cap & USB_CDC_CM_OVER_DATA) {
if (sc->sc_acm_cap & USB_CDC_ACM_HAS_FEATURE) if (sc->sc_acm_cap & USB_CDC_ACM_HAS_FEATURE)
err = umodem_set_comm_feature(sc, umodem_set_comm_feature(sc,
UCDC_ABSTRACT_STATE, UCDC_DATA_MULTIPLEXED); UCDC_ABSTRACT_STATE, UCDC_DATA_MULTIPLEXED);
else
err = 0;
if (err) {
printf("%s: could not set data multiplex mode\n",
devname);
goto bad;
}
sc->sc_cm_over_data = 1; sc->sc_cm_over_data = 1;
} }
} }
@ -404,8 +387,8 @@ USB_ATTACH(umodem)
if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
(ed->bmAttributes & UE_XFERTYPE) == UE_INTERRUPT) { (ed->bmAttributes & UE_XFERTYPE) == UE_INTERRUPT) {
printf("%s: status change notification available\n", device_printf(sc->sc_dev,
devname); "status change notification available\n");
sc->sc_ctl_notify = ed->bEndpointAddress; sc->sc_ctl_notify = ed->bEndpointAddress;
} }
} }
@ -423,13 +406,10 @@ USB_ATTACH(umodem)
TASK_INIT(&sc->sc_task, 0, umodem_notify, sc); TASK_INIT(&sc->sc_task, 0, umodem_notify, sc);
ucom_attach(&sc->sc_ucom); ucom_attach(&sc->sc_ucom);
free(devinfo, M_USBDEV);
USB_ATTACH_SUCCESS_RETURN; USB_ATTACH_SUCCESS_RETURN;
bad: bad:
ucom->sc_dying = 1; ucom->sc_dying = 1;
free(devinfo, M_USBDEV);
USB_ATTACH_ERROR_RETURN; USB_ATTACH_ERROR_RETURN;
} }
@ -468,12 +448,14 @@ umodem_close(void *addr, int portno)
if (sc->sc_notify_pipe != NULL) { if (sc->sc_notify_pipe != NULL) {
err = usbd_abort_pipe(sc->sc_notify_pipe); err = usbd_abort_pipe(sc->sc_notify_pipe);
if (err) if (err)
printf("%s: abort notify pipe failed: %s\n", device_printf(sc->sc_dev,
device_get_nameunit(sc->sc_dev), usbd_errstr(err)); "abort notify pipe failed: %s\n",
usbd_errstr(err));
err = usbd_close_pipe(sc->sc_notify_pipe); err = usbd_close_pipe(sc->sc_notify_pipe);
if (err) if (err)
printf("%s: close notify pipe failed: %s\n", device_printf(sc->sc_dev,
device_get_nameunit(sc->sc_dev), usbd_errstr(err)); "close notify pipe failed: %s\n",
usbd_errstr(err));
sc->sc_notify_pipe = NULL; sc->sc_notify_pipe = NULL;
} }
} }
@ -490,8 +472,8 @@ umodem_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
if (status != USBD_NORMAL_COMPLETION) { if (status != USBD_NORMAL_COMPLETION) {
if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
return; return;
printf("%s: abnormal status: %s\n", device_get_nameunit(sc->sc_dev), device_printf(sc->sc_dev, "abnormal status: %s\n",
usbd_errstr(status)); usbd_errstr(status));
return; return;
} }
@ -509,9 +491,9 @@ umodem_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
* the bits from the notify message * the bits from the notify message
*/ */
if (UGETW(sc->sc_notify_buf.wLength) != 2) { if (UGETW(sc->sc_notify_buf.wLength) != 2) {
printf("%s: Invalid notification length! (%d)\n", device_printf(sc->sc_dev,
device_get_nameunit(sc->sc_dev), "Invalid notification length! (%d)\n",
UGETW(sc->sc_notify_buf.wLength)); UGETW(sc->sc_notify_buf.wLength));
break; break;
} }
DPRINTF(("%s: notify bytes = %02x%02x\n", DPRINTF(("%s: notify bytes = %02x%02x\n",