aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorMike Isely <isely@isely.net>2008-02-10 21:23:14 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-04-25 00:16:36 -0400
commit93075544d6c6e9aaa14c44edb6eb3f71144bdeeb (patch)
tree2727ca11d0740e79d523c7e367010194b70e19cd /drivers/usb
parent9544e833f977d1d3e102a070718d613cd234ce8d (diff)
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')
-rw-r--r--drivers/usb/serial/cypress_m8.c36
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
290{ 290{
291 int new_baudrate = 0, retval = 0, tries = 0; 291 int new_baudrate = 0, retval = 0, tries = 0;
292 struct cypress_private *priv; 292 struct cypress_private *priv;
293 __u8 feature_buffer[8]; 293 __u8 feature_buffer[5];
294 unsigned long flags; 294 unsigned long flags;
295 295
296 dbg("%s", __FUNCTION__); 296 dbg("%s", __FUNCTION__);
@@ -353,7 +353,7 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
353 } 353 }
354 dbg("%s - baud rate is being sent as %d", __FUNCTION__, new_baudrate); 354 dbg("%s - baud rate is being sent as %d", __FUNCTION__, new_baudrate);
355 355
356 memset(feature_buffer, 0, 8); 356 memset(feature_buffer, 0, sizeof(feature_buffer));
357 /* fill the feature_buffer with new configuration */ 357 /* fill the feature_buffer with new configuration */
358 *((u_int32_t *)feature_buffer) = new_baudrate; 358 *((u_int32_t *)feature_buffer) = new_baudrate;
359 359
@@ -370,16 +370,20 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
370 feature_buffer[2], feature_buffer[3], feature_buffer[4]); 370 feature_buffer[2], feature_buffer[3], feature_buffer[4]);
371 371
372 do { 372 do {
373 retval = usb_control_msg (port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), 373 retval = usb_control_msg(port->serial->dev,
374 HID_REQ_SET_REPORT, USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 374 usb_sndctrlpipe(port->serial->dev, 0),
375 0x0300, 0, feature_buffer, 8, 500); 375 HID_REQ_SET_REPORT,
376 USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
377 0x0300, 0, feature_buffer,
378 sizeof(feature_buffer), 500);
376 379
377 if (tries++ >= 3) 380 if (tries++ >= 3)
378 break; 381 break;
379 382
380 } while (retval != 8 && retval != -ENODEV); 383 } while (retval != sizeof(feature_buffer) &&
384 retval != -ENODEV);
381 385
382 if (retval != 8) { 386 if (retval != sizeof(feature_buffer)) {
383 err("%s - failed sending serial line settings - %d", __FUNCTION__, retval); 387 err("%s - failed sending serial line settings - %d", __FUNCTION__, retval);
384 cypress_set_dead(port); 388 cypress_set_dead(port);
385 } else { 389 } else {
@@ -393,19 +397,23 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
393 case CYPRESS_GET_CONFIG: 397 case CYPRESS_GET_CONFIG:
394 dbg("%s - retreiving serial line settings", __FUNCTION__); 398 dbg("%s - retreiving serial line settings", __FUNCTION__);
395 /* set initial values in feature buffer */ 399 /* set initial values in feature buffer */
396 memset(feature_buffer, 0, 8); 400 memset(feature_buffer, 0, sizeof(feature_buffer));
397 401
398 do { 402 do {
399 retval = usb_control_msg (port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), 403 retval = usb_control_msg(port->serial->dev,
400 HID_REQ_GET_REPORT, USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 404 usb_rcvctrlpipe(port->serial->dev, 0),
401 0x0300, 0, feature_buffer, 8, 500); 405 HID_REQ_GET_REPORT,
402 406 USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
407 0x0300, 0, feature_buffer,
408 sizeof(feature_buffer), 500);
409
403 if (tries++ >= 3) 410 if (tries++ >= 3)
404 break; 411 break;
405 412
406 } while (retval != 5 && retval != -ENODEV); 413 } while (retval != sizeof(feature_buffer) &&
414 retval != -ENODEV);
407 415
408 if (retval != 5) { 416 if (retval != sizeof(feature_buffer)) {
409 err("%s - failed to retrieve serial line settings - %d", __FUNCTION__, retval); 417 err("%s - failed to retrieve serial line settings - %d", __FUNCTION__, retval);
410 cypress_set_dead(port); 418 cypress_set_dead(port);
411 return retval; 419 return retval;