On Sun, 10 Feb 2008, Mike Isely wrote: > cypress_m8: Feature buffer fixes > > From: Mike Isely <[EMAIL PROTECTED]> > > Don't hardcode the feature buffer size; use sizeof() instead. That > way we can easily specify the size in a single spot. Speaking of the > feature buffer size, the Cypress app note (and further testing with a > DeLorme Earthmate) suggests that this size should be 5 not 8 bytes. > > Signed-off-by: Mike Isely <[EMAIL PROTECTED]> > > --- > cypress_m8.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > --- > > diff -uprN -X linux-2.6.23.12-vanilla/Documentation/dontdiff > linux-2.6.23.12-vanilla/drivers/usb/serial/cypress_m8.c > cypress_patch_01_feature_buffer_hardcoded/drivers/usb/serial/cypress_m8.c > --- linux-2.6.23.12-vanilla/drivers/usb/serial/cypress_m8.c 2007-12-18 > 15:55:57.000000000 -0600 > +++ cypress_patch_01_feature_buffer_hardcoded/drivers/usb/serial/cypress_m8.c > 2008-02-10 19:35:27.000000000 -0600 > @@ -288,7 +288,7 @@ static int cypress_serial_control (struc > { > int new_baudrate = 0, retval = 0, tries = 0; > struct cypress_private *priv; > - __u8 feature_buffer[8]; > + __u8 feature_buffer[5]; > unsigned long flags; > > dbg("%s", __FUNCTION__); > @@ -351,7 +351,7 @@ static int cypress_serial_control (struc > } > dbg("%s - baud rate is being sent as %d", __FUNCTION__, > new_baudrate); > > - memset(feature_buffer, 0, 8); > + memset(feature_buffer, 0, sizeof(feature_buffer)); > /* fill the feature_buffer with new configuration */ > *((u_int32_t *)feature_buffer) = new_baudrate; > > @@ -370,14 +370,14 @@ static int cypress_serial_control (struc > do { > retval = usb_control_msg (port->serial->dev, > usb_sndctrlpipe(port->serial->dev, 0), > HID_REQ_SET_REPORT, > USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, > - 0x0300, 0, > feature_buffer, 8, 500); > + 0x0300, 0, > feature_buffer, sizeof(feature_buffer), 500); >
While it's clear that your patch didn't cause this, nevertheless the fact remains that one should never do DMA to addresses on the stack. While it works okay on x86, there are other architectures on which it won't work. The feature_buffer storage should be allocated dynamically, by kmalloc(). Alan Stern - To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html