Skip to content

Commit

Permalink
staging: comedi: das16m1: use comedi_legacy_detach()
Browse files Browse the repository at this point in the history
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 by this driver for the 8255
device. 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>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Apr 19, 2013
1 parent adfaa20 commit a0b4bcc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/staging/comedi/drivers/das16m1.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ struct das16m1_private_struct {
unsigned int do_bits; /* saves status of digital output bits */
unsigned int divisor1; /* divides master clock to obtain conversion speed */
unsigned int divisor2; /* divides master clock to obtain conversion speed */
unsigned long extra_iobase;
};

static inline short munge_sample(short data)
Expand Down Expand Up @@ -583,11 +584,9 @@ static int das16m1_attach(struct comedi_device *dev,
/* Request an additional region for the 8255 */
ret = __comedi_request_region(dev, dev->iobase + DAS16M1_82C55,
DAS16M1_SIZE2);
if (ret) {
release_region(dev->iobase, DAS16M1_SIZE);
dev->iobase = 0;
return -EIO;
}
if (ret)
return ret;
devpriv->extra_iobase = dev->iobase + DAS16M1_82C55;

/* now for the irq */
irq = it->options[1];
Expand Down Expand Up @@ -649,7 +648,7 @@ static int das16m1_attach(struct comedi_device *dev,

s = &dev->subdevices[3];
/* 8255 */
subdev_8255_init(dev, s, NULL, dev->iobase + DAS16M1_82C55);
subdev_8255_init(dev, s, NULL, devpriv->extra_iobase);

/* disable upper half of hardware conversion counter so it doesn't mess with us */
outb(TOTAL_CLEAR, dev->iobase + DAS16M1_8254_FIRST_CNTRL);
Expand All @@ -669,13 +668,14 @@ static int das16m1_attach(struct comedi_device *dev,

static void das16m1_detach(struct comedi_device *dev)
{
struct das16m1_private_struct *devpriv = dev->private;

comedi_spriv_free(dev, 3);
if (dev->irq)
free_irq(dev->irq, dev);
if (dev->iobase) {
release_region(dev->iobase, DAS16M1_SIZE);
release_region(dev->iobase + DAS16M1_82C55, DAS16M1_SIZE2);
}
if (devpriv && devpriv->extra_iobase)
release_region(devpriv->extra_iobase, DAS16M1_SIZE2);
comedi_legacy_detach(dev);
}

static struct comedi_driver das16m1_driver = {
Expand Down

0 comments on commit a0b4bcc

Please sign in to comment.