Commit 485455d0 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: amplc_dio200: Replace printk calls

Replace the printk calls with dev_info, dev_err, etc.  There were some
consecutive printk calls without newlines which now scnprintf into a
temporary buffer and this bit of code has been factored out into new
function dio200_report_attach().
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fd97962b
...@@ -509,12 +509,12 @@ dio200_find_pci(struct comedi_device *dev, int bus, int slot, ...@@ -509,12 +509,12 @@ dio200_find_pci(struct comedi_device *dev, int bus, int slot,
} }
/* No match found. */ /* No match found. */
if (bus || slot) { if (bus || slot) {
printk(KERN_ERR dev_err(dev->class_dev,
"comedi%d: error! no %s found at pci %02x:%02x!\n", "error! no %s found at pci %02x:%02x!\n",
dev->minor, thisboard->name, bus, slot); thisboard->name, bus, slot);
} else { } else {
printk(KERN_ERR "comedi%d: error! no %s found!\n", dev_err(dev->class_dev, "error! no %s found!\n",
dev->minor, thisboard->name); thisboard->name);
} }
return -EIO; return -EIO;
} }
...@@ -524,11 +524,12 @@ dio200_find_pci(struct comedi_device *dev, int bus, int slot, ...@@ -524,11 +524,12 @@ dio200_find_pci(struct comedi_device *dev, int bus, int slot,
* if there is a conflict. * if there is a conflict.
*/ */
static int static int
dio200_request_region(unsigned minor, unsigned long from, unsigned long extent) dio200_request_region(struct comedi_device *dev,
unsigned long from, unsigned long extent)
{ {
if (!from || !request_region(from, extent, DIO200_DRIVER_NAME)) { if (!from || !request_region(from, extent, DIO200_DRIVER_NAME)) {
printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n", dev_err(dev->class_dev, "I/O port conflict (%#lx,%lu)!\n",
minor, from, extent); from, extent);
return -EIO; return -EIO;
} }
return 0; return 0;
...@@ -926,8 +927,7 @@ dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -926,8 +927,7 @@ dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s,
subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL); subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
if (!subpriv) { if (!subpriv) {
printk(KERN_ERR "comedi%d: error! out of memory!\n", dev_err(dev->class_dev, "error! out of memory!\n");
dev->minor);
return -ENOMEM; return -ENOMEM;
} }
subpriv->iobase = iobase; subpriv->iobase = iobase;
...@@ -1180,8 +1180,7 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -1180,8 +1180,7 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL); subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
if (!subpriv) { if (!subpriv) {
printk(KERN_ERR "comedi%d: error! out of memory!\n", dev_err(dev->class_dev, "error! out of memory!\n");
dev->minor);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1233,6 +1232,31 @@ dio200_subdev_8254_cleanup(struct comedi_device *dev, ...@@ -1233,6 +1232,31 @@ dio200_subdev_8254_cleanup(struct comedi_device *dev,
kfree(subpriv); kfree(subpriv);
} }
static void dio200_report_attach(struct comedi_device *dev, unsigned int irq)
{
char tmpbuf[60];
int tmplen;
if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) &&
thisboard->bustype == isa_bustype)
tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
"(base %#lx) ", dev->iobase);
else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) &&
thisboard->bustype == pci_bustype)
tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
"(pci %s) ", pci_name(devpriv->pci_dev));
else
tmplen = 0;
if (irq)
tmplen += scnprintf(&tmpbuf[tmplen], sizeof(tmpbuf) - tmplen,
"(irq %u%s) ", irq,
(dev->irq ? "" : " UNAVAILABLE"));
else
tmplen += scnprintf(&tmpbuf[tmplen], sizeof(tmpbuf) - tmplen,
"(no irq) ");
dev_info(dev->class_dev, "%s %sattached\n", dev->board_name, tmpbuf);
}
/* /*
* Attach is called by the Comedi core to configure the driver * Attach is called by the Comedi core to configure the driver
* for a particular board. If you specified a board_name array * for a particular board. If you specified a board_name array
...@@ -1250,13 +1274,11 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1250,13 +1274,11 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
unsigned n; unsigned n;
int ret; int ret;
printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor, dev_info(dev->class_dev, DIO200_DRIVER_NAME ": attach\n");
DIO200_DRIVER_NAME);
ret = alloc_private(dev, sizeof(struct dio200_private)); ret = alloc_private(dev, sizeof(struct dio200_private));
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n", dev_err(dev->class_dev, "error! out of memory!\n");
dev->minor);
return ret; return ret;
} }
...@@ -1266,7 +1288,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1266,7 +1288,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
iobase = it->options[0]; iobase = it->options[0];
irq = it->options[1]; irq = it->options[1];
share_irq = 0; share_irq = 0;
ret = dio200_request_region(dev->minor, iobase, DIO200_IO_SIZE); ret = dio200_request_region(dev, iobase, DIO200_IO_SIZE);
if (ret < 0) if (ret < 0)
return ret; return ret;
} else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) && } else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) &&
...@@ -1283,17 +1305,15 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1283,17 +1305,15 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->pci_dev = pci_dev; devpriv->pci_dev = pci_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) {
printk(KERN_ERR dev_err(dev->class_dev,
"comedi%d: error! cannot enable PCI device and request regions!\n", "error! cannot enable PCI device and request regions!\n");
dev->minor);
return ret; return ret;
} }
iobase = pci_resource_start(pci_dev, 2); iobase = pci_resource_start(pci_dev, 2);
irq = pci_dev->irq; irq = pci_dev->irq;
} else { } else {
printk(KERN_ERR dev_err(dev->class_dev, DIO200_DRIVER_NAME
"comedi%d: %s: BUG! cannot determine board type!\n", ": BUG! cannot determine board type!\n");
dev->minor, DIO200_DRIVER_NAME);
return -EINVAL; return -EINVAL;
} }
...@@ -1305,8 +1325,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1305,8 +1325,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
ret = alloc_subdevices(dev, layout->n_subdevs); ret = alloc_subdevices(dev, layout->n_subdevs);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n", dev_err(dev->class_dev, "error! out of memory!\n");
dev->minor);
return ret; return ret;
} }
...@@ -1366,26 +1385,12 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1366,26 +1385,12 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
DIO200_DRIVER_NAME, dev) >= 0) { DIO200_DRIVER_NAME, dev) >= 0) {
dev->irq = irq; dev->irq = irq;
} else { } else {
printk(KERN_WARNING dev_warn(dev->class_dev,
"comedi%d: warning! irq %u unavailable!\n", "warning! irq %u unavailable!\n", irq);
dev->minor, irq);
} }
} }
printk(KERN_INFO "comedi%d: %s ", dev->minor, dev->board_name); dio200_report_attach(dev, irq);
if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) &&
thisboard->bustype == isa_bustype)
printk("(base %#lx) ", iobase);
else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) &&
thisboard->bustype == pci_bustype)
printk("(pci %s) ", pci_name(devpriv->pci_dev));
if (irq)
printk("(irq %u%s) ", irq, (dev->irq ? "" : " UNAVAILABLE"));
else
printk("(no irq) ");
printk("attached\n");
return 1; return 1;
} }
......
Markdown is supported
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