staging: comedi: amplc_dio200: add PCI BAR information to board
Add `mainbar` member to `struct dio200_board` to hold the PCI BAR number for the main registers. This is `2` for the PCI boards currently supported (PCI215 and PCI272) but will be different for some new boards to be supported later. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
71b3e9e8dc
commit
ef0653ac20
@@ -308,6 +308,7 @@ struct dio200_board {
|
|||||||
enum dio200_bustype bustype;
|
enum dio200_bustype bustype;
|
||||||
enum dio200_model model;
|
enum dio200_model model;
|
||||||
enum dio200_layout_idx layout;
|
enum dio200_layout_idx layout;
|
||||||
|
unsigned char mainbar;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct dio200_board dio200_boards[] = {
|
static const struct dio200_board dio200_boards[] = {
|
||||||
@@ -350,6 +351,7 @@ static const struct dio200_board dio200_boards[] = {
|
|||||||
.bustype = pci_bustype,
|
.bustype = pci_bustype,
|
||||||
.model = pci215_model,
|
.model = pci215_model,
|
||||||
.layout = pc215_layout,
|
.layout = pc215_layout,
|
||||||
|
.mainbar = 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "pci272",
|
.name = "pci272",
|
||||||
@@ -357,6 +359,7 @@ static const struct dio200_board dio200_boards[] = {
|
|||||||
.bustype = pci_bustype,
|
.bustype = pci_bustype,
|
||||||
.model = pci272_model,
|
.model = pci272_model,
|
||||||
.layout = pc272_layout,
|
.layout = pc272_layout,
|
||||||
|
.mainbar = 2,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -1573,8 +1576,10 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
|||||||
static int __devinit dio200_attach_pci(struct comedi_device *dev,
|
static int __devinit dio200_attach_pci(struct comedi_device *dev,
|
||||||
struct pci_dev *pci_dev)
|
struct pci_dev *pci_dev)
|
||||||
{
|
{
|
||||||
|
const struct dio200_board *thisboard;
|
||||||
struct dio200_private *devpriv;
|
struct dio200_private *devpriv;
|
||||||
resource_size_t base;
|
resource_size_t base;
|
||||||
|
unsigned int bar;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!DO_PCI)
|
if (!DO_PCI)
|
||||||
@@ -1593,15 +1598,17 @@ static int __devinit dio200_attach_pci(struct comedi_device *dev,
|
|||||||
dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
|
dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
thisboard = comedi_board(dev);
|
||||||
ret = comedi_pci_enable(pci_dev, DIO200_DRIVER_NAME);
|
ret = comedi_pci_enable(pci_dev, DIO200_DRIVER_NAME);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev->class_dev,
|
dev_err(dev->class_dev,
|
||||||
"error! cannot enable PCI device and request regions!\n");
|
"error! cannot enable PCI device and request regions!\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
base = pci_resource_start(pci_dev, 2);
|
bar = thisboard->mainbar;
|
||||||
if ((pci_resource_flags(pci_dev, 2) & IORESOURCE_MEM) != 0) {
|
base = pci_resource_start(pci_dev, bar);
|
||||||
resource_size_t len = pci_resource_len(pci_dev, 2);
|
if ((pci_resource_flags(pci_dev, bar) & IORESOURCE_MEM) != 0) {
|
||||||
|
resource_size_t len = pci_resource_len(pci_dev, bar);
|
||||||
devpriv->io.u.membase = ioremap_nocache(base, len);
|
devpriv->io.u.membase = ioremap_nocache(base, len);
|
||||||
if (!devpriv->io.u.membase) {
|
if (!devpriv->io.u.membase) {
|
||||||
dev_err(dev->class_dev,
|
dev_err(dev->class_dev,
|
||||||
|
Reference in New Issue
Block a user