diff options
Diffstat (limited to 'drivers/staging/comedi/drivers/amplc_pc236.c')
-rw-r--r-- | drivers/staging/comedi/drivers/amplc_pc236.c | 72 |
1 files changed, 30 insertions, 42 deletions
diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index 4e4f3c15df87..289835419577 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -66,7 +66,6 @@ unused. #define DO_PCI IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) /* PCI236 PCI configuration register information */ -#define PCI_VENDOR_ID_AMPLICON 0x14dc #define PCI_DEVICE_ID_AMPLICON_PCI236 0x0009 #define PCI_DEVICE_ID_INVALID 0xffff @@ -332,28 +331,13 @@ static int pc236_intr_cmdtest(struct comedi_device *dev, if (err) return 2; - /* step 3: */ + /* Step 3: check it arguments are trivially valid */ - if (cmd->start_arg != 0) { - cmd->start_arg = 0; - err++; - } - if (cmd->scan_begin_arg != 0) { - cmd->scan_begin_arg = 0; - err++; - } - if (cmd->convert_arg != 0) { - cmd->convert_arg = 0; - err++; - } - if (cmd->scan_end_arg != 1) { - cmd->scan_end_arg = 1; - err++; - } - if (cmd->stop_arg != 0) { - cmd->stop_arg = 0; - err++; - } + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1); + err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); if (err) return 3; @@ -505,14 +489,16 @@ static int pc236_pci_common_attach(struct comedi_device *dev, static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct pc236_board *thisboard = comedi_board(dev); + struct pc236_private *devpriv; int ret; dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach\n"); - ret = alloc_private(dev, sizeof(struct pc236_private)); - if (ret < 0) { - dev_err(dev->class_dev, "error! out of memory!\n"); - return ret; - } + + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + if (!devpriv) + return -ENOMEM; + dev->private = devpriv; + /* Process options according to bus type. */ if (is_isa_board(thisboard)) { unsigned long iobase = it->options[0]; @@ -536,25 +522,27 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it) } /* - * The attach_pci hook (if non-NULL) is called at PCI probe time in preference - * to the "manual" attach hook. dev->board_ptr is NULL on entry. There should - * be a board entry matching the supplied PCI device. + * The auto_attach hook is called at PCI probe time via + * comedi_pci_auto_config(). dev->board_ptr is NULL on entry. + * There should be a board entry matching the supplied PCI device. */ -static int __devinit pc236_attach_pci(struct comedi_device *dev, - struct pci_dev *pci_dev) +static int pc236_auto_attach(struct comedi_device *dev, + unsigned long context_unused) { - int ret; + struct pci_dev *pci_dev = comedi_to_pci_dev(dev); + struct pc236_private *devpriv; if (!DO_PCI) return -EINVAL; dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach pci %s\n", pci_name(pci_dev)); - ret = alloc_private(dev, sizeof(struct pc236_private)); - if (ret < 0) { - dev_err(dev->class_dev, "error! out of memory!\n"); - return ret; - } + + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + if (!devpriv) + return -ENOMEM; + dev->private = devpriv; + dev->board_ptr = pc236_find_pci_board(pci_dev); if (dev->board_ptr == NULL) { dev_err(dev->class_dev, "BUG! cannot determine board type!\n"); @@ -605,7 +593,7 @@ static struct comedi_driver amplc_pc236_driver = { .driver_name = PC236_DRIVER_NAME, .module = THIS_MODULE, .attach = pc236_attach, - .attach_pci = pc236_attach_pci, + .auto_attach = pc236_auto_attach, .detach = pc236_detach, .board_name = &pc236_boards[0].name, .offset = sizeof(struct pc236_board), @@ -620,13 +608,13 @@ static DEFINE_PCI_DEVICE_TABLE(pc236_pci_table) = { MODULE_DEVICE_TABLE(pci, pc236_pci_table); -static int __devinit amplc_pc236_pci_probe(struct pci_dev *dev, +static int amplc_pc236_pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) { return comedi_pci_auto_config(dev, &lc_pc236_driver); } -static void __devexit amplc_pc236_pci_remove(struct pci_dev *dev) +static void amplc_pc236_pci_remove(struct pci_dev *dev) { comedi_pci_auto_unconfig(dev); } @@ -635,7 +623,7 @@ static struct pci_driver amplc_pc236_pci_driver = { .name = PC236_DRIVER_NAME, .id_table = pc236_pci_table, .probe = &lc_pc236_pci_probe, - .remove = __devexit_p(&lc_pc236_pci_remove) + .remove = &lc_pc236_pci_remove }; module_comedi_pci_driver(amplc_pc236_driver, amplc_pc236_pci_driver); |