From a0b4bccc40983535f518f87792bcb9a7eb103a79 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Apr 2013 14:32:28 -0700 Subject: [PATCH] staging: comedi: das16m1: 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 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 91aba224beb9..02f52eb83d38 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -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) @@ -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]; @@ -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); @@ -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 = { -- 2.30.2