提交 958c5989 编写于 作者: H H Hartley Sweeten 提交者: Greg Kroah-Hartman

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: NH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 c95dbeac
......@@ -191,10 +191,6 @@ static const struct comedi_lrange range_pci171x_da = { 2, {
}
};
static int pci1710_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
static int pci1710_detach(struct comedi_device *dev);
struct boardtype {
const char *name; /* board name */
int device_id;
......@@ -216,17 +212,6 @@ struct boardtype {
unsigned int fifo_half_size; /* size of FIFO/2 */
};
static DEFINE_PCI_DEVICE_TABLE(pci1710_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1710) },
{ PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1711) },
{ PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1713) },
{ PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1720) },
{ PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1731) },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, pci1710_pci_table);
static const struct boardtype boardtypes[] = {
{"pci1710", 0x1710,
IORANGE_171x, 1, TYPE_PCI171X,
......@@ -264,16 +249,6 @@ static const struct boardtype boardtypes[] = {
{.name = DRV_NAME},
};
static struct comedi_driver driver_pci1710 = {
.driver_name = DRV_NAME,
.module = THIS_MODULE,
.attach = pci1710_attach,
.detach = pci1710_detach,
.num_names = ARRAY_SIZE(boardtypes),
.board_name = &boardtypes[0].name,
.offset = sizeof(struct boardtype),
};
struct pci1710_private {
struct pci_dev *pcidev; /* ptr to PCI device */
char valid; /* card is usable */
......@@ -1360,9 +1335,6 @@ static int pci1710_reset(struct comedi_device *dev)
DPRINTK("adv_pci1710 EDBG: END: pci1710_reset(...)\n");
}
/*
==============================================================================
*/
static int pci1710_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
......@@ -1579,12 +1551,8 @@ static int pci1710_attach(struct comedi_device *dev,
return 0;
}
/*
==============================================================================
*/
static int pci1710_detach(struct comedi_device *dev)
{
if (dev->private) {
if (devpriv->valid)
pci1710_reset(dev);
......@@ -1601,49 +1569,44 @@ static int pci1710_detach(struct comedi_device *dev)
return 0;
}
/*
==============================================================================
*/
static int __devinit driver_pci1710_pci_probe(struct pci_dev *dev,
static struct comedi_driver adv_pci1710_driver = {
.driver_name = "adv_pci1710",
.module = THIS_MODULE,
.attach = pci1710_attach,
.detach = pci1710_detach,
.num_names = ARRAY_SIZE(boardtypes),
.board_name = &boardtypes[0].name,
.offset = sizeof(struct boardtype),
};
static int __devinit adv_pci1710_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
return comedi_pci_auto_config(dev, &driver_pci1710);
return comedi_pci_auto_config(dev, &adv_pci1710_driver);
}
static void __devexit driver_pci1710_pci_remove(struct pci_dev *dev)
static void __devexit adv_pci1710_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
static struct pci_driver driver_pci1710_pci_driver = {
.id_table = pci1710_pci_table,
.probe = &driver_pci1710_pci_probe,
.remove = __devexit_p(&driver_pci1710_pci_remove)
static DEFINE_PCI_DEVICE_TABLE(adv_pci1710_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1710) },
{ PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1711) },
{ PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1713) },
{ PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1720) },
{ PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1731) },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, adv_pci1710_pci_table);
static int __init driver_pci1710_init_module(void)
{
int retval;
retval = comedi_driver_register(&driver_pci1710);
if (retval < 0)
return retval;
driver_pci1710_pci_driver.name = (char *)driver_pci1710.driver_name;
return pci_register_driver(&driver_pci1710_pci_driver);
}
static void __exit driver_pci1710_cleanup_module(void)
{
pci_unregister_driver(&driver_pci1710_pci_driver);
comedi_driver_unregister(&driver_pci1710);
}
module_init(driver_pci1710_init_module);
module_exit(driver_pci1710_cleanup_module);
/*
==============================================================================
*/
static struct pci_driver adv_pci1710_pci_driver = {
.name = "adv_pci1710",
.id_table = adv_pci1710_pci_table,
.probe = adv_pci1710_pci_probe,
.remove = __devexit_p(adv_pci1710_pci_remove),
};
module_comedi_pci_driver(adv_pci1710_driver, adv_pci1710_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册