Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 317142
b: refs/heads/master
c: 03668b1
h: refs/heads/master
v: v3
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Jun 5, 2012
1 parent f45555a commit 017562c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 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: ba7914cd133cff9ac73e3434ba6980f2ac97a362
refs/heads/master: 03668b101362b031b74a7cde865fa7346b44eb30
65 changes: 33 additions & 32 deletions trunk/drivers/staging/comedi/drivers/amplc_pc263.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,25 @@ pc263_find_pci(struct comedi_device *dev, int bus, int slot,
}
/* No match found. */
if (bus || slot) {
printk(KERN_ERR
"comedi%d: error! no %s found at pci %02x:%02x!\n",
dev->minor, thisboard->name, bus, slot);
dev_err(dev->class_dev,
"error! no %s found at pci %02x:%02x!\n",
thisboard->name, bus, slot);
} else {
printk(KERN_ERR "comedi%d: error! no %s found!\n",
dev->minor, thisboard->name);
dev_err(dev->class_dev, "error! no %s found!\n",
thisboard->name);
}
return -EIO;
}
/*
* This function checks and requests an I/O region, reporting an error
* if there is a conflict.
*/
static int pc263_request_region(unsigned minor, unsigned long from,
static int pc263_request_region(struct comedi_device *dev, unsigned long from,
unsigned long extent)
{
if (!from || !request_region(from, extent, PC263_DRIVER_NAME)) {
printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
minor, from, extent);
dev_err(dev->class_dev, "I/O port conflict (%#lx,%lu)!\n",
from, extent);
return -EIO;
}
return 0;
Expand All @@ -206,6 +206,22 @@ static int pc263_do_insn_bits(struct comedi_device *dev,
return 2;
}

static void pc263_report_attach(struct comedi_device *dev)
{
char tmpbuf[40];

if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) &&
thisboard->bustype == isa_bustype)
snprintf(tmpbuf, sizeof(tmpbuf), "(base %#lx) ", dev->iobase);
else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) &&
thisboard->bustype == pci_bustype)
snprintf(tmpbuf, sizeof(tmpbuf), "(pci %s) ",
pci_name(devpriv->pci_dev));
else
tmpbuf[0] = '\0';
dev_info(dev->class_dev, "%s %sattached\n", dev->board_name, tmpbuf);
}

/*
* Attach is called by the Comedi core to configure the driver
* for a particular board. If you specified a board_name array
Expand All @@ -218,14 +234,13 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
unsigned long iobase = 0;
int ret;

printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
PC263_DRIVER_NAME);
dev_info(dev->class_dev, PC263_DRIVER_NAME ": attach\n");

/* Process options and reserve resources according to bus type. */
if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) &&
thisboard->bustype == isa_bustype) {
iobase = it->options[0];
ret = pc263_request_region(dev->minor, iobase, PC263_IO_SIZE);
ret = pc263_request_region(dev, iobase, PC263_IO_SIZE);
if (ret < 0)
return ret;
} else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) &&
Expand All @@ -235,8 +250,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)

ret = alloc_private(dev, sizeof(struct pc263_private));
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
dev->minor);
dev_err(dev->class_dev, "error! out of memory!\n");
return ret;
}
bus = it->options[0];
Expand All @@ -247,17 +261,14 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->pci_dev = pci_dev;
ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME);
if (ret < 0) {
printk(KERN_ERR
"comedi%d: error! cannot enable PCI device and "
"request regions!\n",
dev->minor);
dev_err(dev->class_dev,
"error! cannot enable PCI device and request regions!\n");
return ret;
}
iobase = pci_resource_start(pci_dev, 2);
} else {
printk(KERN_ERR
"comedi%d: %s: BUG! cannot determine board type!\n",
dev->minor, PC263_DRIVER_NAME);
dev_err(dev->class_dev, PC263_DRIVER_NAME
": BUG! cannot determine board type!\n");
return -EINVAL;
}

Expand All @@ -266,8 +277,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)

ret = alloc_subdevices(dev, 1);
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
dev->minor);
dev_err(dev->class_dev, "error! out of memory!\n");
return ret;
}

Expand All @@ -282,16 +292,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* read initial relay state */
s->state = inb(dev->iobase) | (inb(dev->iobase + 1) << 8);

printk(KERN_INFO "comedi%d: %s ", dev->minor, dev->board_name);
if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) &&
thisboard->bustype == isa_bustype)
printk("(base %#lx) ", iobase);
else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) &&
thisboard->bustype == pci_bustype)
printk("(pci %s) ", pci_name(devpriv->pci_dev));

printk("attached\n");

pc263_report_attach(dev);
return 1;
}

Expand Down

0 comments on commit 017562c

Please sign in to comment.