ChangeSet 1.1843.4.1, 2004/08/24 11:38:15-07:00, [EMAIL PROTECTED] [PATCH] USB: USB PhidgetServo driver update
Once again a (small) patch for the phidgetservo driver. Some servos have a very high maximum angle, set upper limit to the maximum allowed by the hardware. Reported by Mario Scholz <[EMAIL PROTECTED]> Signed-off-by: Sean Young <[EMAIL PROTECTED]> Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]> drivers/usb/misc/phidgetservo.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff -Nru a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c --- a/drivers/usb/misc/phidgetservo.c 2004-08-26 16:43:54 -07:00 +++ b/drivers/usb/misc/phidgetservo.c 2004-08-26 16:43:54 -07:00 @@ -12,8 +12,6 @@ * controllers available at: http://www.phidgets.com/ * * Note that the driver takes input as: degrees.minutes - * -23 < degrees < 203 - * 0 < minutes < 59 * * CAUTION: Generally you should use 0 < degrees < 180 as anything else * is probably beyond the range of your servo and may damage it. @@ -21,6 +19,10 @@ * Jun 16, 2004: Sean Young <[EMAIL PROTECTED]> * - cleanups * - was using memory after kfree() + * Aug 8, 2004: Sean Young <[EMAIL PROTECTED]> + * - set the highest angle as high as the hardware allows, there are + * some odd servos out there + * */ #include <linux/config.h> @@ -87,6 +89,9 @@ int retval; unsigned char *buffer; + if (degrees < -23 || degrees > 362) + return -EINVAL; + buffer = kmalloc(6, GFP_KERNEL); if (!buffer) { dev_err(&servo->udev->dev, "%s - out of memory\n", @@ -157,6 +162,9 @@ int retval; unsigned char *buffer; + if (degrees < -23 || degrees > 278) + return -EINVAL; + buffer = kmalloc(2, GFP_KERNEL); if (!buffer) { dev_err(&servo->udev->dev, "%s - out of memory\n", @@ -212,10 +220,8 @@ return -EINVAL; \ } \ \ - if (degrees < -23 || degrees > (180 + 23) || \ - minutes < 0 || minutes > 59) { \ + if (minutes < 0 || minutes > 59) \ return -EINVAL; \ - } \ \ if (servo->type & SERVO_VERSION_30) \ retval = change_position_v30 (servo, value, degrees, \ ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel