PERFORCE change 99041 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Mon Jun 12 08:36:12 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=99041
Change 99041 by hselasky at hselasky_mini_itx on 2006/06/12 08:33:23
Use wMaxPacketSize for interrupt endpoints.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/uhid.c#6 edit
.. //depot/projects/usb/src/sys/dev/usb/ukbd.c#5 edit
.. //depot/projects/usb/src/sys/dev/usb/umodem.c#6 edit
.. //depot/projects/usb/src/sys/dev/usb/ums.c#6 edit
.. //depot/projects/usb/src/sys/dev/usb/uplcom.c#5 edit
.. //depot/projects/usb/src/sys/dev/usb/uvscom.c#6 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/uhid.c#6 (text+ko) ====
@@ -137,13 +137,13 @@
tr_transferred:
DPRINTF(0, "transferred!\n");
- if (xfer->actlen == sc->sc_isize) {
+ if (xfer->actlen >= sc->sc_isize) {
usb_cdev_put_data(&(sc->sc_cdev),
- xfer->buffer, xfer->actlen, 1);
+ xfer->buffer, sc->sc_isize, 1);
} else {
/* ignore it */
- DPRINTF(0, "ignored short transfer, %d bytes\n",
- xfer->actlen);
+ DPRINTF(0, "ignored short transfer, "
+ "%d bytes\n", xfer->actlen);
}
tr_setup:
@@ -153,7 +153,6 @@
USBD_IF_POLL(&(sc->sc_cdev.sc_rdq_free), m);
if (m) {
- xfer->length = sc->sc_isize;
usbd_start_hardware(xfer);
}
}
@@ -310,7 +309,7 @@
.endpoint = -1, /* any */
.direction = UE_DIR_IN,
.flags = USBD_SHORT_XFER_OK,
- .bufsize = UHID_BSIZE, /* bytes */
+ .bufsize = 0, /* use wMaxPacketSize */
.callback = &uhid_intr_callback,
},
==== //depot/projects/usb/src/sys/dev/usb/ukbd.c#5 (text+ko) ====
@@ -570,7 +570,7 @@
.endpoint = -1, /* any */
.direction = UE_DIR_IN,
.flags = USBD_SHORT_XFER_OK,
- .bufsize = sizeof(struct ukbd_data), /* bytes */
+ .bufsize = 0, /* use wMaxPacketSize */
.callback = &ukbd_intr_callback,
},
==== //depot/projects/usb/src/sys/dev/usb/umodem.c#6 (text+ko) ====
@@ -317,7 +317,7 @@
.endpoint = -1, /* any */
.direction = UE_DIR_IN,
.flags = USBD_SHORT_XFER_OK,
- .bufsize = sizeof(usb_cdc_notification_t),
+ .bufsize = 0, /* use wMaxPacketSize */
.callback = &umodem_intr_callback,
},
@@ -759,6 +759,7 @@
{
usb_cdc_notification_t *nbuf = xfer->buffer;
struct umodem_softc *sc = xfer->priv_sc;
+ u_int16_t wLength;
USBD_CHECK_STATUS(xfer);
@@ -786,9 +787,12 @@
* Set the serial state in ucom driver based on
* the bits from the notify message
*/
- if (UGETW(nbuf->wLength) < 2) {
- DPRINTF(0, "Invalid notification length, %d bytes!\n",
- UGETW(nbuf->wLength));
+ wLength = UGETW(nbuf->wLength);
+
+ if ((wLength < 2) ||
+ ((wLength + 8) < xfer->actlen)) {
+ DPRINTF(0, "Invalid notification length, "
+ "%d bytes!\n", wLength);
break;
}
DPRINTF(0, "notify bytes = %02x%02x\n",
==== //depot/projects/usb/src/sys/dev/usb/ums.c#6 (text+ko) ====
@@ -77,7 +77,6 @@
#define MOUSE_FLAGS_MASK (HIO_CONST|HIO_RELATIVE)
#define MOUSE_FLAGS (HIO_RELATIVE)
-#define UMS_INT_SIZE 64 /* bytes */
#define UMS_BUF_SIZE 8 /* bytes */
#define UMS_IFQ_MAXLEN 50 /* units */
#define UMS_N_TRANSFER 2 /* units */
@@ -310,7 +309,7 @@
.endpoint = -1, /* any */
.direction = UE_DIR_IN,
.flags = USBD_SHORT_XFER_OK,
- .bufsize = UMS_INT_SIZE, /* bytes */
+ .bufsize = 0, /* use wMaxPacketSize */
.callback = &ums_intr_callback,
},
@@ -501,14 +500,12 @@
isize = hid_report_size(d_ptr, d_len, hid_input, &sc->sc_iid);
- if (isize > UMS_INT_SIZE) {
- DPRINTF(0, "cannot handle a report "
- "size of %d bytes\n", isize);
- goto detach;
+ if (isize > sc->sc_xfer[0]->length) {
+ DPRINTF(0, "WARNING: report size, %d bytes, is larger "
+ "than interrupt size, %d bytes!\n",
+ isize, sc->sc_xfer[0]->length);
}
- sc->sc_xfer[0]->length = isize;
-
free(d_ptr, M_TEMP);
#ifdef USB_DEBUG
==== //depot/projects/usb/src/sys/dev/usb/uplcom.c#5 (text+ko) ====
@@ -121,7 +121,6 @@
#define UPLCOM_CONFIG_INDEX 0
#define UPLCOM_IFACE_INDEX 0
#define UPLCOM_SECOND_IFACE_INDEX 1
-#define UPLCOM_INTR_SIZE 64 /* bytes */
#ifndef UPLCOM_INTR_INTERVAL
#define UPLCOM_INTR_INTERVAL 0 /* default */
@@ -333,7 +332,7 @@
.endpoint = -1, /* any */
.direction = UE_DIR_IN,
.flags = USBD_SHORT_XFER_OK,
- .bufsize = UPLCOM_INTR_SIZE,
+ .bufsize = 0, /* use wMaxPacketSize */
.callback = &uplcom_intr_callback,
},
@@ -460,7 +459,6 @@
struct uplcom_softc *sc = device_get_softc(dev);
struct usbd_interface *iface;
usb_interface_descriptor_t *id;
- u_int16_t isize;
int error;
DPRINTF(10, "\n");
@@ -559,17 +557,6 @@
sc->sc_flag |= UPLCOM_FLAG_WAIT_USB_2;
- isize = UGETW(sc->sc_xfer_intr[0]->pipe->edesc->wMaxPacketSize);
-
- if (isize > UPLCOM_INTR_SIZE) {
- DPRINTF(0, "cannot handle an interrupt "
- "packet of %d bytes\n", isize);
- goto detach;
- }
-
- /* set transfer length */
- sc->sc_xfer_intr[0]->length = isize;
-
sc->sc_dtr = -1;
sc->sc_rts = -1;
sc->sc_break = -1;
==== //depot/projects/usb/src/sys/dev/usb/uvscom.c#6 (text+ko) ====
@@ -140,7 +140,6 @@
*/
#define UVSCOM_IBUFSIZE 512 /* bytes */
#define UVSCOM_OBUFSIZE 64 /* bytes */
-#define UVSCOM_INTR_SIZE 64 /* bytes */
#ifndef UVSCOM_DEFAULT_OPKTSIZE
#define UVSCOM_DEFAULT_OPKTSIZE 8
@@ -298,7 +297,7 @@
.endpoint = -1, /* any */
.direction = UE_DIR_IN,
.flags = USBD_SHORT_XFER_OK,
- .bufsize = UVSCOM_INTR_SIZE,
+ .bufsize = 0, /* use wMaxPacketSize */
.callback = &uvscom_intr_callback,
},
@@ -414,7 +413,6 @@
struct uvscom_softc *sc = device_get_softc(dev);
usb_interface_descriptor_t *id;
struct usbd_interface *iface;
- u_int16_t isize;
int error;
if (sc == NULL) {
@@ -465,18 +463,6 @@
sc->sc_flag |= UVSCOM_FLAG_WAIT_USB;
-
- isize = UGETW(sc->sc_xfer[4]->pipe->edesc->wMaxPacketSize);
-
- if (isize > UVSCOM_INTR_SIZE) {
- DPRINTF(0, "cannot handle an interrupt "
- "packet of %d bytes\n", isize);
- goto detach;
- }
-
- /* set interrupt transfer length */
- sc->sc_xfer[4]->length = isize;
-
sc->sc_dtr = -1;
sc->sc_rts = -1;
sc->sc_line_ctrl = UVSCOM_LINE_INIT;
More information about the p4-projects
mailing list