Add subdev_8255_cleanup()
authorDavid Schleef <ds@schleef.org>
Wed, 18 Jun 2003 01:25:02 +0000 (01:25 +0000)
committerDavid Schleef <ds@schleef.org>
Wed, 18 Jun 2003 01:25:02 +0000 (01:25 +0000)
comedi/drivers/adv_pci_dio.c

index d138cf276496073713e2f4e2fc3ebfb8848f769b..6944e9440df8ec49106d49b0bdfa0948db7c3a66 100644 (file)
@@ -1009,14 +1009,36 @@ static int pci_dio_attach(comedi_device *dev, comedi_devconfig *it)
 */
 static int pci_dio_detach(comedi_device *dev)
 {
-       int i;
+       int i, j;
        comedi_subdevice *s;
+       int subdev;
                
        if (dev->private) {
                if (devpriv->valid) {
                        pci_dio_reset(dev);
                }
 
+               /* This shows the silliness of using this kind of
+                * scheme for numbering subdevices.  Don't do it.  --ds */
+               subdev = 0;
+               for (i=0; i<MAX_DI_SUBDEVS; i++){
+                       if (this_board->sdi[i].chans) {
+                               subdev++;
+                       }
+               }
+               for (i=0; i<MAX_DO_SUBDEVS; i++){
+                       if (this_board->sdo[i].chans) {
+                               subdev++;
+                       }
+               }
+               for (i=0; i<MAX_DIO_SUBDEVG; i++){
+                       for (j=0; j<this_board->sdio[i].regs; j++) {
+                               s = dev->subdevices + subdev;
+                               subdev_8255_cleanup(dev, s);
+                               subdev++;
+                       }
+               }
+
                for (i=0; i<dev->n_subdevices; i++) {
                        s=dev->subdevices+i;
                        s->private=NULL;