staging: comedi: introduce, and use, comedi_spriv_free()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 15 Apr 2013 23:41:57 +0000 (16:41 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Apr 2013 17:13:01 +0000 (10:13 -0700)
The comedi_subdevice 'private' variable is a void * that is available
for the subdevice to use in manner. It's common in comedi drivers for
the driver to allocate memory for a subdevice and store the pointer
to that memory in the 'private' variable. It's then the responsibility
of the driver to free that memory when the device is detached.

Due to how the attach/detach works in comedi, the drivers need to do
some sanity checking before they can free the allocated memory during
the detach.

Introduce a helper function, comedi_spriv_free(), to handle freeing
the private data allocated for a subdevice. This allows moving all the
sanity checks into the helper function and makes it safe to call
with any context. It also allows removing some of the boilerplate
code in the (*detach) functions.

Remove the subdev_8255_cleanup() export in the 8255 subdevice driver
as well as the addi_watchdog_cleanup() export in the addi_watchdog
driver and use the new helper instead.

The amplc_dio200_common driver uses a number of local helper functions
to free the private data for it's subdevices. Remove those as well and
use the new helper.

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>
30 files changed:
drivers/staging/comedi/comedidev.h
drivers/staging/comedi/drivers.c
drivers/staging/comedi/drivers/8255.c
drivers/staging/comedi/drivers/8255.h
drivers/staging/comedi/drivers/8255_pci.c
drivers/staging/comedi/drivers/addi_apci_1516.c
drivers/staging/comedi/drivers/addi_apci_2032.c
drivers/staging/comedi/drivers/addi_apci_2200.c
drivers/staging/comedi/drivers/addi_watchdog.c
drivers/staging/comedi/drivers/addi_watchdog.h
drivers/staging/comedi/drivers/adv_pci_dio.c
drivers/staging/comedi/drivers/aio_aio12_8.c
drivers/staging/comedi/drivers/amplc_dio200_common.c
drivers/staging/comedi/drivers/amplc_pc236.c
drivers/staging/comedi/drivers/amplc_pci230.c
drivers/staging/comedi/drivers/cb_pcidas.c
drivers/staging/comedi/drivers/cb_pcidas64.c
drivers/staging/comedi/drivers/cb_pcidda.c
drivers/staging/comedi/drivers/cb_pcimdda.c
drivers/staging/comedi/drivers/daqboard2000.c
drivers/staging/comedi/drivers/das08.c
drivers/staging/comedi/drivers/das16.c
drivers/staging/comedi/drivers/das16m1.c
drivers/staging/comedi/drivers/ni_65xx.c
drivers/staging/comedi/drivers/ni_atmio16d.c
drivers/staging/comedi/drivers/ni_daq_dio24.c
drivers/staging/comedi/drivers/ni_labpc.c
drivers/staging/comedi/drivers/ni_mio_common.c
drivers/staging/comedi/drivers/pcl724.c
drivers/staging/comedi/drivers/pcm3724.c

index 26c55569813f36572dd275968cfabdee26f6a6e3..ce509d02c21430d80c19f112a402cc00c94c1ed6 100644 (file)
@@ -348,6 +348,8 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
 
 int comedi_alloc_subdevices(struct comedi_device *, int);
 
+void comedi_spriv_free(struct comedi_device *, int subdev_num);
+
 int __comedi_request_region(struct comedi_device *,
                            unsigned long start, unsigned long len);
 int comedi_request_region(struct comedi_device *,
index 8a19f22d4ab90a18c87e979b7a13a8e7f4afd92f..2a28f64dc74c0774f93db8d592931b489383be15 100644 (file)
@@ -86,6 +86,18 @@ int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices)
 }
 EXPORT_SYMBOL_GPL(comedi_alloc_subdevices);
 
+void comedi_spriv_free(struct comedi_device *dev, int subdev_num)
+{
+       struct comedi_subdevice *s;
+
+       if (dev->subdevices && subdev_num < dev->n_subdevices) {
+               s = &dev->subdevices[subdev_num];
+               kfree(s->private);
+               s->private = NULL;
+       }
+}
+EXPORT_SYMBOL_GPL(comedi_spriv_free);
+
 static void cleanup_device(struct comedi_device *dev)
 {
        int i;
index ec4dacff0255c0b992e826c90756514d47e7b560..1d48aa602eceaf80476d5cde48e379f08877854a 100644 (file)
@@ -334,12 +334,6 @@ int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
 }
 EXPORT_SYMBOL_GPL(subdev_8255_init_irq);
 
