* 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>
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",
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);
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",
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);
}
#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; \
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, \
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); \
}
static struct usb_driver servo_driver = {
- .owner = THIS_MODULE,
.name = "phidgetservo",
.probe = servo_probe,
.disconnect = servo_disconnect,