Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Aug 2008 02:33:12 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 146746 for review
Message-ID:  <200808060233.m762XCRD007719@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=146746

Change 146746 by hselasky@hselasky_laptop001 on 2008/08/06 02:32:22

	
	Various fixes and improvements.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_compat_linux.c#7 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_compat_linux.h#5 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_core.h#15 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.c#20 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.h#11 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.c#17 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_transfer.c#16 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_compat_linux.c#7 (text+ko) ====

@@ -469,7 +469,7 @@
 		}
 
 		if (urb->complete) {
-			(urb->complete) (urb, NULL);
+			(urb->complete) (urb);
 		}
 	} else {
 
@@ -842,7 +842,6 @@
 	struct usb2_descriptor *desc;
 	struct usb2_interface_descriptor *id;
 	struct usb2_endpoint_descriptor *ed;
-	struct usb2_device_descriptor *dd;
 	struct usb_device *p_ud = NULL;
 	struct usb_interface *p_ui = NULL;
 	struct usb_host_interface *p_uhi = NULL;
@@ -879,12 +878,6 @@
 			 */
 			switch (desc->bDescriptorType) {
 			case UDESC_DEVICE:
-				dd = (void *)desc;
-				if (dd->bLength < sizeof(*dd))
-					break;
-				if (p_ud) {
-					bcopy(dd, &(p_ud->descriptor), sizeof(p_ud->descriptor));
-				}
 				break;
 
 			case UDESC_ENDPOINT:
@@ -912,6 +905,7 @@
 					p_uhi->desc.bNumEndpoints = 0;
 					p_uhi->endpoint = p_uhe;
 					p_uhi->string = "";
+					p_uhi->bsd_iface_index = iface_index;
 					p_uhi++;
 				}
 				iface_no = id->bInterfaceNumber;
@@ -964,7 +958,8 @@
 			p_ud->bsd_endpoint_start = p_uhe;
 			p_ud->bsd_endpoint_end = p_uhe + nedesc;
 			p_ud->devnum = device_get_unit(dev);
-
+			bcopy(&udev->ddesc, &p_ud->descriptor,
+			    sizeof(p_ud->descriptor));
 			bcopy(udev->default_pipe.edesc, &(p_ud->ep0.desc),
 			    sizeof(p_ud->ep0.desc));
 
@@ -1324,7 +1319,7 @@
  * up, when an USB transfer has finished.
  *------------------------------------------------------------------------*/
 static void
-usb_linux_wait_complete(struct urb *urb, struct pt_regs *pt_regs)
+usb_linux_wait_complete(struct urb *urb)
 {
 	if (urb->transfer_flags & URB_IS_SLEEPING) {
 		usb2_cv_signal(&(urb->cv_wait));
@@ -1344,7 +1339,7 @@
 	urb = xfer->priv_fifo;
 	xfer->priv_fifo = NULL;
 	if (urb->complete) {
-		(urb->complete) (urb, NULL);
+		(urb->complete) (urb);
 	}
 	return;
 }

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_compat_linux.h#5 (text+ko) ====

@@ -31,10 +31,9 @@
 struct usb_interface;
 struct usb_driver;
 struct urb;
-struct pt_regs;
 
 typedef void *pm_message_t;
-typedef void (usb_complete_t)(struct urb *, struct pt_regs *);
+typedef void (usb_complete_t)(struct urb *);
 
 #define	USB_MAX_FULL_SPEED_ISOC_FRAMES (60 * 1)
 #define	USB_MAX_HIGH_SPEED_ISOC_FRAMES (60 * 8)
@@ -268,10 +267,10 @@
 
 #define	USB_ENDPOINT_HALT		0	/* IN/OUT will STALL */
 
-#define	PIPE_ISOCHRONOUS		UE_ISOCHRONOUS
-#define	PIPE_INTERRUPT			UE_INTERRUPT
-#define	PIPE_CONTROL			UE_CONTROL
-#define	PIPE_BULK			UE_BULK
+#define	PIPE_ISOCHRONOUS		0x01	/* UE_ISOCHRONOUS */
+#define	PIPE_INTERRUPT			0x03	/* UE_INTERRUPT */
+#define	PIPE_CONTROL			0x00	/* UE_CONTROL */
+#define	PIPE_BULK			0x02	/* UE_BULK */
 
 /* Whenever Linux references an USB endpoint:
  * a) to initialize "urb->pipe"
@@ -338,6 +337,8 @@
 	uint8_t *extra;			/* Extra descriptors */
 
 	uint16_t extralen;
+
+	uint8_t	bsd_iface_index;
 } __aligned(USB_HOST_ALIGN);
 
 struct usb_interface {
@@ -458,5 +459,6 @@
 void	usb_linux_deregister(void *arg);
 
 #define	interface_to_usbdev(intf) (intf)->linux_udev
+#define	interface_to_bsddev(intf) (intf)->linux_udev->bsd_udev
 
 #endif					/* _USB_COMPAT_LINUX_H */

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_core.h#15 (text+ko) ====

@@ -414,5 +414,7 @@
 void	usb2_unref_device(struct usb2_location *ploc);
 void	usb2_set_parent_iface(struct usb2_device *udev, uint8_t iface_index, uint8_t parent_index);
 void	usb2_set_iface_perm(struct usb2_device *udev, uint8_t iface_index, uint32_t uid, uint32_t gid, uint16_t mode);
+uint8_t	usb2_get_bus_index(struct usb2_device *udev);
+uint8_t	usb2_get_device_index(struct usb2_device *udev);
 
 #endif					/* _USB2_CORE_H_ */

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.c#20 (text+ko) ====

@@ -2167,6 +2167,23 @@
 	return;
 }
 
+uint8_t
+usb2_fifo_put_data_buffer(struct usb2_fifo *f, void *ptr, uint32_t len)
+{
+	struct usb2_mbuf *m;
+
+	USB_IF_DEQUEUE(&(f->free_q), m);
+
+	if (m) {
+		m->cur_data_len = len;
+		m->cur_data_ptr = ptr;
+		USB_IF_ENQUEUE(&(f->used_q), m);
+		usb2_fifo_wakeup(f);
+		return (1);
+	}
+	return (0);
+}
+
 void
 usb2_fifo_put_data_error(struct usb2_fifo *f)
 {
@@ -2303,6 +2320,37 @@
 	return (tr_data);
 }
 
+uint8_t
+usb2_fifo_get_data_buffer(struct usb2_fifo *f, void **pptr, uint32_t *plen)
+{
+	struct usb2_mbuf *m;
+
+	USB_IF_DEQUEUE(&(f->used_q), m);
+
+	if (m) {
+		*plen = m->cur_data_len;
+		*pptr = m->cur_data_ptr;
+
+		USB_IF_PREPEND(&(f->used_q), m);
+		return (1);
+	}
+	return (0);
+}
+
+void
+usb2_fifo_get_data_next(struct usb2_fifo *f)
+{
+	struct usb2_mbuf *m;
+
+	USB_IF_DEQUEUE(&(f->used_q), m);
+
+	if (m) {
+		USB_IF_ENQUEUE(&(f->free_q), m);
+		usb2_fifo_wakeup(f);
+	}
+	return;
+}
+
 void
 usb2_fifo_get_data_error(struct usb2_fifo *f)
 {

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.h#11 (text+ko) ====

@@ -128,9 +128,12 @@
 uint32_t usb2_fifo_put_bytes_max(struct usb2_fifo *fifo);
 void	usb2_fifo_put_data(struct usb2_fifo *fifo, struct usb2_page_cache *pc, uint32_t offset, uint32_t len, uint8_t what);
 void	usb2_fifo_put_data_linear(struct usb2_fifo *fifo, void *ptr, uint32_t len, uint8_t what);
+uint8_t	usb2_fifo_put_data_buffer(struct usb2_fifo *f, void *ptr, uint32_t len);
 void	usb2_fifo_put_data_error(struct usb2_fifo *fifo);
 uint8_t	usb2_fifo_get_data(struct usb2_fifo *fifo, struct usb2_page_cache *pc, uint32_t offset, uint32_t len, uint32_t *actlen, uint8_t what);
 uint8_t	usb2_fifo_get_data_linear(struct usb2_fifo *fifo, void *ptr, uint32_t len, uint32_t *actlen, uint8_t what);
+uint8_t	usb2_fifo_get_data_buffer(struct usb2_fifo *f, void **pptr, uint32_t *plen);
+void	usb2_fifo_get_data_next(struct usb2_fifo *f);
 void	usb2_fifo_get_data_error(struct usb2_fifo *fifo);
 uint8_t	usb2_fifo_opened(struct usb2_fifo *fifo);
 void	usb2_fifo_free(struct usb2_fifo *f);

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.c#17 (text+ko) ====

@@ -1965,3 +1965,15 @@
 {
 	return (iface->alt_index);
 }
+
+uint8_t
+usb2_get_bus_index(struct usb2_device *udev)
+{
+	return ((uint8_t)device_get_unit(udev->bus->bdev));
+}
+
+uint8_t
+usb2_get_device_index(struct usb2_device *udev)
+{
+	return (udev->device_index);
+}

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_transfer.c#16 (text+ko) ====

@@ -272,7 +272,8 @@
 	xfer->endpoint = edesc->bEndpointAddress;
 	xfer->max_packet_size = UGETW(edesc->wMaxPacketSize);
 	xfer->max_packet_count = 1;
-	xfer->flags_int.usb2_mode = parm->udev->flags.usb2_mode;	/* make a shadow copy */
+	/* make a shadow copy: */
+	xfer->flags_int.usb2_mode = parm->udev->flags.usb2_mode;
 
 	parm->bufsize = setup_sub->bufsize;
 
@@ -287,7 +288,8 @@
 	}
 	/* filter "wMaxPacketSize" according to HC capabilities */
 
-	if (xfer->max_packet_size > parm->hc_max_packet_size) {
+	if ((xfer->max_packet_size > parm->hc_max_packet_size) ||
+	    (xfer->max_packet_size == 0)) {
 		xfer->max_packet_size = parm->hc_max_packet_size;
 	}
 	/* filter "wMaxPacketSize" according to standard sizes */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808060233.m762XCRD007719>