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

USB: New PhidgetKit 8/8/8 reset outputs after 2 seconds

New phidget interface kits (type 8/8/8) reset their outputs if they
haven't received a set report for 2 seconds.
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 1b495f75
...@@ -44,20 +44,25 @@ struct driver_interfacekit { ...@@ -44,20 +44,25 @@ struct driver_interfacekit {
int inputs; int inputs;
int outputs; int outputs;
int has_lcd; int has_lcd;
int amnesiac;
}; };
#define ifkit(_sensors, _inputs, _outputs, _lcd) \
static struct driver_interfacekit ph_##_sensors##_inputs##_outputs = { \ #define ifkit(_sensors, _inputs, _outputs, _lcd, _amnesiac) \
{ \
.sensors = _sensors, \ .sensors = _sensors, \
.inputs = _inputs, \ .inputs = _inputs, \
.outputs = _outputs, \ .outputs = _outputs, \
.has_lcd = _lcd, \ .has_lcd = _lcd, \
.amnesiac = _amnesiac \
}; };
ifkit(0, 0, 4, 0);
ifkit(8, 8, 8, 0); static const struct driver_interfacekit ph_004 = ifkit(0, 0, 4, 0, 0);
ifkit(0, 4, 7, 1); static const struct driver_interfacekit ph_888n = ifkit(8, 8, 8, 0, 1);
ifkit(8, 8, 4, 0); static const struct driver_interfacekit ph_888o = ifkit(8, 8, 8, 0, 0);
ifkit(0, 8, 8, 1); static const struct driver_interfacekit ph_047 = ifkit(0, 4, 7, 1, 0);
ifkit(0, 16, 16, 0); static const struct driver_interfacekit ph_884 = ifkit(8, 8, 4, 0, 0);
static const struct driver_interfacekit ph_088 = ifkit(0, 8, 8, 1, 0);
static const struct driver_interfacekit ph_01616 = ifkit(0, 16, 16, 0, 0);
static unsigned long device_no; static unsigned long device_no;
...@@ -77,6 +82,7 @@ struct interfacekit { ...@@ -77,6 +82,7 @@ struct interfacekit {
dma_addr_t data_dma; dma_addr_t data_dma;
struct work_struct do_notify; struct work_struct do_notify;
struct work_struct do_resubmit;
unsigned long input_events; unsigned long input_events;
unsigned long sensor_events; unsigned long sensor_events;
}; };
...@@ -84,8 +90,10 @@ struct interfacekit { ...@@ -84,8 +90,10 @@ struct interfacekit {
static struct usb_device_id id_table[] = { static struct usb_device_id id_table[] = {
{USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT004), {USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT004),
.driver_info = (kernel_ulong_t)&ph_004}, .driver_info = (kernel_ulong_t)&ph_004},
{USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT888), {USB_DEVICE_VER(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT888, 0, 0x814),
.driver_info = (kernel_ulong_t)&ph_888}, .driver_info = (kernel_ulong_t)&ph_888o},
{USB_DEVICE_VER(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT888, 0x0815, 0xffff),
.driver_info = (kernel_ulong_t)&ph_888n},
{USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT047), {USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT047),
.driver_info = (kernel_ulong_t)&ph_047}, .driver_info = (kernel_ulong_t)&ph_047},
{USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT088), {USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT088),
...@@ -98,16 +106,11 @@ static struct usb_device_id id_table[] = { ...@@ -98,16 +106,11 @@ static struct usb_device_id id_table[] = {
}; };
MODULE_DEVICE_TABLE(usb, id_table); MODULE_DEVICE_TABLE(usb, id_table);
static int change_outputs(struct interfacekit *kit, int output_num, int enable) static int set_outputs(struct interfacekit *kit)
{ {
u8 *buffer; u8 *buffer;
int retval; int retval;
if (enable)
set_bit(output_num, &kit->outputs);
else
clear_bit(output_num, &kit->outputs);
buffer = kzalloc(4, GFP_KERNEL); buffer = kzalloc(4, GFP_KERNEL);
if (!buffer) { if (!buffer) {
dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__); dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__);
...@@ -127,6 +130,9 @@ static int change_outputs(struct interfacekit *kit, int output_num, int enable) ...@@ -127,6 +130,9 @@ static int change_outputs(struct interfacekit *kit, int output_num, int enable)
retval); retval);
kfree(buffer); kfree(buffer);
if (kit->ifkit->amnesiac)
schedule_delayed_work(&kit->do_resubmit, HZ / 2);
return retval < 0 ? retval : 0; return retval < 0 ? retval : 0;
} }
...@@ -399,19 +405,29 @@ static void do_notify(void *data) ...@@ -399,19 +405,29 @@ static void do_notify(void *data)
} }
} }
static void do_resubmit(void *data)
{
set_outputs(data);
}
#define show_set_output(value) \ #define show_set_output(value) \
static ssize_t set_output##value(struct device *dev, \ static ssize_t set_output##value(struct device *dev, \
struct device_attribute *attr, \ struct device_attribute *attr, \
const char *buf, size_t count) \ const char *buf, size_t count) \
{ \ { \
struct interfacekit *kit = dev_get_drvdata(dev); \ struct interfacekit *kit = dev_get_drvdata(dev); \
int enabled; \ int enable; \
int retval; \ int retval; \
\ \
if (sscanf(buf, "%d", &enabled) < 1) \ if (sscanf(buf, "%d", &enable) < 1) \
return -EINVAL; \ return -EINVAL; \
\ \
retval = change_outputs(kit, value - 1, enabled); \ if (enable) \
set_bit(value - 1, &kit->outputs); \
else \
clear_bit(value - 1, &kit->outputs); \
\
retval = set_outputs(kit); \
\ \
return retval ? retval : count; \ return retval ? retval : count; \
} \ } \
...@@ -560,6 +576,7 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic ...@@ -560,6 +576,7 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
kit->udev = usb_get_dev(dev); kit->udev = usb_get_dev(dev);
kit->intf = intf; kit->intf = intf;
INIT_WORK(&kit->do_notify, do_notify, kit); INIT_WORK(&kit->do_notify, do_notify, kit);
INIT_WORK(&kit->do_resubmit, do_resubmit, kit);
usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data, usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data,
maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp, maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp,
interfacekit_irq, kit, endpoint->bInterval); interfacekit_irq, kit, endpoint->bInterval);
...@@ -663,6 +680,7 @@ static void interfacekit_disconnect(struct usb_interface *interface) ...@@ -663,6 +680,7 @@ static void interfacekit_disconnect(struct usb_interface *interface)
usb_buffer_free(kit->udev, URB_INT_SIZE, kit->data, kit->data_dma); usb_buffer_free(kit->udev, URB_INT_SIZE, kit->data, kit->data_dma);
cancel_delayed_work(&kit->do_notify); cancel_delayed_work(&kit->do_notify);
cancel_delayed_work(&kit->do_resubmit);
for (i=0; i<kit->ifkit->outputs; i++) for (i=0; i<kit->ifkit->outputs; i++)
device_remove_file(kit->dev, &dev_output_attrs[i]); device_remove_file(kit->dev, &dev_output_attrs[i]);
......
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