Commit 818f569f authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7f072f54
......@@ -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);
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
Supports Markdown
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