Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: comedi: refactor adv_pci1710 driver and use module_comedi_pci_driver

Move the module_init/module_exit routines and the associated
struct comedi_drive and struct pci_driver to the end of the
source. This is more typical of how other drivers are written and
removes the need for the forward declarations.

Convert the driver to use the module_comedi_pci_driver() macro
which makes the code smaller and a bit simpler.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

H Hartley Sweeten and committed by
Greg Kroah-Hartman
958c5989 c95dbeac

+29 -66
+29 -66
drivers/staging/comedi/drivers/adv_pci1710.c
··· 191 191 } 192 192 }; 193 193 194 - static int pci1710_attach(struct comedi_device *dev, 195 - struct comedi_devconfig *it); 196 - static int pci1710_detach(struct comedi_device *dev); 197 - 198 194 struct boardtype { 199 195 const char *name; /* board name */ 200 196 int device_id; ··· 211 215 unsigned int ai_ns_min; /* max sample speed of card v ns */ 212 216 unsigned int fifo_half_size; /* size of FIFO/2 */ 213 217 }; 214 - 215 - static DEFINE_PCI_DEVICE_TABLE(pci1710_pci_table) = { 216 - { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1710) }, 217 - { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1711) }, 218 - { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1713) }, 219 - { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1720) }, 220 - { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1731) }, 221 - { 0 } 222 - }; 223 - 224 - MODULE_DEVICE_TABLE(pci, pci1710_pci_table); 225 218 226 219 static const struct boardtype boardtypes[] = { 227 220 {"pci1710", 0x1710, ··· 247 262 10000, 512}, 248 263 /* dummy entry corresponding to driver name */ 249 264 {.name = DRV_NAME}, 250 - }; 251 - 252 - static struct comedi_driver driver_pci1710 = { 253 - .driver_name = DRV_NAME, 254 - .module = THIS_MODULE, 255 - .attach = pci1710_attach, 256 - .detach = pci1710_detach, 257 - .num_names = ARRAY_SIZE(boardtypes), 258 - .board_name = &boardtypes[0].name, 259 - .offset = sizeof(struct boardtype), 260 265 }; 261 266 262 267 struct pci1710_private { ··· 1335 1360 DPRINTK("adv_pci1710 EDBG: END: pci1710_reset(...)\n"); 1336 1361 } 1337 1362 1338 - /* 1339 - ============================================================================== 1340 - */ 1341 1363 static int pci1710_attach(struct comedi_device *dev, 1342 1364 struct comedi_devconfig *it) 1343 1365 { ··· 1551 1579 return 0; 1552 1580 } 1553 1581 1554 - /* 1555 - ============================================================================== 1556 - */ 1557 1582 static int pci1710_detach(struct comedi_device *dev) 1558 1583 { 1559 - 1560 1584 if (dev->private) { 1561 1585 if (devpriv->valid) 1562 1586 pci1710_reset(dev); ··· 1569 1601 return 0; 1570 1602 } 1571 1603 1572 - /* 1573 - ============================================================================== 1574 - */ 1575 - static int __devinit driver_pci1710_pci_probe(struct pci_dev *dev, 1576 - const struct pci_device_id *ent) 1604 + static struct comedi_driver adv_pci1710_driver = { 1605 + .driver_name = "adv_pci1710", 1606 + .module = THIS_MODULE, 1607 + .attach = pci1710_attach, 1608 + .detach = pci1710_detach, 1609 + .num_names = ARRAY_SIZE(boardtypes), 1610 + .board_name = &boardtypes[0].name, 1611 + .offset = sizeof(struct boardtype), 1612 + }; 1613 + 1614 + static int __devinit adv_pci1710_pci_probe(struct pci_dev *dev, 1615 + const struct pci_device_id *ent) 1577 1616 { 1578 - return comedi_pci_auto_config(dev, &driver_pci1710); 1617 + return comedi_pci_auto_config(dev, &adv_pci1710_driver); 1579 1618 } 1580 1619 1581 - static void __devexit driver_pci1710_pci_remove(struct pci_dev *dev) 1620 + static void __devexit adv_pci1710_pci_remove(struct pci_dev *dev) 1582 1621 { 1583 1622 comedi_pci_auto_unconfig(dev); 1584 1623 } 1585 1624 1586 - static struct pci_driver driver_pci1710_pci_driver = { 1587 - .id_table = pci1710_pci_table, 1588 - .probe = &driver_pci1710_pci_probe, 1589 - .remove = __devexit_p(&driver_pci1710_pci_remove) 1625 + static DEFINE_PCI_DEVICE_TABLE(adv_pci1710_pci_table) = { 1626 + { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1710) }, 1627 + { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1711) }, 1628 + { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1713) }, 1629 + { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1720) }, 1630 + { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1731) }, 1631 + { 0 } 1590 1632 }; 1633 + MODULE_DEVICE_TABLE(pci, adv_pci1710_pci_table); 1591 1634 1592 - static int __init driver_pci1710_init_module(void) 1593 - { 1594 - int retval; 1595 - 1596 - retval = comedi_driver_register(&driver_pci1710); 1597 - if (retval < 0) 1598 - return retval; 1599 - 1600 - driver_pci1710_pci_driver.name = (char *)driver_pci1710.driver_name; 1601 - return pci_register_driver(&driver_pci1710_pci_driver); 1602 - } 1603 - 1604 - static void __exit driver_pci1710_cleanup_module(void) 1605 - { 1606 - pci_unregister_driver(&driver_pci1710_pci_driver); 1607 - comedi_driver_unregister(&driver_pci1710); 1608 - } 1609 - 1610 - module_init(driver_pci1710_init_module); 1611 - module_exit(driver_pci1710_cleanup_module); 1612 - /* 1613 - ============================================================================== 1614 - */ 1635 + static struct pci_driver adv_pci1710_pci_driver = { 1636 + .name = "adv_pci1710", 1637 + .id_table = adv_pci1710_pci_table, 1638 + .probe = adv_pci1710_pci_probe, 1639 + .remove = __devexit_p(adv_pci1710_pci_remove), 1640 + }; 1641 + module_comedi_pci_driver(adv_pci1710_driver, adv_pci1710_pci_driver); 1615 1642 1616 1643 MODULE_AUTHOR("Comedi http://www.comedi.org"); 1617 1644 MODULE_DESCRIPTION("Comedi low-level driver");