-void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s)
-{
-       kfree(s->private);
-}
-EXPORT_SYMBOL_GPL(subdev_8255_cleanup);
-
 /*
 
    Start of the 8255 standalone device
@@ -397,7 +391,7 @@ static void dev_8255_detach(struct comedi_device *dev)
                        spriv = s->private;
                        release_region(spriv->iobase, _8255_SIZE);
                }
-               subdev_8255_cleanup(dev, s);
+               comedi_spriv_free(dev, i);
        }
 }
 
index 1e589b4b8b73c84618b23256c65cec7c432c694a..0f6e7492b7db7cd32b3bbcfb0c24ab05efee7fca 100644 (file)
@@ -32,7 +32,6 @@ int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
 int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
                         int (*io) (int, int, int, unsigned long),
                         unsigned long iobase);
-void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s);
 void subdev_8255_interrupt(struct comedi_device *dev,
                           struct comedi_subdevice *s);
 
index de54ad3a64e6ff64f73cbfd2525d5b75932a0728..76dec96aeb2ad696f1ad0e8a8a3187eb323d1a47 100644 (file)
@@ -241,20 +241,12 @@ static int pci_8255_auto_attach(struct comedi_device *dev,
 
 static void pci_8255_detach(struct comedi_device *dev)
 {
-       const struct pci_8255_boardinfo *board = comedi_board(dev);
        struct pci_8255_private *devpriv = dev->private;
-       struct comedi_subdevice *s;
        int i;
 
-       if (!board || !devpriv)
-               return;
-       if (dev->subdevices) {
-               for (i = 0; i < board->n_8255; i++) {
-                       s = &dev->subdevices[i];
-                       subdev_8255_cleanup(dev, s);
-               }
-       }
-       if (devpriv->mmio_base)
+       for (i = 0; i < dev->n_subdevices; i++)
+               comedi_spriv_free(dev, i);
+       if (devpriv && devpriv->mmio_base)
                iounmap(devpriv->mmio_base);
        comedi_pci_disable(dev);
 }
index e66ff4e05cdb75ed384f51395cc53c187f10bc09..ed01c56630bb7264fa11d8818f4bc03068a19bb3 100644 (file)
@@ -203,8 +203,7 @@ static void apci1516_detach(struct comedi_device *dev)
 {
        if (dev->iobase)
                apci1516_reset(dev);
-       if (dev->subdevices)
-               addi_watchdog_cleanup(&dev->subdevices[2]);
+       comedi_spriv_free(dev, 2);
        comedi_pci_disable(dev);
 }
 
index e5fa20aa7f2d154827e578602ff0b4587b26490b..b666637f61beed09448a24bc93171653d88190d4 100644 (file)
@@ -354,8 +354,7 @@ static void apci2032_detach(struct comedi_device *dev)
                free_irq(dev->irq, dev);
        if (dev->read_subdev)
                kfree(dev->read_subdev->private);
-       if (dev->subdevices)
-               addi_watchdog_cleanup(&dev->subdevices[1]);
+       comedi_spriv_free(dev, 1);
        comedi_pci_disable(dev);
 }
 
index 8cad37ccf73e792c8a3a4cb33721198385290914..1cdc08d79792ddfe96acdd2a9b3380716d4f6079 100644 (file)
@@ -130,8 +130,7 @@ static void apci2200_detach(struct comedi_device *dev)
 {
        if (dev->iobase)
                apci2200_reset(dev);
-       if (dev->subdevices)
-               addi_watchdog_cleanup(&dev->subdevices[2]);
+       comedi_spriv_free(dev, 2);
        comedi_pci_disable(dev);
 }
 
index 375ab665e091a3a0b51dc2a3a935fe9959bcac6b..1666b5f510d3243b8811123a0c349b51b54ea7f9 100644 (file)
@@ -150,12 +150,6 @@ int addi_watchdog_init(struct comedi_subdevice *s, unsigned long iobase)
 }
 EXPORT_SYMBOL_GPL(addi_watchdog_init);
 
-void addi_watchdog_cleanup(struct comedi_subdevice *s)
-{
-       kfree(s->private);
-}
-EXPORT_SYMBOL_GPL(addi_watchdog_cleanup);
-
 static int __init addi_watchdog_module_init(void)
 {
        return 0;
index f374a7bff44de19cd584a718f52152891841c4e0..83b47befa4d17e6ec2022f545dc9a4cbcc06a9ff 100644 (file)
@@ -5,6 +5,5 @@
 
 void addi_watchdog_reset(unsigned long iobase);
 int addi_watchdog_init(struct comedi_subdevice *, unsigned long iobase);
-void addi_watchdog_cleanup(struct comedi_subdevice *s);
 
 #endif
index e98ddcc6ecfa44563a618657f12924cc89cf1872..f70c67471c13a42aa850db35a9352edf70e69202 100644 (file)
@@ -1180,13 +1180,11 @@ static void pci_dio_detach(struct comedi_device *dev)
                if (devpriv->valid)
                        pci_dio_reset(dev);
        }
-       if (dev->subdevices) {
-               for (i = 0; i < dev->n_subdevices; i++) {
-                       s = &dev->subdevices[i];
-                       if (s->type == COMEDI_SUBD_DIO)
-                               subdev_8255_cleanup(dev, s);
-                       s->private = NULL;
-               }
+       for (i = 0; i < dev->n_subdevices; i++) {
+               s = &dev->subdevices[i];
+               if (s->type == COMEDI_SUBD_DIO)
+                       comedi_spriv_free(dev, i);
+               s->private = NULL; /* some private data is static */
        }
        comedi_pci_disable(dev);
 }
