Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 337237
b: refs/heads/master
c: 805afd6
h: refs/heads/master
i:
  337235: ff4e07d
v: v3
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Oct 24, 2012
1 parent 9f4d41e commit 43b4f48
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ef0653ac20e739aba476ee63ca2a618a3a26857d
refs/heads/master: 805afd6bd62b2a6050cda8592fa2f9f72abe5a19
21 changes: 17 additions & 4 deletions trunk/drivers/staging/comedi/drivers/amplc_dio200.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ struct dio200_board {
enum dio200_model model;
enum dio200_layout_idx layout;
unsigned char mainbar;
unsigned int mainsize;
};

static const struct dio200_board dio200_boards[] = {
Expand All @@ -318,30 +319,35 @@ static const struct dio200_board dio200_boards[] = {
.bustype = isa_bustype,
.model = pc212e_model,
.layout = pc212_layout,
.mainsize = DIO200_IO_SIZE,
},
{
.name = "pc214e",
.bustype = isa_bustype,
.model = pc214e_model,
.layout = pc214_layout,
.mainsize = DIO200_IO_SIZE,
},
{
.name = "pc215e",
.bustype = isa_bustype,
.model = pc215e_model,
.layout = pc215_layout,
.mainsize = DIO200_IO_SIZE,
},
{
.name = "pc218e",
.bustype = isa_bustype,
.model = pc218e_model,
.layout = pc218_layout,
.mainsize = DIO200_IO_SIZE,
},
{
.name = "pc272e",
.bustype = isa_bustype,
.model = pc272e_model,
.layout = pc272_layout,
.mainsize = DIO200_IO_SIZE,
},
#endif
#if DO_PCI
Expand All @@ -352,6 +358,7 @@ static const struct dio200_board dio200_boards[] = {
.model = pci215_model,
.layout = pc215_layout,
.mainbar = 2,
.mainsize = DIO200_IO_SIZE,
},
{
.name = "pci272",
Expand All @@ -360,6 +367,7 @@ static const struct dio200_board dio200_boards[] = {
.model = pci272_model,
.layout = pc272_layout,
.mainbar = 2,
.mainsize = DIO200_IO_SIZE,
},
#endif
};
Expand Down Expand Up @@ -1550,7 +1558,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)

iobase = it->options[0];
irq = it->options[1];
ret = dio200_request_region(dev, iobase, DIO200_IO_SIZE);
ret = dio200_request_region(dev, iobase, thisboard->mainsize);
if (ret < 0)
return ret;
devpriv->io.u.iobase = iobase;
Expand Down Expand Up @@ -1578,7 +1586,7 @@ static int __devinit dio200_attach_pci(struct comedi_device *dev,
{
const struct dio200_board *thisboard;
struct dio200_private *devpriv;
resource_size_t base;
resource_size_t base, len;
unsigned int bar;
int ret;

Expand Down Expand Up @@ -1607,8 +1615,12 @@ static int __devinit dio200_attach_pci(struct comedi_device *dev,
}
bar = thisboard->mainbar;
base = pci_resource_start(pci_dev, bar);
len = pci_resource_len(pci_dev, bar);
if (len < thisboard->mainsize) {
dev_err(dev->class_dev, "error! PCI region size too small!\n");
return -EINVAL;
}
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);
if (!devpriv->io.u.membase) {
dev_err(dev->class_dev,
Expand Down Expand Up @@ -1655,7 +1667,8 @@ static void dio200_detach(struct comedi_device *dev)
}
if (is_isa_board(thisboard)) {
if (devpriv->io.regtype == io_regtype)
release_region(devpriv->io.u.iobase, DIO200_IO_SIZE);
release_region(devpriv->io.u.iobase,
thisboard->mainsize);
} else if (is_pci_board(thisboard)) {
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
if (pcidev) {
Expand Down

0 comments on commit 43b4f48

Please sign in to comment.