aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH Hartley Sweeten <hartleys@visionengravers.com>2012-05-15 18:10:25 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-15 20:56:53 -0400
commit48b992b49f56f03a425a42c6d7fefe72c8d5648e (patch)
tree04570d15a066dba74b27f460cd1482053527267f
parentecdc3e0d12c3c94abc9e3d7903ea55e7c1f350bb (diff)
staging: comedi: refactor cb_pcimdda 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>
-rw-r--r--drivers/staging/comedi/drivers/cb_pcimdda.c109
1 files changed, 38 insertions, 71 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c
index 8d1081e9a798..857d0c3dd518 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdda.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdda.c
@@ -140,17 +140,6 @@ static const struct board_struct boards[] = {
140#define REG_SZ (thisboard->reg_sz) 140#define REG_SZ (thisboard->reg_sz)
141#define REGS_BADRINDEX (thisboard->regs_badrindex) 141#define REGS_BADRINDEX (thisboard->regs_badrindex)
142 142
143/* This is used by modprobe to translate PCI IDs to drivers. Should
144 * only be used for PCI and ISA-PnP devices */
145/* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
146 * upstream. */
147static DEFINE_PCI_DEVICE_TABLE(pci_table) = {
148 { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, PCI_ID_PCIM_DDA06_16) },
149 {0}
150};
151
152MODULE_DEVICE_TABLE(pci, pci_table);
153
154/* 143/*
155 * this structure is for data unique to this hardware driver. If 144 * this structure is for data unique to this hardware driver. If
156 * several hardware drivers keep similar information in this structure, 145 * several hardware drivers keep similar information in this structure,
@@ -177,66 +166,6 @@ struct board_private_struct {
177 */ 166 */
178#define devpriv ((struct board_private_struct *)dev->private) 167#define devpriv ((struct board_private_struct *)dev->private)
179 168
180/*
181 * The struct comedi_driver structure tells the Comedi core module
182 * which functions to call to configure/deconfigure (attach/detach)
183 * the board, and also about the kernel module that contains
184 * the device code.
185 */
186static int attach(struct comedi_device *dev, struct comedi_devconfig *it);
187static int detach(struct comedi_device *dev);
188static struct comedi_driver cb_pcimdda_driver = {
189 .driver_name = "cb_pcimdda",
190 .module = THIS_MODULE,
191 .attach = attach,
192 .detach = detach,
193};
194
195MODULE_AUTHOR("Calin A. Culianu <calin@rtlab.org>");
196MODULE_DESCRIPTION("Comedi low-level driver for the Computerboards PCIM-DDA "
197 "series. Currently only supports PCIM-DDA06-16 (which "
198 "also happens to be the only board in this series. :) ) ");
199MODULE_LICENSE("GPL");
200static int __devinit cb_pcimdda_driver_pci_probe(struct pci_dev *dev,
201 const struct pci_device_id
202 *ent)
203{
204 return comedi_pci_auto_config(dev, &cb_pcimdda_driver);
205}
206
207static void __devexit cb_pcimdda_driver_pci_remove(struct pci_dev *dev)
208{
209 comedi_pci_auto_unconfig(dev);
210}
211
212static struct pci_driver cb_pcimdda_driver_pci_driver = {
213 .id_table = pci_table,
214 .probe = &cb_pcimdda_driver_pci_probe,
215 .remove = __devexit_p(&cb_pcimdda_driver_pci_remove)
216};
217
218static int __init cb_pcimdda_driver_init_module(void)
219{
220 int retval;
221
222 retval = comedi_driver_register(&cb_pcimdda_driver);
223 if (retval < 0)
224 return retval;
225
226 cb_pcimdda_driver_pci_driver.name =
227 (char *)cb_pcimdda_driver.driver_name;
228 return pci_register_driver(&cb_pcimdda_driver_pci_driver);
229}
230
231static void __exit cb_pcimdda_driver_cleanup_module(void)
232{
233 pci_unregister_driver(&cb_pcimdda_driver_pci_driver);
234 comedi_driver_unregister(&cb_pcimdda_driver);
235}
236
237module_init(cb_pcimdda_driver_init_module);
238module_exit(cb_pcimdda_driver_cleanup_module);
239
240static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, 169static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
241 struct comedi_insn *insn, unsigned int *data); 170 struct comedi_insn *insn, unsigned int *data);
242static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, 171static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -515,3 +444,41 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it)
515 "card found at the requested position\n"); 444 "card found at the requested position\n");
516 return -ENODEV; 445 return -ENODEV;
517} 446}
447
448static struct comedi_driver cb_pcimdda_driver = {
449 .driver_name = "cb_pcimdda",
450 .module = THIS_MODULE,
451 .attach = attach,
452 .detach = detach,
453};
454
455static int __devinit cb_pcimdda_pci_probe(struct pci_dev *dev,
456 const struct pci_device_id *ent)
457{
458 return comedi_pci_auto_config(dev, &cb_pcimdda_driver);
459}
460
461static void __devexit cb_pcimdda_pci_remove(struct pci_dev *dev)
462{
463 comedi_pci_auto_unconfig(dev);
464}
465
466static DEFINE_PCI_DEVICE_TABLE(cb_pcimdda_pci_table) = {
467 { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, PCI_ID_PCIM_DDA06_16) },
468 { 0 }
469};
470MODULE_DEVICE_TABLE(pci, cb_pcimdda_pci_table);
471
472static struct pci_driver cb_pcimdda_driver_pci_driver = {
473 .name = "cb_pcimdda",
474 .id_table = cb_pcimdda_pci_table,
475 .probe = cb_pcimdda_pci_probe,
476 .remove = __devexit_p(cb_pcimdda_pci_remove),
477};
478module_comedi_pci_driver(cb_pcimdda_driver, cb_pcimdda_driver_pci_driver);
479
480MODULE_AUTHOR("Calin A. Culianu <calin@rtlab.org>");
481MODULE_DESCRIPTION("Comedi low-level driver for the Computerboards PCIM-DDA "
482 "series. Currently only supports PCIM-DDA06-16 (which "
483 "also happens to be the only board in this series. :) ) ");
484MODULE_LICENSE("GPL");