index e37d4a8f924018d812b604620000a485017d90b6..a3ca5c6b6a0669d7bb98228265f2b77758f3cc5d 100644 (file)
@@ -261,8 +261,7 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
 
 static void aio_aio12_8_detach(struct comedi_device *dev)
 {
-       if (dev->subdevices)
-               subdev_8255_cleanup(dev, &dev->subdevices[2]);
+       comedi_spriv_free(dev, 2);
        if (dev->iobase)
                release_region(dev->iobase, 24);
 }
index 04a798e9d0156476dcb6ed8a6b615662cab00285..3403e5ccfa93034acf6b1b19d5b49bffff2f0f8a 100644 (file)
@@ -594,17 +594,6 @@ dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s,
        return 0;
 }
 
-/*
- * This function cleans up an 'INTERRUPT' subdevice.
- */
-static void
-dio200_subdev_intr_cleanup(struct comedi_device *dev,
-                          struct comedi_subdevice *s)
-{
-       struct dio200_subdev_intr *subpriv = s->private;
-       kfree(subpriv);
-}
-
 /*
  * Interrupt service routine.
  */
@@ -937,17 +926,6 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
        return 0;
 }
 
-/*
- * This function cleans up an '8254' counter subdevice.
- */
-static void
-dio200_subdev_8254_cleanup(struct comedi_device *dev,
-                          struct comedi_subdevice *s)
-{
-       struct dio200_subdev_intr *subpriv = s->private;
-       kfree(subpriv);
-}
-
 /*
  * This function sets I/O directions for an '8255' DIO subdevice.
  */
@@ -1064,17 +1042,6 @@ static int dio200_subdev_8255_init(struct comedi_device *dev,
        return 0;
 }
 
-/*
- * This function cleans up an '8255' DIO subdevice.
- */
-static void dio200_subdev_8255_cleanup(struct comedi_device *dev,
-                                      struct comedi_subdevice *s)
-{
-       struct dio200_subdev_8255 *subpriv = s->private;
-
-       kfree(subpriv);
-}
-
 /*
  * Handle 'insn_read' for a timer subdevice.
  */
@@ -1178,15 +1145,6 @@ static int dio200_subdev_timer_init(struct comedi_device *dev,
        return 0;
 }
 
