From: H Hartley Sweeten Date: Wed, 13 Mar 2013 17:36:31 +0000 (-0700) Subject: staging: comedi_pci: pass comedi_device to comedi_pci_enable() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=818f569fe930c5b8a05d1a44ece3c63c99c13c88;p=openwrt%2Fstaging%2Fblogic.git staging: comedi_pci: pass comedi_device to comedi_pci_enable() Make comedi_pci_enable() use the same parameter type as comedi_pci_disable(). This also allows comedi_pci_enable to automatically determine the resource name passed to pci_request_regions(). Make sure the errno value returned is passed on instead of assuming an errno. Also, remove any kernel noise that is generated when the call fails. The National Instruments drivers that use the mite module currently enable the PCI device in the mite module. For those drivers move the call to comedi_pci_enable into the driver. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/comedi_pci.c b/drivers/staging/comedi/comedi_pci.c index bee012c1e6a2..b164b0353ebe 100644 --- a/drivers/staging/comedi/comedi_pci.c +++ b/drivers/staging/comedi/comedi_pci.c @@ -36,18 +36,23 @@ EXPORT_SYMBOL_GPL(comedi_to_pci_dev); /** * comedi_pci_enable() - Enable the PCI device and request the regions. - * @pcidev: pci_dev struct - * @res_name: name for the requested reqource + * @dev: comedi_device struct */ -int comedi_pci_enable(struct pci_dev *pcidev, const char *res_name) +int comedi_pci_enable(struct comedi_device *dev) { + struct pci_dev *pcidev = comedi_to_pci_dev(dev); int rc; + if (!pcidev) + return -ENODEV; + rc = pci_enable_device(pcidev); if (rc < 0) return rc; - rc = pci_request_regions(pcidev, res_name); + rc = pci_request_regions(pcidev, dev->board_name + ? dev->board_name + : dev->driver->driver_name); if (rc < 0) pci_disable_device(pcidev); diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 9846c2ecc916..f638381fe424 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -384,7 +384,7 @@ struct pci_driver; struct pci_dev *comedi_to_pci_dev(struct comedi_device *); -int comedi_pci_enable(struct pci_dev *, const char *); +int comedi_pci_enable(struct comedi_device *); void comedi_pci_disable(struct comedi_device *); int comedi_pci_auto_config(struct pci_dev *, struct comedi_driver *, @@ -421,7 +421,7 @@ static inline struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev) return NULL; } -static inline int comedi_pci_enable(struct pci_dev *dev, const char *name) +static inline int comedi_pci_enable(struct comedi_device *dev) { return -ENOSYS; } diff --git a/drivers/staging/comedi/drivers/8255_pci.c b/drivers/staging/comedi/drivers/8255_pci.c index a546dff61925..808460bbd32e 100644 --- a/drivers/staging/comedi/drivers/8255_pci.c +++ b/drivers/staging/comedi/drivers/8255_pci.c @@ -204,7 +204,7 @@ static int pci_8255_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; iobase = pci_resource_start(pcidev, board->dio_badr); diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c index 704a56eec6b7..cb9b590f63b9 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c @@ -101,7 +101,7 @@ static int addi_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index 4da6e8b14dc1..3d32448e4e69 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -303,7 +303,7 @@ static int apci1032_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c b/drivers/staging/comedi/drivers/addi_apci_1516.c index a7e449db4693..e66ff4e05cdb 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1516.c +++ b/drivers/staging/comedi/drivers/addi_apci_1516.c @@ -148,7 +148,7 @@ static int apci1516_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/addi_apci_16xx.c b/drivers/staging/comedi/drivers/addi_apci_16xx.c index e2f9357d4c35..4c6a9b5a06ae 100644 --- a/drivers/staging/comedi/drivers/addi_apci_16xx.c +++ b/drivers/staging/comedi/drivers/addi_apci_16xx.c @@ -142,7 +142,7 @@ static int apci16xx_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/addi_apci_1710.c b/drivers/staging/comedi/drivers/addi_apci_1710.c index 05e1b9c391e6..f36ad00cee4a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1710.c +++ b/drivers/staging/comedi/drivers/addi_apci_1710.c @@ -42,7 +42,7 @@ static int apci1710_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index 6e4ee0ae67aa..59e092eab9f3 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -289,7 +289,7 @@ static int apci2032_auto_attach(struct comedi_device *dev, dev->board_name = dev->driver->driver_name; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, 1); diff --git a/drivers/staging/comedi/drivers/addi_apci_2200.c b/drivers/staging/comedi/drivers/addi_apci_2200.c index aea0abb1a0af..0953f65ab0ad 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2200.c +++ b/drivers/staging/comedi/drivers/addi_apci_2200.c @@ -90,7 +90,7 @@ static int apci2200_auto_attach(struct comedi_device *dev, dev->board_name = dev->driver->driver_name; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 056153157e51..1c5ac16aad15 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -70,7 +70,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; pci_set_master(pcidev); diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index 8bd3d72df0a6..75a36e364932 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -346,7 +346,7 @@ static int apci3501_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index 8939bbdaee5f..8a438ff1bd45 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -181,7 +181,7 @@ static int pci6208_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, 2); diff --git a/drivers/staging/comedi/drivers/adl_pci7x3x.c b/drivers/staging/comedi/drivers/adl_pci7x3x.c index bd2e58415d77..e3960745f506 100644 --- a/drivers/staging/comedi/drivers/adl_pci7x3x.c +++ b/drivers/staging/comedi/drivers/adl_pci7x3x.c @@ -164,7 +164,7 @@ static int adl_pci7x3x_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, 2); diff --git a/drivers/staging/comedi/drivers/adl_pci8164.c b/drivers/staging/comedi/drivers/adl_pci8164.c index 008f89aea4ba..469a51d97b82 100644 --- a/drivers/staging/comedi/drivers/adl_pci8164.c +++ b/drivers/staging/comedi/drivers/adl_pci8164.c @@ -80,7 +80,7 @@ static int adl_pci8164_auto_attach(struct comedi_device *dev, dev->board_name = dev->driver->driver_name; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, 2); diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index ee45ee8c03c4..9c27e981db0c 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -872,7 +872,7 @@ static int pci9111_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = dev_private; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev_private->lcr_io_base = pci_resource_start(pcidev, 1); diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 2bf00e834540..cb4ef2dcbf02 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -1970,12 +1970,9 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, u16 u16w; dev->board_name = this_board->name; - ret = comedi_pci_enable(pcidev, dev->board_name); - if (ret) { - dev_err(dev->class_dev, - "cannot enable PCI device %s\n", pci_name(pcidev)); + ret = comedi_pci_enable(dev); + if (ret) return ret; - } if (master) pci_set_master(pcidev); diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index af302fe3f5cb..52672c53e11e 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -1248,7 +1248,7 @@ static int pci1710_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, 2); diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 25f4cba5a75b..9e81e58a6e69 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -249,7 +249,7 @@ static int pci1723_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, 2); diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index c799308adfb4..a33929e87a2f 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -360,7 +360,7 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev, dev->board_name = dev->driver->driver_name; - retval = comedi_pci_enable(pcidev, dev->board_name); + retval = comedi_pci_enable(dev); if (retval) return retval; diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 79f72d6d7de1..3a05fbca9299 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -1104,7 +1104,7 @@ static int pci_dio_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, this_board->main_pci_region); diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index d13a6dddcd09..652494289a13 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -1950,12 +1950,11 @@ static int dio200_auto_attach(struct comedi_device *dev, return -EINVAL; } thisboard = comedi_board(dev); - ret = comedi_pci_enable(pci_dev, DIO200_DRIVER_NAME); - if (ret < 0) { - dev_err(dev->class_dev, - "error! cannot enable PCI device and request regions!\n"); + + ret = comedi_pci_enable(dev); + if (ret) return ret; - } + bar = thisboard->mainbar; base = pci_resource_start(pci_dev, bar); len = pci_resource_len(pci_dev, bar); diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index 45168488503d..4507f92e1579 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -470,12 +470,10 @@ static int pc236_pci_common_attach(struct comedi_device *dev, comedi_set_hw_dev(dev, &pci_dev->dev); - ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME); - if (ret < 0) { - dev_err(dev->class_dev, - "error! cannot enable PCI device and request regions!\n"); + ret = comedi_pci_enable(dev); + if (ret) return ret; - } + devpriv->lcr_iobase = pci_resource_start(pci_dev, 1); iobase = pci_resource_start(pci_dev, 2); return pc236_common_attach(dev, iobase, pci_dev->irq, IRQF_SHARED); diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c index d825414994b8..b8449433eee7 100644 --- a/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/drivers/staging/comedi/drivers/amplc_pc263.c @@ -249,13 +249,11 @@ static int pc263_pci_common_attach(struct comedi_device *dev, comedi_set_hw_dev(dev, &pci_dev->dev); - ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME); - if (ret < 0) { - dev_err(dev->class_dev, - "error! cannot enable PCI device and request regions!\n"); + ret = comedi_pci_enable(dev); + if (ret) return ret; - } iobase = pci_resource_start(pci_dev, 2); + return pc263_common_attach(dev, iobase); } diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 3d5c1332eb34..4d7eab9b5565 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -1280,13 +1280,10 @@ static int pci224_attach_common(struct comedi_device *dev, comedi_set_hw_dev(dev, &pci_dev->dev); - ret = comedi_pci_enable(pci_dev, DRIVER_NAME); - if (ret < 0) { - dev_err(dev->class_dev, - "error! cannot enable PCI device and request regions!\n" - ); + ret = comedi_pci_enable(dev); + if (ret) return ret; - } + spin_lock_init(&devpriv->ao_spinlock); devpriv->iobase1 = pci_resource_start(pci_dev, 2); diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 1bfe893b4cb2..b6e4af444ef5 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2645,12 +2645,11 @@ static int pci230_attach_common(struct comedi_device *dev, comedi_set_hw_dev(dev, &pci_dev->dev); dev->board_name = thisboard->name; - /* Enable PCI device and reserve I/O spaces. */ - if (comedi_pci_enable(pci_dev, "amplc_pci230") < 0) { - dev_err(dev->class_dev, - "failed to enable PCI device and request regions\n"); - return -EIO; - } + + rc = comedi_pci_enable(dev); + if (rc) + return rc; + /* Read base addresses of the PCI230's two I/O regions from PCI * configuration register. */ iobase1 = pci_resource_start(pci_dev, 2); diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 04aa8d948a8b..7a23d56645e7 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1455,7 +1455,7 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = 1; diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 15a97212b158..46b6af4c517d 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -4059,11 +4059,9 @@ static int auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - if (comedi_pci_enable(pcidev, dev->driver->driver_name)) { - dev_warn(dev->class_dev, - "failed to enable PCI device and request regions\n"); - return -EIO; - } + retval = comedi_pci_enable(dev); + if (retval) + return retval; pci_set_master(pcidev); /* Initialize dev->board_name */ diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c index aff16171ca93..2da6bd663aff 100644 --- a/drivers/staging/comedi/drivers/cb_pcidda.c +++ b/drivers/staging/comedi/drivers/cb_pcidda.c @@ -357,7 +357,7 @@ static int cb_pcidda_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, 3); diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index 8a8677f2525e..f6d99a3a972e 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -222,7 +222,7 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index 7b8adec5e7b9..d00f7f629d36 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -168,7 +168,7 @@ static int cb_pcimdda_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, 3); diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c index b8c56a60cda9..da0be62aef60 100644 --- a/drivers/staging/comedi/drivers/contec_pci_dio.c +++ b/drivers/staging/comedi/drivers/contec_pci_dio.c @@ -79,7 +79,7 @@ static int contec_auto_attach(struct comedi_device *dev, dev->board_name = dev->driver->driver_name; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, 0); diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 077f9a5eb7c8..7c549eb442f8 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -709,8 +709,8 @@ static int daqboard2000_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - result = comedi_pci_enable(pcidev, dev->driver->driver_name); - if (result < 0) + result = comedi_pci_enable(dev); + if (result) return result; dev->iobase = 1; /* the "detach" needs this */ diff --git a/drivers/staging/comedi/drivers/das08_pci.c b/drivers/staging/comedi/drivers/das08_pci.c index c64fb2775b8c..53fa943dd0b7 100644 --- a/drivers/staging/comedi/drivers/das08_pci.c +++ b/drivers/staging/comedi/drivers/das08_pci.c @@ -71,7 +71,7 @@ static int das08_pci_auto_attach(struct comedi_device *dev, /* The das08 driver needs the board_ptr */ dev->board_ptr = &das08_pci_boards[0]; - ret = comedi_pci_enable(pdev, dev->driver->driver_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pdev, 2); diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index 296c5205ac9f..edbcd89aff9d 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -735,7 +735,7 @@ static int dt3000_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret < 0) return ret; dev->iobase = 1; /* the "detach" needs this */ diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/staging/comedi/drivers/dyna_pci10xx.c index 9f83dfbcf295..17f9ec2a9072 100644 --- a/drivers/staging/comedi/drivers/dyna_pci10xx.c +++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c @@ -194,7 +194,7 @@ static int dyna_pci10xx_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, 2); diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index f0e92143ac89..16b4cc050d35 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -499,11 +499,9 @@ static int hpdi_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - if (comedi_pci_enable(pcidev, dev->board_name)) { - dev_warn(dev->class_dev, - "failed enable PCI device and request regions\n"); - return -EIO; - } + retval = comedi_pci_enable(dev); + if (retval) + return retval; dev->iobase = 1; /* the "detach" needs this */ pci_set_master(pcidev); diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index 65265c3ce3ff..f29a797fd9d5 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -510,7 +510,7 @@ static int icp_multi_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; iobase = pci_resource_start(pcidev, 2); diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index f1ae9a814d8f..36659e500f40 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -702,11 +702,11 @@ static int jr3_pci_auto_attach(struct comedi_device *dev, } dev->board_name = "jr3_pci"; - result = comedi_pci_enable(pcidev, "jr3_pci"); - if (result < 0) + result = comedi_pci_enable(dev); + if (result) return result; - dev->iobase = 1; /* the "detach" needs this */ + devpriv->iobase = ioremap(pci_resource_start(pcidev, 0), offsetof(struct jr3_t, channel[devpriv->n_channels])); diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c index 74318f204e25..bca29e5f4fc5 100644 --- a/drivers/staging/comedi/drivers/ke_counter.c +++ b/drivers/staging/comedi/drivers/ke_counter.c @@ -98,7 +98,7 @@ static int cnt_auto_attach(struct comedi_device *dev, dev->board_name = dev->driver->driver_name; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, 0); diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 6bc1347eaf68..e415db2d069e 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -1571,7 +1571,7 @@ static int me4000_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = info; - result = comedi_pci_enable(pcidev, dev->board_name); + result = comedi_pci_enable(dev); if (result) return result; diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 8951a673c2d1..fbbac1259ebd 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -511,7 +511,7 @@ static int me_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = dev_private; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = 1; /* detach needs this */ diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 5a3b14fb4de1..9a456624ab4e 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -109,11 +109,6 @@ int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1) u32 csigr_bits; unsigned unknown_dma_burst_bits; - if (comedi_pci_enable(mite->pcidev, "mite")) { - dev_err(&mite->pcidev->dev, - "error enabling mite and requesting io regions\n"); - return -EIO; - } pci_set_master(mite->pcidev); addr = pci_resource_start(mite->pcidev, 0); diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 194eac63dd3e..65dd1c68721a 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -336,6 +336,11 @@ static int ni6527_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; + ret = comedi_pci_enable(dev); + if (ret) + return ret; + dev->iobase = 1; + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; @@ -350,7 +355,6 @@ static int ni6527_auto_attach(struct comedi_device *dev, dev_err(dev->class_dev, "error setting up mite\n"); return ret; } - dev->iobase = 1; dev_info(dev->class_dev, "board: %s, ID=0x%02x\n", dev->board_name, readb(devpriv->mite->daq_io_addr + ID_Register)); diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index b882a5f5b035..eec712e5e138 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -600,6 +600,11 @@ static int ni_65xx_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; + ret = comedi_pci_enable(dev); + if (ret) + return ret; + dev->iobase = 1; + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; @@ -614,7 +619,6 @@ static int ni_65xx_auto_attach(struct comedi_device *dev, dev_warn(dev->class_dev, "error setting up mite\n"); return ret; } - dev->iobase = 1; dev->irq = mite_irq(devpriv->mite); dev_info(dev->class_dev, "board: %s, ID=0x%02x", dev->board_name, diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index cc82106af7f0..f97a668143d8 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -1174,6 +1174,11 @@ static int ni_660x_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; + ret = comedi_pci_enable(dev); + if (ret) + return ret; + dev->iobase = 1; + ret = ni_660x_allocate_private(dev); if (ret < 0) return ret; @@ -1188,7 +1193,6 @@ static int ni_660x_auto_attach(struct comedi_device *dev, dev_warn(dev->class_dev, "error setting up mite\n"); return ret; } - dev->iobase = 1; ret = ni_660x_alloc_mite_rings(dev); if (ret < 0) diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 5ec6f829a924..524f6cd72687 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -208,6 +208,11 @@ static int ni_670x_auto_attach(struct comedi_device *dev, dev->board_ptr = thisboard; dev->board_name = thisboard->name; + ret = comedi_pci_enable(dev); + if (ret) + return ret; + dev->iobase = 1; + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; @@ -222,7 +227,6 @@ static int ni_670x_auto_attach(struct comedi_device *dev, dev_warn(dev->class_dev, "error setting up mite\n"); return ret; } - dev->iobase = 1; ret = comedi_alloc_subdevices(dev, 2); if (ret) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 9082eca09499..78f01709e222 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -708,6 +708,11 @@ static int labpc_auto_attach(struct comedi_device *dev, if (!IS_ENABLED(CONFIG_COMEDI_PCI_DRIVERS)) return -ENODEV; + ret = comedi_pci_enable(dev); + if (ret) + return ret; + dev->iobase = 1; + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; @@ -722,7 +727,6 @@ static int labpc_auto_attach(struct comedi_device *dev, ret = mite_setup(devpriv->mite); if (ret < 0) return ret; - dev->iobase = 1; iobase = (unsigned long)devpriv->mite->daq_io_addr; irq = mite_irq(devpriv->mite); return labpc_common_attach(dev, iobase, irq, 0); diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 8f743751507b..2298d6ee12ef 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -1112,6 +1112,11 @@ static int nidio_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; + ret = comedi_pci_enable(dev); + if (ret) + return ret; + dev->iobase = 1; + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; @@ -1128,7 +1133,6 @@ static int nidio_auto_attach(struct comedi_device *dev, dev_warn(dev->class_dev, "error setting up mite\n"); return ret; } - dev->iobase = 1; devpriv->di_mite_ring = mite_alloc_ring(devpriv->mite); if (devpriv->di_mite_ring == NULL) diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index 0f18f8dda5fb..098c398f2bea 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -1488,6 +1488,11 @@ static int pcimio_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; + ret = comedi_pci_enable(dev); + if (ret) + return ret; + dev->iobase = 1; + ret = ni_alloc_private(dev); if (ret) return ret; @@ -1514,7 +1519,6 @@ static int pcimio_auto_attach(struct comedi_device *dev, pr_warn("error setting up mite\n"); return ret; } - dev->iobase = 1; devpriv->ai_mite_ring = mite_alloc_ring(devpriv->mite); if (devpriv->ai_mite_ring == NULL) diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 5b0676817726..c0935d4a89c1 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -1283,7 +1283,7 @@ static int rtd_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = 1; /* the "detach" needs this */ diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 92338791f4a2..cd164ee3a5e1 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -2673,7 +2673,7 @@ static int s626_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret; dev->iobase = 1; /* detach needs this */ diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index f5d708c3aa5b..6fb7d5d22094 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -567,7 +567,7 @@ static int skel_auto_attach(struct comedi_device *dev, dev->private = devpriv; /* Enable the PCI device. */ - ret = comedi_pci_enable(pcidev, dev->board_name); + ret = comedi_pci_enable(dev); if (ret) return ret;