}
}
-/*
-==============================================================================
-*/
-static void free_resources(struct comedi_device *dev)
-{
- const struct pcl812_board *board = comedi_board(dev);
- struct pcl812_private *devpriv = dev->private;
-
- if (devpriv) {
- if (devpriv->dmabuf[0])
- free_pages(devpriv->dmabuf[0], devpriv->dmapages[0]);
- if (devpriv->dmabuf[1])
- free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]);
- if (devpriv->dma)
- free_dma(devpriv->dma);
- }
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->iobase)
- release_region(dev->iobase, board->io_range);
-}
-
/*
==============================================================================
*/
return ret;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
- if (!devpriv) {
- free_resources(dev);
+ if (!devpriv)
return -ENOMEM;
- }
dev->private = devpriv;
irq = 0;
* maybe experiment with try_to_free_pages()
* will help ....
*/
- free_resources(dev);
return -EBUSY; /* no buffer :-( */
}
devpriv->dmapages[0] = pages;
devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages);
if (!devpriv->dmabuf[1]) {
printk(KERN_ERR ", unable to allocate DMA buffer, FAIL!\n");
- free_resources(dev);
return -EBUSY;
}
devpriv->dmapages[1] = pages;
n_subdevices++;
ret = comedi_alloc_subdevices(dev, n_subdevices);
- if (ret) {
- free_resources(dev);
+ if (ret)
return ret;
- }
subdev = 0;
static void pcl812_detach(struct comedi_device *dev)
{
- free_resources(dev);
+ struct pcl812_private *devpriv = dev->private;
+
+ if (devpriv) {
+ if (devpriv->dmabuf[0])
+ free_pages(devpriv->dmabuf[0], devpriv->dmapages[0]);
+ if (devpriv->dmabuf[1])
+ free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]);
+ if (devpriv->dma)
+ free_dma(devpriv->dma);
+ }
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ comedi_legacy_detach(dev);
}
static const struct pcl812_board boardtypes[] = {