Commit 3faeeecb authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: ni_labpc: use module_comedi_pci_driver()

Use the macro `module_comedi_pci_driver(comedi_driver, pci_driver)` to
register the module as a Comedi PCI driver if the module supports PCI
devices, otherwise use `module_comedi_driver(comedi_driver)` to register
it as an ordinary Comedi driver.  Rename variables and functions that
have prefix `driver_` for consistency.  Set the `name` member of the
`struct pci_driver` variable in its initializer instead of initializing
it in the module initialization function.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1cabcd31
...@@ -492,7 +492,7 @@ static const int sample_size = 2; ...@@ -492,7 +492,7 @@ static const int sample_size = 2;
#define devpriv ((struct labpc_private *)dev->private) #define devpriv ((struct labpc_private *)dev->private)
static struct comedi_driver driver_labpc = { static struct comedi_driver labpc_driver = {
.driver_name = DRV_NAME, .driver_name = DRV_NAME,
.module = THIS_MODULE, .module = THIS_MODULE,
.attach = labpc_attach, .attach = labpc_attach,
...@@ -544,7 +544,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, ...@@ -544,7 +544,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
if (thisboard->bustype == isa_bustype) { if (thisboard->bustype == isa_bustype) {
/* check if io addresses are available */ /* check if io addresses are available */
if (!request_region(iobase, LABPC_SIZE, if (!request_region(iobase, LABPC_SIZE,
driver_labpc.driver_name)) { labpc_driver.driver_name)) {
dev_err(dev->class_dev, "I/O port conflict\n"); dev_err(dev->class_dev, "I/O port conflict\n");
return -EIO; return -EIO;
} }
...@@ -577,7 +577,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, ...@@ -577,7 +577,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
|| thisboard->bustype == pcmcia_bustype) || thisboard->bustype == pcmcia_bustype)
isr_flags |= IRQF_SHARED; isr_flags |= IRQF_SHARED;
if (request_irq(irq, labpc_interrupt, isr_flags, if (request_irq(irq, labpc_interrupt, isr_flags,
driver_labpc.driver_name, dev)) { labpc_driver.driver_name, dev)) {
dev_err(dev->class_dev, "unable to allocate irq %u\n", dev_err(dev->class_dev, "unable to allocate irq %u\n",
irq); irq);
return -EINVAL; return -EINVAL;
...@@ -599,7 +599,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, ...@@ -599,7 +599,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
"failed to allocate dma buffer\n"); "failed to allocate dma buffer\n");
return -ENOMEM; return -ENOMEM;
} }
if (request_dma(dma_chan, driver_labpc.driver_name)) { if (request_dma(dma_chan, labpc_driver.driver_name)) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
"failed to allocate dma channel %u\n", "failed to allocate dma channel %u\n",
dma_chan); dma_chan);
...@@ -772,7 +772,7 @@ static int labpc_find_device(struct comedi_device *dev, int bus, int slot) ...@@ -772,7 +772,7 @@ static int labpc_find_device(struct comedi_device *dev, int bus, int slot)
|| slot != PCI_SLOT(mite->pcidev->devfn)) || slot != PCI_SLOT(mite->pcidev->devfn))
continue; continue;
} }
for (i = 0; i < driver_labpc.num_names; i++) { for (i = 0; i < labpc_driver.num_names; i++) {
if (labpc_boards[i].bustype != pci_bustype) if (labpc_boards[i].bustype != pci_bustype)
continue; continue;
if (mite_device_id(mite) == labpc_boards[i].device_id) { if (mite_device_id(mite) == labpc_boards[i].device_id) {
...@@ -2123,56 +2123,26 @@ static void write_caldac(struct comedi_device *dev, unsigned int channel, ...@@ -2123,56 +2123,26 @@ static void write_caldac(struct comedi_device *dev, unsigned int channel,
} }
#ifdef CONFIG_COMEDI_PCI_DRIVERS #ifdef CONFIG_COMEDI_PCI_DRIVERS
static int __devinit driver_labpc_pci_probe(struct pci_dev *dev, static int __devinit labpc_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
return comedi_pci_auto_config(dev, &driver_labpc); return comedi_pci_auto_config(dev, &labpc_driver);
} }
static void __devexit driver_labpc_pci_remove(struct pci_dev *dev) static void __devexit labpc_pci_remove(struct pci_dev *dev)
{ {
comedi_pci_auto_unconfig(dev); comedi_pci_auto_unconfig(dev);
} }
static struct pci_driver driver_labpc_pci_driver = { static struct pci_driver labpc_pci_driver = {
.name = DRV_NAME,
.id_table = labpc_pci_table, .id_table = labpc_pci_table,
.probe = &driver_labpc_pci_probe, .probe = labpc_pci_probe,
.remove = __devexit_p(&driver_labpc_pci_remove) .remove = __devexit_p(labpc_pci_remove)
}; };
module_comedi_pci_driver(labpc_driver, labpc_pci_driver);
static int __init driver_labpc_init_module(void)
{
int retval;
retval = comedi_driver_register(&driver_labpc);
if (retval < 0)
return retval;
driver_labpc_pci_driver.name = (char *)driver_labpc.driver_name;
return pci_register_driver(&driver_labpc_pci_driver);
}
static void __exit driver_labpc_cleanup_module(void)
{
pci_unregister_driver(&driver_labpc_pci_driver);
comedi_driver_unregister(&driver_labpc);
}
module_init(driver_labpc_init_module);
module_exit(driver_labpc_cleanup_module);
#else #else
static int __init driver_labpc_init_module(void) module_comedi_driver(labpc_driver);
{
return comedi_driver_register(&driver_labpc);
}
static void __exit driver_labpc_cleanup_module(void)
{
comedi_driver_unregister(&driver_labpc);
}
module_init(driver_labpc_init_module);
module_exit(driver_labpc_cleanup_module);
#endif #endif
......
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