ChangeSet 1.1587.3.16, 2004/04/28 21:43:38-07:00, sean@mess.org [PATCH] USB: fix PhidgetServo driver Somehow I managed to send the wrong version. Here is a patch which fixes that. (Remove a dev_info() which wasn't supposed to be there, and make sure that everything is still consistent in the unlikely event that kmalloc() fails). Just minor cleanups. drivers/usb/misc/phidgetservo.c | 31 ++++++++++++++----------------- 1 files changed, 14 insertions(+), 17 deletions(-) diff -Nru a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c --- a/drivers/usb/misc/phidgetservo.c Fri May 14 15:31:28 2004 +++ b/drivers/usb/misc/phidgetservo.c Fri May 14 15:31:28 2004 @@ -67,6 +67,13 @@ int retval; unsigned char *buffer; + buffer = kmalloc(6, GFP_KERNEL); + if (!buffer) { + dev_err(&servo->udev->dev, "%s - out of memory\n", + __FUNCTION__); + return; + } + /* * pulse = 0 - 4095 * angle = 0 - 180 degrees @@ -77,13 +84,6 @@ servo->degrees[servo_no]= degrees; servo->minutes[servo_no]= minutes; - buffer = kmalloc(6, GFP_KERNEL); - if (!buffer) { - dev_err(&servo->udev->dev, "%s - out of memory\n", - __FUNCTION__); - return; - } - /* * The PhidgetServo v3.0 is controlled by sending 6 bytes, * 4 * 12 bits for each servo. @@ -136,6 +136,13 @@ int retval; unsigned char *buffer; + buffer = kmalloc(2, GFP_KERNEL); + if (!buffer) { + dev_err(&servo->udev->dev, "%s - out of memory\n", + __FUNCTION__); + return; + } + /* * angle = 0 - 180 degrees * pulse = angle + 23 @@ -144,13 +151,6 @@ servo->degrees[servo_no]= degrees; servo->minutes[servo_no]= 0; - buffer = kmalloc(2, GFP_KERNEL); - if (!buffer) { - dev_err(&servo->udev->dev, "%s - out of memory\n", - __FUNCTION__); - return; - } - /* * The PhidgetServo v2.0 is controlled by sending two bytes. The * first byte is the servo number xor'ed with 2: @@ -291,9 +291,6 @@ dev_info(&interface->dev, "USB %d-Motor PhidgetServo v%d.0 detached\n", dev->quad_servo ? 4 : 1, dev->version); - - dev_info(&interface->dev, - "WARNING: version 2.0 not tested. Please report if this works.\n"); } static struct usb_driver servo_driver = {