-/*
- * This function cleans up a timer subdevice.
- */
-static void dio200_subdev_timer_cleanup(struct comedi_device *dev,
-                                       struct comedi_subdevice *s)
-{
-       /* Nothing to do. */
-}
-
 void amplc_dio200_set_enhance(struct comedi_device *dev, unsigned char val)
 {
        dio200_write8(dev, DIO200_ENHANCE, val);
@@ -1282,20 +1240,13 @@ void amplc_dio200_common_detach(struct comedi_device *dev)
        if (dev->subdevices) {
                layout = dio200_board_layout(thisboard);
                for (n = 0; n < dev->n_subdevices; n++) {
-                       struct comedi_subdevice *s = &dev->subdevices[n];
                        switch (layout->sdtype[n]) {
                        case sd_8254:
-                               dio200_subdev_8254_cleanup(dev, s);
-                               break;
                        case sd_8255:
-                               dio200_subdev_8255_cleanup(dev, s);
-                               break;
                        case sd_intr:
-                               dio200_subdev_intr_cleanup(dev, s);
+                               comedi_spriv_free(dev, n);
                                break;
                        case sd_timer:
-                               dio200_subdev_timer_cleanup(dev, s);
-                               break;
                        default:
                                break;
                        }
index e789383ce49d697657888c8cc68bfcdd63a4411f..0f1a0f806cc69af16a40c023e6bfa50b74a6fec9 100644 (file)
@@ -545,8 +545,7 @@ static void pc236_detach(struct comedi_device *dev)
                pc236_intr_disable(dev);
        if (dev->irq)
                free_irq(dev->irq, dev);
-       if (dev->subdevices)
-               subdev_8255_cleanup(dev, &dev->subdevices[0]);
+       comedi_spriv_free(dev, 0);
        if (is_isa_board(thisboard)) {
                if (dev->iobase)
                        release_region(dev->iobase, PC236_IO_SIZE);
index b6e4af444ef5718588178048acc591eb04af75b7..49200fbd60b994b6984ca42dff9f404f8a54ea4d 100644 (file)
@@ -2832,11 +2832,9 @@ static int pci230_auto_attach(struct comedi_device *dev,
 
 static void pci230_detach(struct comedi_device *dev)
 {
-       const struct pci230_board *thisboard = comedi_board(dev);
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
 
-       if (dev->subdevices && thisboard->have_dio)
-               subdev_8255_cleanup(dev, &dev->subdevices[2]);
+       comedi_spriv_free(dev, 2);
        if (dev->irq)
                free_irq(dev->irq, dev);
        comedi_pci_disable(dev);
index cdbeb0833d0b8e8e4aad86248c8972326b6732de..53dd298d2b5443e41413676fa980ed7cce46c64c 100644 (file)
@@ -1608,8 +1608,7 @@ static void cb_pcidas_detach(struct comedi_device *dev)
        }
        if (dev->irq)
                free_irq(dev->irq, dev);
-       if (dev->subdevices)
-               subdev_8255_cleanup(dev, &dev->subdevices[2]);
+       comedi_spriv_free(dev, 2);
        comedi_pci_disable(dev);
 }
 
index cfcde124143df1658ab3b864a80fe8943c95445c..c3e5495b4f06aa43b45ec8932ec0d88bee99865a 100644 (file)
@@ -4163,8 +4163,7 @@ static void detach(struct comedi_device *dev)
                                        devpriv->ao_dma_desc_bus_addr);
                }
        }
-       if (dev->subdevices)
-               subdev_8255_cleanup(dev, &dev->subdevices[4]);
+       comedi_spriv_free(dev, 4);
        comedi_pci_disable(dev);
 }
 
