linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / usb / misc / phidgetservo.c
index b89b534..b3418d2 100644 (file)
@@ -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.
  * Jun 16, 2004: Sean Young <sean@mess.org>
  *  - cleanups
  *  - was using memory after kfree()
+ * Aug 8, 2004: Sean Young <sean@mess.org>
+ *  - set the highest angle as high as the hardware allows, there are 
+ *    some odd servos out there
+ *
  */
 
 #include <linux/config.h>
-#ifdef CONFIG_USB_DEBUG
-#define DEBUG  1
-#endif
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -87,6 +86,9 @@ change_position_v30(struct phidget_servo *servo, int servo_no, int degrees,
        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",
@@ -143,7 +145,7 @@ change_position_v30(struct phidget_servo *servo, int servo_no, int degrees,
 
        retval = usb_control_msg(servo->udev,
                                 usb_sndctrlpipe(servo->udev, 0),
-                                0x09, 0x21, 0x0200, 0x0000, buffer, 6, 2 * HZ);
+                                0x09, 0x21, 0x0200, 0x0000, buffer, 6, 2000);
 
        kfree(buffer);
 
@@ -157,6 +159,9 @@ change_position_v20(struct phidget_servo *servo, int servo_no, int degrees,
        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",
@@ -191,7 +196,7 @@ change_position_v20(struct phidget_servo *servo, int servo_no, int degrees,
 
        retval = usb_control_msg(servo->udev,
                                 usb_sndctrlpipe(servo->udev, 0),
-                                0x09, 0x21, 0x0200, 0x0000, buffer, 2, 2 * HZ);
+                                0x09, 0x21, 0x0200, 0x0000, buffer, 2, 2000);
 
        kfree(buffer);
 
@@ -199,7 +204,7 @@ change_position_v20(struct phidget_servo *servo, int servo_no, int degrees,
 }
 
 #define show_set(value)        \
-static ssize_t set_servo##value (struct device *dev,                   \
+static ssize_t set_servo##value (struct device *dev, struct device_attribute *attr,                    \
                                        const char *buf, size_t count)  \
 {                                                                      \
        int degrees, minutes, retval;                                   \
@@ -212,10 +217,8 @@ static ssize_t set_servo##value (struct device *dev,                       \
                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,    \
@@ -227,7 +230,7 @@ static ssize_t set_servo##value (struct device *dev,                        \
        return retval < 0 ? retval : count;                             \
 }                                                                      \
                                                                        \
-static ssize_t show_servo##value (struct device *dev, char *buf)       \
+static ssize_t show_servo##value (struct device *dev, struct device_attribute *attr, char *buf)        \
 {                                                                      \
        struct usb_interface *intf = to_usb_interface (dev);            \
        struct phidget_servo *servo = usb_get_intfdata (intf);          \
@@ -303,7 +306,6 @@ servo_disconnect(struct usb_interface *interface)
 }
 
 static struct usb_driver servo_driver = {
-       .owner = THIS_MODULE,
        .name = "phidgetservo",
        .probe = servo_probe,
        .disconnect = servo_disconnect,