diff options
author | Mike Isely <isely@isely.net> | 2008-02-11 05:23:14 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-25 08:16:36 +0400 |
commit | 93075544d6c6e9aaa14c44edb6eb3f71144bdeeb (patch) | |
tree | 2727ca11d0740e79d523c7e367010194b70e19cd /drivers/usb/serial/cypress_m8.c | |
parent | 9544e833f977d1d3e102a070718d613cd234ce8d (diff) | |
download | linux-93075544d6c6e9aaa14c44edb6eb3f71144bdeeb.tar.xz |
USB: cypress_m8: Feature buffer fixes
cypress_m8: Feature buffer fixes
From: Mike Isely <isely@pobox.com>
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 <isely@pobox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/cypress_m8.c')
-rw-r--r-- | drivers/usb/serial/cypress_m8.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 779d07851a4d..155b82a25d18 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -290,7 +290,7 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m { 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__); @@ -353,7 +353,7 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m } 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,16 +370,20 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m feature_buffer[2], feature_buffer[3], feature_buffer[4]); 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); + 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, + sizeof(feature_buffer), 500); if (tries++ >= 3) break; - } while (retval != 8 && retval != -ENODEV); + } while (retval != sizeof(feature_buffer) && + retval != -ENODEV); - if (retval != 8) { + if (retval != sizeof(feature_buffer)) { err("%s - failed sending serial line settings - %d", __FUNCTION__, retval); cypress_set_dead(port); } else { @@ -393,19 +397,23 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m case CYPRESS_GET_CONFIG: dbg("%s - retreiving serial line settings", __FUNCTION__); /* set initial values in feature buffer */ - memset(feature_buffer, 0, 8); + memset(feature_buffer, 0, sizeof(feature_buffer)); do { - retval = usb_control_msg (port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), - HID_REQ_GET_REPORT, USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, - 0x0300, 0, feature_buffer, 8, 500); - + retval = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + HID_REQ_GET_REPORT, + USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, + 0x0300, 0, feature_buffer, + sizeof(feature_buffer), 500); + if (tries++ >= 3) break; - } while (retval != 5 && retval != -ENODEV); + } while (retval != sizeof(feature_buffer) && + retval != -ENODEV); - if (retval != 5) { + if (retval != sizeof(feature_buffer)) { err("%s - failed to retrieve serial line settings - %d", __FUNCTION__, retval); cypress_set_dead(port); return retval; |