index 2da6bd663affc4869e4118331c3c46e892792f4e..f9b459888b8b8f3f1b18349a104698db2c947773 100644 (file)
@@ -399,10 +399,8 @@ static int cb_pcidda_auto_attach(struct comedi_device *dev,
 
 static void cb_pcidda_detach(struct comedi_device *dev)
 {
-       if (dev->subdevices) {
-               subdev_8255_cleanup(dev, &dev->subdevices[1]);
-               subdev_8255_cleanup(dev, &dev->subdevices[2]);
-       }
+       comedi_spriv_free(dev, 1);
+       comedi_spriv_free(dev, 2);
        comedi_pci_disable(dev);
 }
 
index f7d1136be652e9f21d2de54bc23f7f5ec4d0f329..88f03ae6f3e67b28e83627d2682c3ffd0ad4d688 100644 (file)
@@ -199,8 +199,7 @@ static int cb_pcimdda_auto_attach(struct comedi_device *dev,
 
 static void cb_pcimdda_detach(struct comedi_device *dev)
 {
-       if (dev->subdevices)
-               subdev_8255_cleanup(dev, &dev->subdevices[1]);
+       comedi_spriv_free(dev, 1);
        comedi_pci_disable(dev);
 }
 
index ed3d6e510818ddc66472d88af2cf8696cf1cf839..c1f14f0b6c1a362220f333d66cc0236d2ff702e7 100644 (file)
@@ -766,8 +766,7 @@ static void daqboard2000_detach(struct comedi_device *dev)
 {
        struct daqboard2000_private *devpriv = dev->private;
 
-       if (dev->subdevices)
-               subdev_8255_cleanup(dev, &dev->subdevices[2]);
+       comedi_spriv_free(dev, 2);
        if (dev->irq)
                free_irq(dev->irq, dev);
        if (devpriv) {
index 9823aa06787a2510fdc0d93289eb9dde01554d34..ba12c1d605fb956a2c963bf97367cba37158598f 100644 (file)
@@ -568,8 +568,7 @@ EXPORT_SYMBOL_GPL(das08_common_attach);
 
 void das08_common_detach(struct comedi_device *dev)
 {
-       if (dev->subdevices)
-               subdev_8255_cleanup(dev, &dev->subdevices[4]);
+       comedi_spriv_free(dev, 4);
 }
 EXPORT_SYMBOL_GPL(das08_common_detach);
 
index 50902ccb519373d0f35f408329388f01d89da773..c2b5015448ae3a8ccced8bd81c576fc085baff5e 100644 (file)
@@ -1339,8 +1339,7 @@ static void das16_detach(struct comedi_device *dev)
        struct das16_private_struct *devpriv = dev->private;
 
        das16_reset(dev);
-       if (dev->subdevices)
-               subdev_8255_cleanup(dev, &dev->subdevices[4]);
+       comedi_spriv_free(dev, 4);
        if (devpriv) {
                int i;
                for (i = 0; i < 2; i++) {
index 77f213b4450b22088b272e7cd76c5e8d86c32edc..91aba224beb91b73d843f9998d0460b7a6ba1b85 100644 (file)
@@ -669,8 +669,7 @@ static int das16m1_attach(struct comedi_device *dev,
 
 static void das16m1_detach(struct comedi_device *dev)
 {
-       if (dev->subdevices)
-               subdev_8255_cleanup(dev, &dev->subdevices[3]);
+       comedi_spriv_free(dev, 3);
        if (dev->irq)
                free_irq(dev->irq, dev);
        if (dev->iobase) {
index 013392cfe2a1abe84d2b442e92faa85cd8dea455..3f71f0f54d3ce257398b9eee038aea4f3f5f6fa1 100644 (file)
@@ -730,6 +730,7 @@ static int ni_65xx_auto_attach(struct comedi_device *dev,
 static void ni_65xx_detach(struct comedi_device *dev)
 {
        struct ni_65xx_private *devpriv = dev->private;
+       int i;
 
        if (devpriv && devpriv->mite && devpriv->mite->daq_io_addr) {
                writeb(0x00,
@@ -738,15 +739,9 @@ static void ni_65xx_detach(struct comedi_device *dev)
        }
        if (dev->irq)
                free_irq(dev->irq, dev);
+       for (i = 0; i < dev->n_subdevices; ++i)
+               comedi_spriv_free(dev, i);
        if (devpriv) {
-               struct comedi_subdevice *s;
-               unsigned i;
-
-               for (i = 0; i < dev->n_subdevices; ++i) {
-                       s = &dev->subdevices[i];
-                       kfree(s->private);
-                       s->private = NULL;
-               }
                if (devpriv->mite) {
                        mite_unsetup(devpriv->mite);
                        mite_free(devpriv->mite);
index 4bfe6c8d0cce5cf8b7d45ad3cdaae613ad02de28..4fb36cd833df1f7ffeee4a97165c899cc34ba33d 100644 (file)
@@ -767,13 +767,7 @@ static int atmio16d_attach(struct comedi_device *dev,
 
 static void atmio16d_detach(struct comedi_device *dev)
 {
-       const struct atmio16_board_t *board = comedi_board(dev);
-       struct comedi_subdevice *s;
-
-       if (dev->subdevices && board->has_8255) {
-               s = &dev->subdevices[3];
-               subdev_8255_cleanup(dev, s);
-       }
+       comedi_spriv_free(dev, 3);
        if (dev->irq)
                free_irq(dev->irq, dev);
        reset_atmio16d(dev);
index c17ffe3cf5c41209ee532615b02ff5cf2bc32b14..9b7805fda93252c7162f5c87b7005494ee470942 100644 (file)
@@ -73,8 +73,7 @@ static int dio24_auto_attach(struct comedi_device *dev,
 
 static void dio24_detach(struct comedi_device *dev)
 {
-       if (dev->subdevices)
-               subdev_8255_cleanup(dev, &dev->subdevices[0]);
+       comedi_spriv_free(dev, 0);
        comedi_pcmcia_disable(dev);
 }
 
index 19961424d1df4ac159ea08c0ef48e4dffd605d61..d48511f0cacd543c582af75c230ff460886fd06f 100644 (file)
@@ -1860,14 +1860,10 @@ void labpc_common_detach(struct comedi_device *dev)
 {
        const struct labpc_boardinfo *board = comedi_board(dev);
        struct labpc_private *devpriv = dev->private;
-       struct comedi_subdevice *s;
 
        if (!board)
                return;
-       if (dev->subdevices) {
-               s = &dev->subdevices[2];
-               subdev_8255_cleanup(dev, s);
-       }
+       comedi_spriv_free(dev, 2);
 #ifdef CONFIG_ISA_DMA_API
        /* only free stuff if it has been allocated by _attach */
        kfree(devpriv->dma_buffer);
index 0f8d05c35391b9d7e563302b2229ac14d749e9e0..a46d579016d9571eef12db6bff2e95beea47e4d2 100644 (file)
@@ -4068,19 +4068,14 @@ static int ni_serial_sw_readwrite8(struct comedi_device *dev,
 
 static void mio_common_detach(struct comedi_device *dev)
 {
-       const struct ni_board_struct *board = comedi_board(dev);
        struct ni_private *devpriv = dev->private;
-       struct comedi_subdevice *s;
 
        if (devpriv) {
                if (devpriv->counter_dev) {
                        ni_gpct_device_destroy(devpriv->counter_dev);
                }
        }
-       if (dev->subdevices && board->has_8255) {
-               s = &dev->subdevices[NI_8255_DIO_SUBDEV];
-               subdev_8255_cleanup(dev, s);
-       }
+       comedi_spriv_free(dev, NI_8255_DIO_SUBDEV);
 }
 
 static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s)
index 2821ead2772c42f058d0455c4074ccee1c8bed8a..0f5a4821cf5fa0890522c798ffb2b7c1efbc9424 100644 (file)
@@ -170,13 +170,10 @@ static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 static void pcl724_detach(struct comedi_device *dev)
 {
        const struct pcl724_board *board = comedi_board(dev);
-       struct comedi_subdevice *s;
        int i;
 
-       for (i = 0; i < dev->n_subdevices; i++) {
-               s = &dev->subdevices[i];
-               subdev_8255_cleanup(dev, s);
-       }
+       for (i = 0; i < dev->n_subdevices; i++)
+               comedi_spriv_free(dev, i);
 #ifdef PCL724_IRQ
        if (dev->irq)
                free_irq(dev->irq, dev);
index 7f9266cefc169aaaee10916e0fdbb2cba01079f6..19742d1ba56846e5184589a03dd3b1edfbd94bb2 100644 (file)
@@ -252,15 +252,10 @@ static int pcm3724_attach(struct comedi_device *dev,
 
 static void pcm3724_detach(struct comedi_device *dev)
 {
-       struct comedi_subdevice *s;
        int i;
 
-       if (dev->subdevices) {
-               for (i = 0; i < dev->n_subdevices; i++) {
-                       s = &dev->subdevices[i];
-                       subdev_8255_cleanup(dev, s);
-               }
-       }
+       for (i = 0; i < dev->n_subdevices; i++)
+               comedi_spriv_free(dev, i);
        if (dev->iobase)
                release_region(dev->iobase, PCM3724_SIZE);
 }