diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-04-18 14:32:12 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-19 11:19:53 -0700 |
commit | adfaa207ca4140fe6a09550549308248e651e2b9 (patch) | |
tree | ba760ff73a57f9f195bbdd8c8ce623a09f0c3023 | |
parent | a3fd5e517aa5139a77c806a19064fd8e2976b428 (diff) |
staging: comedi: das16: use comedi_legacy_detach()
Use the new comedi_legacy_detach() helper in the (*detach) to release
the first I/O region requested by this driver.
An additional I/O region is requested for some of the boards this driver
supports. Save the iobase for that region in the private data so that
the (*detach) knows it needs to be released.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers/das16.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index c2b5015448ae..b2826710cebb 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -393,6 +393,8 @@ struct das16_private_struct { struct timer_list timer; /* for timed interrupt */ volatile short timer_running; volatile short timer_mode; /* true if using timer mode */ + + unsigned long extra_iobase; }; static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, @@ -1122,11 +1124,9 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* Request an additional region for the 8255 */ ret = __comedi_request_region(dev, dev->iobase + 0x400, board->size & 0x3ff); - if (ret) { - release_region(dev->iobase, 0x10); - dev->iobase = 0; - return -EIO; - } + if (ret) + return ret; + devpriv->extra_iobase = dev->iobase + 0x400; } /* probe id bits to make sure they are consistent */ @@ -1356,15 +1356,9 @@ static void das16_detach(struct comedi_device *dev) } if (dev->irq) free_irq(dev->irq, dev); - if (dev->iobase) { - if (board->size < 0x400) { - release_region(dev->iobase, board->size); - } else { - release_region(dev->iobase, 0x10); - release_region(dev->iobase + 0x400, - board->size & 0x3ff); - } - } + if (devpriv->extra_iobase) + release_region(devpriv->extra_iobase, board->size & 0x3ff); + comedi_legacy_detach(dev); } static const struct das16_board das16_boards[] = { |