Commit 007ff2af authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: vmk80xx: refactor init code

Refactor the usb driver probe/disconnect and comedi driver attach/
detach to follow the style of the other comedi driver types to
improve maintainability.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d6cc3ec8
...@@ -64,37 +64,11 @@ Status: works ...@@ -64,37 +64,11 @@ Status: works
#include "../comedidev.h" #include "../comedidev.h"
#define BOARDNAME "vmk80xx"
MODULE_AUTHOR("Manuel Gebele <forensixs@gmx.de>");
MODULE_DESCRIPTION("Velleman USB Board Low-Level Driver");
MODULE_SUPPORTED_DEVICE("K8055/K8061 aka VM110/VM140");
MODULE_VERSION("0.8.01");
MODULE_LICENSE("GPL");
enum { enum {
DEVICE_VMK8055, DEVICE_VMK8055,
DEVICE_VMK8061 DEVICE_VMK8061
}; };
static const struct usb_device_id vmk80xx_id_table[] = {
{USB_DEVICE(0x10cf, 0x5500), .driver_info = DEVICE_VMK8055},
{USB_DEVICE(0x10cf, 0x5501), .driver_info = DEVICE_VMK8055},
{USB_DEVICE(0x10cf, 0x5502), .driver_info = DEVICE_VMK8055},
{USB_DEVICE(0x10cf, 0x5503), .driver_info = DEVICE_VMK8055},
{USB_DEVICE(0x10cf, 0x8061), .driver_info = DEVICE_VMK8061},
{USB_DEVICE(0x10cf, 0x8062), .driver_info = DEVICE_VMK8061},
{USB_DEVICE(0x10cf, 0x8063), .driver_info = DEVICE_VMK8061},
{USB_DEVICE(0x10cf, 0x8064), .driver_info = DEVICE_VMK8061},
{USB_DEVICE(0x10cf, 0x8065), .driver_info = DEVICE_VMK8061},
{USB_DEVICE(0x10cf, 0x8066), .driver_info = DEVICE_VMK8061},
{USB_DEVICE(0x10cf, 0x8067), .driver_info = DEVICE_VMK8061},
{USB_DEVICE(0x10cf, 0x8068), .driver_info = DEVICE_VMK8061},
{} /* terminating entry */
};
MODULE_DEVICE_TABLE(usb, vmk80xx_id_table);
#define VMK8055_DI_REG 0x00 #define VMK8055_DI_REG 0x00
#define VMK8055_DO_REG 0x01 #define VMK8055_DO_REG 0x01
#define VMK8055_AO1_REG 0x02 #define VMK8055_AO1_REG 0x02
...@@ -232,8 +206,6 @@ static struct vmk80xx_usb vmb[VMK80XX_MAX_BOARDS]; ...@@ -232,8 +206,6 @@ static struct vmk80xx_usb vmb[VMK80XX_MAX_BOARDS];
static DEFINE_MUTEX(glb_mutex); static DEFINE_MUTEX(glb_mutex);
static struct comedi_driver vmk80xx_driver; /* see below for initializer */
static void vmk80xx_tx_callback(struct urb *urb) static void vmk80xx_tx_callback(struct urb *urb)
{ {
struct vmk80xx_usb *dev = urb->context; struct vmk80xx_usb *dev = urb->context;
...@@ -1267,8 +1239,16 @@ static void vmk80xx_detach(struct comedi_device *dev) ...@@ -1267,8 +1239,16 @@ static void vmk80xx_detach(struct comedi_device *dev)
} }
} }
static int vmk80xx_probe(struct usb_interface *intf, static struct comedi_driver vmk80xx_driver = {
const struct usb_device_id *id) .module = THIS_MODULE,
.driver_name = "vmk80xx",
.attach = vmk80xx_attach,
.detach = vmk80xx_detach,
.attach_usb = vmk80xx_attach_usb,
};
static int vmk80xx_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{ {
int i; int i;
struct vmk80xx_usb *dev; struct vmk80xx_usb *dev;
...@@ -1419,7 +1399,7 @@ static int vmk80xx_probe(struct usb_interface *intf, ...@@ -1419,7 +1399,7 @@ static int vmk80xx_probe(struct usb_interface *intf,
return -ENODEV; return -ENODEV;
} }
static void vmk80xx_disconnect(struct usb_interface *intf) static void vmk80xx_usb_disconnect(struct usb_interface *intf)
{ {
struct vmk80xx_usb *dev = usb_get_intfdata(intf); struct vmk80xx_usb *dev = usb_get_intfdata(intf);
...@@ -1447,20 +1427,35 @@ static void vmk80xx_disconnect(struct usb_interface *intf) ...@@ -1447,20 +1427,35 @@ static void vmk80xx_disconnect(struct usb_interface *intf)
mutex_unlock(&glb_mutex); mutex_unlock(&glb_mutex);
} }
static const struct usb_device_id vmk80xx_usb_id_table[] = {
{ USB_DEVICE(0x10cf, 0x5500), .driver_info = DEVICE_VMK8055 },
{ USB_DEVICE(0x10cf, 0x5501), .driver_info = DEVICE_VMK8055 },
{ USB_DEVICE(0x10cf, 0x5502), .driver_info = DEVICE_VMK8055 },
{ USB_DEVICE(0x10cf, 0x5503), .driver_info = DEVICE_VMK8055 },
{ USB_DEVICE(0x10cf, 0x8061), .driver_info = DEVICE_VMK8061 },
{ USB_DEVICE(0x10cf, 0x8062), .driver_info = DEVICE_VMK8061 },
{ USB_DEVICE(0x10cf, 0x8063), .driver_info = DEVICE_VMK8061 },
{ USB_DEVICE(0x10cf, 0x8064), .driver_info = DEVICE_VMK8061 },
{ USB_DEVICE(0x10cf, 0x8065), .driver_info = DEVICE_VMK8061 },
{ USB_DEVICE(0x10cf, 0x8066), .driver_info = DEVICE_VMK8061 },
{ USB_DEVICE(0x10cf, 0x8067), .driver_info = DEVICE_VMK8061 },
{ USB_DEVICE(0x10cf, 0x8068), .driver_info = DEVICE_VMK8061 },
{ }
};
MODULE_DEVICE_TABLE(usb, vmk80xx_usb_id_table);
/* TODO: Add support for suspend, resume, pre_reset, /* TODO: Add support for suspend, resume, pre_reset,
* post_reset and flush */ * post_reset and flush */
static struct usb_driver vmk80xx_usb_driver = { static struct usb_driver vmk80xx_usb_driver = {
.name = "vmk80xx", .name = "vmk80xx",
.probe = vmk80xx_probe, .probe = vmk80xx_usb_probe,
.disconnect = vmk80xx_disconnect, .disconnect = vmk80xx_usb_disconnect,
.id_table = vmk80xx_id_table .id_table = vmk80xx_usb_id_table,
};
static struct comedi_driver vmk80xx_driver = {
.module = THIS_MODULE,
.driver_name = "vmk80xx",
.attach = vmk80xx_attach,
.detach = vmk80xx_detach,
.attach_usb = vmk80xx_attach_usb,
}; };
module_comedi_usb_driver(vmk80xx_driver, vmk80xx_usb_driver); module_comedi_usb_driver(vmk80xx_driver, vmk80xx_usb_driver);
MODULE_AUTHOR("Manuel Gebele <forensixs@gmx.de>");
MODULE_DESCRIPTION("Velleman USB Board Low-Level Driver");
MODULE_SUPPORTED_DEVICE("K8055/K8061 aka VM110/VM140");
MODULE_VERSION("0.8.01");
MODULE_LICENSE("GPL");
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