]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
staging: comedi: das16: use comedi_request_region()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 9 Apr 2013 23:15:55 +0000 (16:15 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Apr 2013 19:47:39 +0000 (12:47 -0700)
Use comedi_request_region() to request the I/O region used by this
driver.

Remove the noise when the board is first attached as well as the
error message when the request_region() fails, comedi_request_reqion()
will output the error message if necessary.

This driver does a second request_region() for the I/O space needed
by the 8255 chip. Modify the error message if that request fails so
it matches to format of the comedi_request_region() message.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/das16.c

index c84f7795994e666145477dd4a25a27c81dc8efe7..01fe078f3914a88513e6958fbeeeb779d0ddbbe5 100644 (file)
@@ -1079,13 +1079,11 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        struct comedi_subdevice *s;
        int ret;
        unsigned int irq;
-       unsigned long iobase;
        unsigned int dma_chan;
        int timer_mode;
        unsigned long flags;
        struct comedi_krange *user_ai_range, *user_ao_range;
 
-       iobase = it->options[0];
 #if 0
        irq = it->options[1];
        timer_mode = it->options[8];
@@ -1097,8 +1095,6 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        if (timer_mode)
                irq = 0;
 
-       printk(KERN_INFO "comedi%d: das16:", dev->minor);
-
        /*  check that clock setting is valid */
        if (it->options[3]) {
                if (it->options[3] != 0 &&
@@ -1116,33 +1112,26 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        dev->private = devpriv;
 
        if (board->size < 0x400) {
-               printk(" 0x%04lx-0x%04lx\n", iobase, iobase + board->size);
-               if (!request_region(iobase, board->size, dev->board_name)) {
-                       printk(KERN_ERR " I/O port conflict\n");
-                       return -EIO;
-               }
+               ret = comedi_request_region(dev, it->options[0], board->size);
+               if (ret)
+                       return ret;
        } else {
-               printk(KERN_INFO " 0x%04lx-0x%04lx 0x%04lx-0x%04lx\n",
-                      iobase, iobase + 0x0f,
-                      iobase + 0x400,
-                      iobase + 0x400 + (board->size & 0x3ff));
-               if (!request_region(iobase, 0x10, dev->board_name)) {
-                       printk(KERN_ERR " I/O port conflict:  0x%04lx-0x%04lx\n",
-                              iobase, iobase + 0x0f);
-                       return -EIO;
-               }
-               if (!request_region(iobase + 0x400, board->size & 0x3ff,
+               ret = comedi_request_region(dev, it->options[0], 0x10);
+               if (ret)
+                       return ret;
+               /* Request an additional region for the 8255 */
+               if (!request_region(dev->iobase + 0x400, board->size & 0x3ff,
                                    dev->board_name)) {
-                       release_region(iobase, 0x10);
-                       printk(KERN_ERR " I/O port conflict:  0x%04lx-0x%04lx\n",
-                              iobase + 0x400,
-                              iobase + 0x400 + (board->size & 0x3ff));
+                       release_region(dev->iobase, 0x10);
+                       dev_warn(dev->class_dev,
+                                "%s: I/O port conflict (%#lx,%d)\n",
+                                dev->board_name,
+                                dev->iobase + 0x400, board->size & 0x3ff);
+                       dev->iobase = 0;
                        return -EIO;
                }
        }
 
-       dev->iobase = iobase;
-
        /*  probe id bits to make sure they are consistent */
        if (das16_probe(dev, it)) {
                printk(KERN_ERR " id bits do not match selected board, aborting\n");