added 2 8255 digital io subdevices
authorFrank Mori Hess <fmhess@speakeasy.net>
Mon, 9 Jul 2001 18:38:03 +0000 (18:38 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Mon, 9 Jul 2001 18:38:03 +0000 (18:38 +0000)
comedi/drivers/cb_pcidda.c

index 8a62afc4f50ec0cee2e9d03fd8fd24b8ea8f0d4b..ed6bad9f46bfac9ecfe136df3f1d979c86782d62 100644 (file)
@@ -236,7 +236,7 @@ static int cb_pcidda_attach(comedi_device *dev, comedi_devconfig *it)
        unsigned int dac, digitalio;
 
        printk("comedi%d: cb_pcidda: ",dev->minor);
-       
+
 /*
  * Allocate the private structure area.
  */
@@ -338,7 +338,7 @@ found:
 /*
  * Allocate the subdevice structures.
  */
-       dev->n_subdevices=1;
+       dev->n_subdevices=3;
        if(alloc_subdevices(dev)<0)
                return -ENOMEM;
 
@@ -352,7 +352,14 @@ found:
        s->insn_write = &cb_pcidda_ao_winsn;
 //     s->do_cmd = &cb_pcidda_ai_cmd;
        s->do_cmdtest = &cb_pcidda_ai_cmdtest;
-       
+
+       // two 8255 digital io subdevices
+       s = dev->subdevices + 1;
+       subdev_8255_init(dev, s, NULL, (void *)(devpriv->digitalio));
+       s = dev->subdevices + 2;
+       subdev_8255_init(dev, s, NULL,
+               (void *)(devpriv->digitalio + PORT2A));
+
        return 1;
 }
 
@@ -377,6 +384,13 @@ static int cb_pcidda_detach(comedi_device *dev)
                if(devpriv->dac)
                        release_region(devpriv->dac, 8 + thisboard->ao_chans*2);
        }
+       // cleanup 8255
+       if(dev->subdevices)
+       {
+               subdev_8255_cleanup(dev, dev->subdevices + 1);
+               subdev_8255_cleanup(dev, dev->subdevices + 2);
+       }
+
        printk("comedi%d: cb_pcidda: remove\n",dev->minor);
 
        return 0;