staging: comedi: vmk80xx: refactor init code
PATCH 5/8 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 H Hartley Sweeten <[email protected]>
Cc Ian Abbott <[email protected]>
Cc Frank Mori Hess <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
--- drivers/staging/comedi/drivers/vmk80xx.c | 79 +++++++++++++++----------------- 1 file changed, 37 insertions(+), 42 deletions(-)
drivers/staging/comedi/drivers/vmk80xx.c +37 -42
@@ -64,37 +64,11 @@ Changelog:#include "../comedidev.h" -#define BOARDNAME "vmk80xx" - -MODULE_AUTHOR ("Manuel Gebele <[email protected]>" ); -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 {DEVICE_VMK8055 ,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_DO_REG 0x01#define VMK8055_AO1_REG 0x02
@@ -232,8 +206,6 @@ static struct vmk80xx_usb vmb[VMK80XX_MAX_BOARDS];static DEFINE_MUTEX (glb_mutex); -static struct comedi_driver vmk80xx_driver;/* see below for initializer */ -static void vmk80xx_tx_callback (struct urb *urb) {struct vmk80xx_usb *dev = urb->context;
@@ -1267,8 +1239,16 @@ static void vmk80xx_detach(struct comedi_device *dev) } } -static int vmk80xx_probe (struct usb_interface *intf, -const struct usb_device_id *id) +static struct comedi_driver vmk80xx_driver = { + .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;struct vmk80xx_usb *dev;
@@ -1419,7 +1399,7 @@ error: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);
@@ -1447,20 +1427,35 @@ static void vmk80xx_disconnect(struct usb_interface *intf)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, * post_reset and flush */ static struct usb_driver vmk80xx_usb_driver = { .name ="vmk80xx" , - .probe = vmk80xx_probe, - .disconnect = vmk80xx_disconnect, - .id_table = vmk80xx_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, + .probe = vmk80xx_usb_probe, + .disconnect = vmk80xx_usb_disconnect, + .id_table = vmk80xx_usb_id_table, };module_comedi_usb_driver (vmk80xx_driver, vmk80xx_usb_driver); + +MODULE_AUTHOR ("Manuel Gebele <[email protected]>" ); +MODULE_DESCRIPTION ("Velleman USB Board Low-Level Driver" ); +MODULE_SUPPORTED_DEVICE ("K8055/K8061 aka VM110/VM140" ); +MODULE_VERSION ("0.8.01" ); +MODULE_LICENSE ("GPL" );
Signature · 1 line
1.7.11