Constified ranges, board structures, and miscellaneous data.
[comedi.git] / comedi / drivers / poc.c
index 3efd2dc08034376acc845782f6ebadcab9626f8c..bd7ad8b53ebac452e5a427f7bca9996438c0fc58 100644 (file)
@@ -21,7 +21,6 @@
 /*
 Driver: poc.o
 Description: Generic driver for very simple devices
-Device names: dac02
 Author: ds
 Devices: [Keithley Metrabyte] DAC-02 (dac02), [Advantech] PCL-733 (pcl733),
   PCL-734 (pcl734)
@@ -53,8 +52,8 @@ static int pcl734_insn_bits(comedi_device *dev,comedi_subdevice *s,
        comedi_insn *insn,lsampl_t *data);
 
 struct boarddef_struct{
-       char *name;
-       int iosize;
+       const char *name;
+       unsigned int iosize;
        int (*setup)(comedi_device *);
        int type;
        int n_chan;
@@ -62,9 +61,9 @@ struct boarddef_struct{
        int (*winsn)(comedi_device *,comedi_subdevice *,comedi_insn *,lsampl_t *);
        int (*rinsn)(comedi_device *,comedi_subdevice *,comedi_insn *,lsampl_t *);
        int (*insnbits)(comedi_device *,comedi_subdevice *,comedi_insn *,lsampl_t *);
-       comedi_lrange* range;
+       const comedi_lrange *range;
 };
-static struct boarddef_struct boards[]={
+static const struct boarddef_struct boards[]={
        {
        name:           "dac02",
        iosize:         8,
@@ -96,7 +95,7 @@ static struct boarddef_struct boards[]={
        },
 };
 #define n_boards (sizeof(boards)/sizeof(boards[0]))
-#define this_board ((struct boarddef_struct *)dev->board_ptr)
+#define this_board ((const struct boarddef_struct *)dev->board_ptr)
 
 static comedi_driver driver_poc=
 {
@@ -104,7 +103,7 @@ static comedi_driver driver_poc=
        module:         THIS_MODULE,
        attach:         poc_attach,
        detach:         poc_detach,
-       board_name:     boards,
+       board_name:     &boards[0].name,
        num_names:      n_boards,
        offset:         sizeof(boards[0]),
 };
@@ -112,10 +111,11 @@ static comedi_driver driver_poc=
 static int poc_attach(comedi_device *dev, comedi_devconfig *it)
 {
        comedi_subdevice *s;
-       int iosize, iobase;
+       unsigned long iobase;
+       unsigned int iosize;
 
        iobase = it->options[0];
-       printk("comedi%d: poc: using %s iobase 0x%x\n", dev->minor,
+       printk("comedi%d: poc: using %s iobase 0x%lx\n", dev->minor,
                this_board->name, iobase);
 
        dev->board_name = this_board->name;
@@ -128,17 +128,15 @@ static int poc_attach(comedi_device *dev, comedi_devconfig *it)
 
        iosize = this_board->iosize;
        /* check if io addresses are available */
-       if(check_region(iobase, iosize) < 0)
+       if(!request_region(iobase, iosize, "dac02"))
        {
-               printk("I/O port conflict: failed to allocate ports 0x%x to 0x%x\n",
+               printk("I/O port conflict: failed to allocate ports 0x%lx to 0x%lx\n",
                        iobase, iobase + iosize - 1);
                return -EIO;
        }
-       request_region(iobase, iosize, "dac02");
        dev->iobase = iobase;
 
-       dev->n_subdevices = 1;
-       if(alloc_subdevices(dev) < 0)
+       if(alloc_subdevices(dev, 1) < 0)
                return -ENOMEM;
        if(alloc_private(dev,sizeof(lsampl_t)*this_board->n_chan) < 0)
                return -ENOMEM;
@@ -193,7 +191,7 @@ static int dac02_ao_winsn(comedi_device *dev,comedi_subdevice *s,comedi_insn *in
        chan = CR_CHAN(insn->chanspec);
        ((lsampl_t *)dev->private)[chan] = data[0];
        output = data[0];
-#if wrong
+#ifdef wrong
        // convert to complementary binary if range is bipolar
        if((CR_RANGE(insn->chanspec) & 0x2) == 0)
                output = ~output;
@@ -210,7 +208,7 @@ static int pcl733_insn_bits(comedi_device *dev,comedi_subdevice *s,
        comedi_insn *insn,lsampl_t *data)
 {
        if(insn->n!=2)return -EINVAL;
-       
+
        data[1] = inb(dev->iobase + 0);
        data[1] |= (inb(dev->iobase + 1) << 8);
        data[1] |= (inb(dev->iobase + 2) << 16);