speedtch xusbatm.c,1.17,1.18

Duncan Sands duncan at infradead.org
Fri Nov 18 12:46:52 EST 2005


Update of /home/cvs/speedtch
In directory phoenix.infradead.org:/tmp/cvs-serv22351

Modified Files:
	xusbatm.c 
Log Message:
Fix yet more buglets.  It seems to work now.


Index: xusbatm.c
===================================================================
RCS file: /home/cvs/speedtch/xusbatm.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- xusbatm.c	18 Nov 2005 17:06:46 -0000	1.17
+++ xusbatm.c	18 Nov 2005 17:46:48 -0000	1.18
@@ -59,7 +59,7 @@
 	for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++)
 		if ((intf = usb_dev->actconfig->interface[i]) && (alt = usb_altnum_to_altsetting(intf, altsetting)))
 			for (j = 0; j < alt->desc.bNumEndpoints; j++)
-				if ((alt->endpoint[j].desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK) == ep)
+				if (alt->endpoint[j].desc.bEndpointAddress == ep)
 					return intf;
 	return NULL;
 }
@@ -71,11 +71,11 @@
 	int ret;
 
 	if (claim && (ret = usb_driver_claim_interface(&xusbatm_usb_driver, intf, usbatm))) {
-		usb_err(usbatm, "%s: failed to claim interface %d (%d)!\n", __func__, ifnum, ret);
+		usb_err(usbatm, "%s: failed to claim interface %2d (%d)!\n", __func__, ifnum, ret);
 		return ret;
 	}
 	if ((ret = usb_set_interface(usb_dev, ifnum, altsetting))) {
-		usb_err(usbatm, "%s: altsetting %d for interface %d failed (%d)!\n", __func__, altsetting, ifnum, ret);
+		usb_err(usbatm, "%s: altsetting %2d for interface %2d failed (%d)!\n", __func__, altsetting, ifnum, ret);
 		return ret;
 	}
 	return 0;
@@ -101,36 +101,39 @@
 	struct usb_interface *tx_intf = xusbatm_find_intf(usb_dev, tx_alt, tx_endpoint[drv_ix]);
 	int ret;
 
-	usb_dbg(usbatm, "%s: binding driver %d: vendor %#x product %#x"
-		" rx: ep %#x padd %d alt %d tx: ep %#x padd %d alt %d\n",
+	usb_dbg(usbatm, "%s: binding driver %d: vendor %04x product %04x"
+		" rx: ep %02x  padd %d alt %2d tx: ep %02x  padd %d alt %2d\n",
 		__func__, drv_ix, vendor[drv_ix], product[drv_ix],
 		rx_endpoint[drv_ix], rx_padding[drv_ix], rx_alt,
 		tx_endpoint[drv_ix], tx_padding[drv_ix], tx_alt);
 
 	if (!rx_intf || !tx_intf) {
 		if (!rx_intf)
-			usb_dbg(usbatm, "%s: no interface contains endpoint %#x in altsetting %d\n",
-				__func__, rx_endpoint[drv_ix] | USB_DIR_IN, rx_alt);
+			usb_dbg(usbatm, "%s: no interface contains endpoint %02x in altsetting %2d\n",
+				__func__, rx_endpoint[drv_ix], rx_alt);
 		if (!tx_intf)
-			usb_dbg(usbatm, "%s: no interface contains endpoint %#x in altsetting %d\n",
+			usb_dbg(usbatm, "%s: no interface contains endpoint %02x in altsetting %2d\n",
 				__func__, tx_endpoint[drv_ix], tx_alt);
 		return -ENODEV;
 	}
 
+	if ((rx_intf != intf) && (tx_intf != intf))
+		return -ENODEV;
+
 	if ((rx_intf == tx_intf) && (rx_alt != tx_alt)) {
-		usb_err(usbatm, "%s: altsettings clash on interface %d (%d/%d)!\n", __func__,
+		usb_err(usbatm, "%s: altsettings clash on interface %2d (%2d vs %2d)!\n", __func__,
 				rx_intf->altsetting->desc.bInterfaceNumber, rx_alt, tx_alt);
 		return -EINVAL;
 	}
 
-	usb_dbg(usbatm, "%s: interfaces: rx %d; tx %d\n", __func__,
+	usb_dbg(usbatm, "%s: rx If#=%2d; tx If#=%2d\n", __func__,
 			rx_intf->altsetting->desc.bInterfaceNumber,
 			tx_intf->altsetting->desc.bInterfaceNumber);
 
-	if (!(ret = xusbatm_capture_intf(usbatm, usb_dev, rx_intf, rx_alt, rx_intf != intf)))
+	if ((ret = xusbatm_capture_intf(usbatm, usb_dev, rx_intf, rx_alt, rx_intf != intf)))
 		return ret;
 
-	if (!(ret = xusbatm_capture_intf(usbatm, usb_dev, tx_intf, tx_alt, tx_intf != intf))) {
+	if ((tx_intf != rx_intf) && (ret = xusbatm_capture_intf(usbatm, usb_dev, tx_intf, tx_alt, tx_intf != intf))) {
 		xusbatm_release_intf(usb_dev, rx_intf, rx_intf != intf);
 		return ret;
 	}
@@ -198,7 +201,7 @@
 	}
 
 	for (i = 0; i < num_vendor; i++) {
-		rx_endpoint[i] &= USB_ENDPOINT_NUMBER_MASK;
+		rx_endpoint[i] |= USB_DIR_IN;
 		tx_endpoint[i] &= USB_ENDPOINT_NUMBER_MASK;
 
 		xusbatm_usb_ids[i].match_flags	= USB_DEVICE_ID_MATCH_DEVICE;




More information about the Usbatm-commits mailing list