mirror of https://gitee.com/openkylin/linux.git
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 <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
adfaa207ca
commit
a0b4bccc40
|
@ -143,6 +143,7 @@ struct das16m1_private_struct {
|
||||||
unsigned int do_bits; /* saves status of digital output bits */
|
unsigned int do_bits; /* saves status of digital output bits */
|
||||||
unsigned int divisor1; /* divides master clock to obtain conversion speed */
|
unsigned int divisor1; /* divides master clock to obtain conversion speed */
|
||||||
unsigned int divisor2; /* 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)
|
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 */
|
/* Request an additional region for the 8255 */
|
||||||
ret = __comedi_request_region(dev, dev->iobase + DAS16M1_82C55,
|
ret = __comedi_request_region(dev, dev->iobase + DAS16M1_82C55,
|
||||||
DAS16M1_SIZE2);
|
DAS16M1_SIZE2);
|
||||||
if (ret) {
|
if (ret)
|
||||||
release_region(dev->iobase, DAS16M1_SIZE);
|
return ret;
|
||||||
dev->iobase = 0;
|
devpriv->extra_iobase = dev->iobase + DAS16M1_82C55;
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now for the irq */
|
/* now for the irq */
|
||||||
irq = it->options[1];
|
irq = it->options[1];
|
||||||
|
@ -649,7 +648,7 @@ static int das16m1_attach(struct comedi_device *dev,
|
||||||
|
|
||||||
s = &dev->subdevices[3];
|
s = &dev->subdevices[3];
|
||||||
/* 8255 */
|
/* 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 */
|
/* disable upper half of hardware conversion counter so it doesn't mess with us */
|
||||||
outb(TOTAL_CLEAR, dev->iobase + DAS16M1_8254_FIRST_CNTRL);
|
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)
|
static void das16m1_detach(struct comedi_device *dev)
|
||||||
{
|
{
|
||||||
|
struct das16m1_private_struct *devpriv = dev->private;
|
||||||
|
|
||||||
comedi_spriv_free(dev, 3);
|
comedi_spriv_free(dev, 3);
|
||||||
if (dev->irq)
|
if (dev->irq)
|
||||||
free_irq(dev->irq, dev);
|
free_irq(dev->irq, dev);
|
||||||
if (dev->iobase) {
|
if (devpriv && devpriv->extra_iobase)
|
||||||
release_region(dev->iobase, DAS16M1_SIZE);
|
release_region(devpriv->extra_iobase, DAS16M1_SIZE2);
|
||||||
release_region(dev->iobase + DAS16M1_82C55, DAS16M1_SIZE2);
|
comedi_legacy_detach(dev);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct comedi_driver das16m1_driver = {
|
static struct comedi_driver das16m1_driver = {
|
||||||
|
|
Loading…
Reference in New Issue