From 3974c5c08d50fb3a23ec825186a60535264142e8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Oct 2012 16:51:16 -0700 Subject: [PATCH] staging: comedi: addi_common: move module init code to EOF Move the module_{init,exit} code and associated variables to the end of the file. Use module_comedi_pci_driver() to remove the module init boilerplate. For aesthetic reasons, rename the comedi_driver and pci_driver from driver_* to *_driver. Remove the forward declarations for i_ADDI_{Attach,Detach}. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/addi_common.c | 77 +++++++------------ .../comedi/drivers/addi-data/addi_common.h | 2 - 2 files changed, 29 insertions(+), 50 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c index b166698c8469..6d7f6ea45c6d 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c @@ -1401,54 +1401,6 @@ static const struct addi_board boardtypes[] = { #endif }; -static struct comedi_driver driver_addi = { - .driver_name = ADDIDATA_DRIVER_NAME, - .module = THIS_MODULE, - .attach = i_ADDI_Attach, - .detach = i_ADDI_Detach, - .num_names = ARRAY_SIZE(boardtypes), - .board_name = &boardtypes[0].pc_DriverName, - .offset = sizeof(struct addi_board), -}; - -static int __devinit driver_addi_pci_probe(struct pci_dev *dev, - const struct pci_device_id *ent) -{ - return comedi_pci_auto_config(dev, &driver_addi); -} - -static void __devexit driver_addi_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - -static struct pci_driver driver_addi_pci_driver = { - .id_table = addi_apci_tbl, - .probe = &driver_addi_pci_probe, - .remove = __devexit_p(&driver_addi_pci_remove) -}; - -static int __init driver_addi_init_module(void) -{ - int retval; - - retval = comedi_driver_register(&driver_addi); - if (retval < 0) - return retval; - - driver_addi_pci_driver.name = (char *)driver_addi.driver_name; - return pci_register_driver(&driver_addi_pci_driver); -} - -static void __exit driver_addi_cleanup_module(void) -{ - pci_unregister_driver(&driver_addi_pci_driver); - comedi_driver_unregister(&driver_addi); -} - -module_init(driver_addi_init_module); -module_exit(driver_addi_cleanup_module); - /* +----------------------------------------------------------------------------+ | Function name :static int i_ADDI_Attach(struct comedi_device *dev, | @@ -1938,3 +1890,32 @@ static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, struct comedi_su return insn->n; } + +static struct comedi_driver addi_driver = { + .driver_name = ADDIDATA_DRIVER_NAME, + .module = THIS_MODULE, + .attach = i_ADDI_Attach, + .detach = i_ADDI_Detach, + .num_names = ARRAY_SIZE(boardtypes), + .board_name = &boardtypes[0].pc_DriverName, + .offset = sizeof(struct addi_board), +}; + +static int __devinit addi_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, &addi_driver); +} + +static void __devexit addi_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver addi_pci_driver = { + .name = ADDIDATA_DRIVER_NAME, + .id_table = addi_apci_tbl, + .probe = &addi_pci_probe, + .remove = __devexit_p(&addi_pci_remove), +}; +module_comedi_pci_driver(addi_driver, addi_pci_driver); diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index b7bbb7164f58..60047dec4afa 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -414,8 +414,6 @@ struct addi_private { static unsigned short pci_list_builded; /* set to 1 when list of card is known */ /* Function declarations */ -static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it); -static void i_ADDI_Detach(struct comedi_device *dev); static int i_ADDI_Reset(struct comedi_device *dev); static irqreturn_t v_ADDI_Interrupt(int irq, void *d); -- 2.39.5