Commit f65763d3 authored by Sean Young's avatar Sean Young Committed by Greg Kroah-Hartman

[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.
parent e6f2894b
......@@ -67,6 +67,13 @@ change_position_v30(struct phidget_servo *servo, int servo_no, int degrees,
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 @@ change_position_v30(struct phidget_servo *servo, int servo_no, int degrees,
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 @@ change_position_v20(struct phidget_servo *servo, int servo_no, int degrees,
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 @@ change_position_v20(struct phidget_servo *servo, int servo_no, int degrees,
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 @@ servo_disconnect(struct usb_interface *interface)
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 = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment