]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/staging/comedi/drivers/adl_pci6208.c
Staging: comedi: make use of ARRAY_SIZE macro
[mv-sheeva.git] / drivers / staging / comedi / drivers / adl_pci6208.c
index f710f551820d293bf7e0193d310ca7b2ea033de6..b4807fc7eb01a95075629d8b71c637e3dc011b45 100644 (file)
@@ -61,35 +61,35 @@ struct pci6208_board {
        const char *name;
        unsigned short dev_id;  /* `lspci` will show you this */
        int ao_chans;
-       //int ao_bits;
+       /* int ao_bits; */
 };
 
 static const struct pci6208_board pci6208_boards[] = {
        /*{
-          name :  "pci6208v",
-          dev_id       :  0x6208,      //not sure
-          ao_chans:  8
-          //,  ao_bits :  16
+       .name = "pci6208v",
+       .dev_id = 0x6208,      // not sure
+       .ao_chans = 8
+          // , .ao_bits = 16
           },
           {
-          name :  "pci6216v",
-          dev_id       :  0x6208,      //not sure
-          ao_chans:  16
-          //,  ao_bits :  16
+       .name = "pci6216v",
+       .dev_id = 0x6208,      // not sure
+       .ao_chans = 16
+          // , .ao_bits = 16
           }, */
        {
-             name:     "pci6208a",
-             dev_id:   0x6208,
-             ao_chans:8
-                       //,     ao_bits :  16
+       .name = "pci6208a",
+       .dev_id = 0x6208,
+       .ao_chans = 8
+                       /* ,    .ao_bits = 16 */
                }
 };
 
 /* This is used by modprobe to translate PCI IDs to drivers.  Should
  * only be used for PCI and ISA-PnP devices */
 static DEFINE_PCI_DEVICE_TABLE(pci6208_pci_table) = {
-       //{ PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-       //{ PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+       /* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
+       /* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
        {PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
        {0}
 };
@@ -107,35 +107,32 @@ struct pci6208_private {
 
 #define devpriv ((struct pci6208_private *)dev->private)
 
-static int pci6208_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pci6208_detach(struct comedi_device * dev);
-
-#define pci6208_board_nbr \
-       (sizeof(pci6208_boards) / sizeof(struct pci6208_board))
+static int pci6208_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci6208_detach(struct comedi_device *dev);
 
 static struct comedi_driver driver_pci6208 = {
-      driver_name:PCI6208_DRIVER_NAME,
-      module:THIS_MODULE,
-      attach:pci6208_attach,
-      detach:pci6208_detach,
+       .driver_name = PCI6208_DRIVER_NAME,
+       .module = THIS_MODULE,
+       .attach = pci6208_attach,
+       .detach = pci6208_detach,
 };
 
 COMEDI_PCI_INITCLEANUP(driver_pci6208, pci6208_pci_table);
 
-static int pci6208_find_device(struct comedi_device * dev, int bus, int slot);
+static int pci6208_find_device(struct comedi_device *dev, int bus, int slot);
 static int
 pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
        int dev_minor);
 
 /*read/write functions*/
-static int pci6208_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
-       struct comedi_insn * insn, unsigned int * data);
-static int pci6208_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
-       struct comedi_insn * insn, unsigned int * data);
-//static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s,
-//      struct comedi_insn *insn,unsigned int *data);
-//static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s,
-//      struct comedi_insn *insn,unsigned int *data);
+static int pci6208_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+       struct comedi_insn *insn, unsigned int *data);
+static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+       struct comedi_insn *insn, unsigned int *data);
+/* static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, */
+/* struct comedi_insn *insn,unsigned int *data); */
+/* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */
+/* struct comedi_insn *insn,unsigned int *data); */
 
 /*
  * Attach is called by the Comedi core to configure the driver
@@ -143,7 +140,7 @@ static int pci6208_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice
  * in the driver structure, dev->board_ptr contains that
  * address.
  */
-static int pci6208_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pci6208_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
        struct comedi_subdevice *s;
        int retval;
@@ -176,22 +173,22 @@ static int pci6208_attach(struct comedi_device * dev, struct comedi_devconfig *
        s = dev->subdevices + 0;
        /* analog output subdevice */
        s->type = COMEDI_SUBD_AO;
-       s->subdev_flags = SDF_WRITABLE; //anything else to add here??
+       s->subdev_flags = SDF_WRITABLE; /* anything else to add here?? */
        s->n_chan = thisboard->ao_chans;
-       s->maxdata = 0xffff;    //16-bit DAC
-       s->range_table = &range_bipolar10;      //this needs to be checked.
+       s->maxdata = 0xffff;    /* 16-bit DAC */
+       s->range_table = &range_bipolar10;      /* this needs to be checked. */
        s->insn_write = pci6208_ao_winsn;
        s->insn_read = pci6208_ao_rinsn;
 
-       //s=dev->subdevices+1;
+       /* s=dev->subdevices+1; */
        /* digital i/o subdevice */
-       //s->type=COMEDI_SUBD_DIO;
-       //s->subdev_flags=SDF_READABLE|SDF_WRITABLE;
-       //s->n_chan=16;
-       //s->maxdata=1;
-       //s->range_table=&range_digital;
-       //s->insn_bits = pci6208_dio_insn_bits;
-       //s->insn_config = pci6208_dio_insn_config;
+       /* s->type=COMEDI_SUBD_DIO; */
+       /* s->subdev_flags=SDF_READABLE|SDF_WRITABLE; */
+       /* s->n_chan=16; */
+       /* s->maxdata=1; */
+       /* s->range_table=&range_digital; */
+       /* s->insn_bits = pci6208_dio_insn_bits; */
+       /* s->insn_config = pci6208_dio_insn_config; */
 
        printk("attached\n");
 
@@ -206,7 +203,7 @@ static int pci6208_attach(struct comedi_device * dev, struct comedi_devconfig *
  * allocated by _attach().  dev->private and dev->subdevices are
  * deallocated automatically by the core.
  */
-static int pci6208_detach(struct comedi_device * dev)
+static int pci6208_detach(struct comedi_device *dev)
 {
        printk("comedi%d: pci6208: remove\n", dev->minor);
 
@@ -220,8 +217,8 @@ static int pci6208_detach(struct comedi_device * dev)
        return 0;
 }
 
-static int pci6208_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
-       struct comedi_insn * insn, unsigned int * data)
+static int pci6208_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+       struct comedi_insn *insn, unsigned int *data)
 {
        int i = 0, Data_Read;
        unsigned short chan = CR_CHAN(insn->chanspec);
@@ -245,8 +242,8 @@ static int pci6208_ao_winsn(struct comedi_device * dev, struct comedi_subdevice
 
 /* AO subdevices should have a read insn as well as a write insn.
  * Usually this means copying a value stored in devpriv. */
-static int pci6208_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
-       struct comedi_insn * insn, unsigned int * data)
+static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+       struct comedi_insn *insn, unsigned int *data)
 {
        int i;
        int chan = CR_CHAN(insn->chanspec);
@@ -262,51 +259,51 @@ static int pci6208_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice
  * useful to applications if you implement the insn_bits interface.
  * This allows packed reading/writing of the DIO channels.  The
  * comedi core can convert between insn_bits and insn_read/write */
-//static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s,
-//      struct comedi_insn *insn,unsigned int *data)
-//{
-//      if(insn->n!=2)return -EINVAL;
+/* static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, */
+/* struct comedi_insn *insn,unsigned int *data) */
+/* { */
+/* if(insn->n!=2)return -EINVAL; */
 
        /* The insn data is a mask in data[0] and the new data
         * in data[1], each channel cooresponding to a bit. */
-//      if(data[0]){
-//              s->state &= ~data[0];
-//              s->state |= data[0]&data[1];
+/* if(data[0]){ */
+/* s->state &= ~data[0]; */
+/* s->state |= data[0]&data[1]; */
                /* Write out the new digital output lines */
-               //outw(s->state,dev->iobase + SKEL_DIO);
-//      }
+               /* outw(s->state,dev->iobase + SKEL_DIO); */
+/* } */
 
        /* on return, data[1] contains the value of the digital
         * input and output lines. */
-       //data[1]=inw(dev->iobase + SKEL_DIO);
+       /* data[1]=inw(dev->iobase + SKEL_DIO); */
        /* or we could just return the software copy of the output values if
         * it was a purely digital output subdevice */
-       //data[1]=s->state;
+       /* data[1]=s->state; */
 
-//      return 2;
-//}
+/* return 2; */
+/* } */
 
-//static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s,
-//      struct comedi_insn *insn,unsigned int *data)
-//{
-//      int chan=CR_CHAN(insn->chanspec);
+/* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */
+/* struct comedi_insn *insn,unsigned int *data) */
+/* { */
+/* int chan=CR_CHAN(insn->chanspec); */
 
        /* The input or output configuration of each digital line is
         * configured by a special insn_config instruction.  chanspec
         * contains the channel to be changed, and data[0] contains the
         * value COMEDI_INPUT or COMEDI_OUTPUT. */
 
-//      if(data[0]==COMEDI_OUTPUT){
-//              s->io_bits |= 1<<chan;
-//      }else{
-//              s->io_bits &= ~(1<<chan);
-//      }
-       //outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG);
+/* if(data[0]==COMEDI_OUTPUT){ */
+/* s->io_bits |= 1<<chan; */
+/* }else{ */
+/* s->io_bits &= ~(1<<chan); */
+/* } */
+       /* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */
 
-//      return 1;
-//}
+/* return 1; */
+/* } */
 
-static int pci6208_find_device(struct comedi_device * dev, int bus, int slot)
+static int pci6208_find_device(struct comedi_device *dev, int bus, int slot)
 {
        struct pci_dev *pci_dev;
        int i;
@@ -315,11 +312,11 @@ static int pci6208_find_device(struct comedi_device * dev, int bus, int slot)
                pci_dev != NULL;
                pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) {
                if (pci_dev->vendor == PCI_VENDOR_ID_ADLINK) {
-                       for (i = 0; i < pci6208_board_nbr; i++) {
+                       for (i = 0; i < ARRAY_SIZE(pci6208_boards); i++) {
                                if (pci6208_boards[i].dev_id == pci_dev->device) {
-                                       // was a particular bus/slot requested?
+                                       /*  was a particular bus/slot requested? */
                                        if ((bus != 0) || (slot != 0)) {
-                                               // are we on the wrong bus/slot?
+                                               /*  are we on the wrong bus/slot? */
                                                if (pci_dev->bus->number
                                                        != bus ||
                                                        PCI_SLOT(pci_dev->devfn)
@@ -346,10 +343,10 @@ static int pci6208_find_device(struct comedi_device * dev, int bus, int slot)
                PCI_SLOT(pci_dev->devfn),
                PCI_FUNC(pci_dev->devfn), pci_dev->irq);
 
-       // TODO: Warn about non-tested boards.
-       //switch(board->device_id)
-       //{
-       //};
+       /*  TODO: Warn about non-tested boards. */
+       /* switch(board->device_id) */
+       /* { */
+       /* }; */
 
        devpriv->pci_dev = pci_dev;
 
@@ -362,19 +359,19 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
 {
        unsigned long io_base, io_range, lcr_io_base, lcr_io_range;
 
-       // Enable PCI device and request regions
+       /*  Enable PCI device and request regions */
        if (comedi_pci_enable(pci_dev, PCI6208_DRIVER_NAME) < 0) {
                printk("comedi%d: Failed to enable PCI device and request regions\n", dev_minor);
                return -EIO;
        }
-       // Read local configuration register base address [PCI_BASE_ADDRESS #1].
+       /*  Read local configuration register base address [PCI_BASE_ADDRESS #1]. */
        lcr_io_base = pci_resource_start(pci_dev, 1);
        lcr_io_range = pci_resource_len(pci_dev, 1);
 
        printk("comedi%d: local config registers at address 0x%4lx [0x%4lx]\n",
                dev_minor, lcr_io_base, lcr_io_range);
 
-       // Read PCI6208 register base address [PCI_BASE_ADDRESS #2].
+       /*  Read PCI6208 register base address [PCI_BASE_ADDRESS #2]. */
        io_base = pci_resource_start(pci_dev, 2);
        io_range = pci_resource_end(pci_dev, 2) - io_base + 1;
 
@@ -382,10 +379,10 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
                dev_minor, io_base, io_range);
 
        *io_base_ptr = io_base;
-       //devpriv->io_range = io_range;
-       //devpriv->is_valid=0;
-       //devpriv->lcr_io_base=lcr_io_base;
-       //devpriv->lcr_io_range=lcr_io_range;
+       /* devpriv->io_range = io_range; */
+       /* devpriv->is_valid=0; */
+       /* devpriv->lcr_io_base=lcr_io_base; */
+       /* devpriv->lcr_io_range=lcr_io_range; */
 
        return 0;
 }