staging: comedi: addi_apci_16xx: cleanup addi_find_boardinfo()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 18 Jan 2013 17:48:25 +0000 (10:48 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 18 Jan 2013 20:57:24 +0000 (12:57 -0800)
This function was originally in the addi-data "common" code and
required using pointer math to access the boardinfo data using
the void * 'dev->driver->board_name'. Now that the function is
local to this driver we can access the boardinfo directly and
remove the pointer math.

Rename the function so it has namespace associated with this
driver.

Also, for aesthetic reasons, globally rename the local variable used
for the boardinfo pointer from 'this_board' to 'board',

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/addi_apci_16xx.c

index 23aafe2c6f8282717d23b1886e676b257e81c80f..899dae14a75ce4fa25e27c7d73fb8edab394fded 100644 (file)
@@ -26,19 +26,17 @@ static const struct apci16xx_boardinfo apci16xx_boardtypes[] = {
        },
 };
 
-static const void *addi_find_boardinfo(struct comedi_device *dev,
-                                      struct pci_dev *pcidev)
+static const void *apci16xx_find_boardinfo(struct comedi_device *dev,
+                                          struct pci_dev *pcidev)
 {
-       const void *p = dev->driver->board_name;
-       const struct apci16xx_boardinfo *this_board;
+       const struct apci16xx_boardinfo *board;
        int i;
 
-       for (i = 0; i < dev->driver->num_names; i++) {
-               this_board = p;
-               if (this_board->vendor == pcidev->vendor &&
-                   this_board->device == pcidev->device)
-                       return this_board;
-               p += dev->driver->offset;
+       for (i = 0; i < ARRAY_SIZE(apci16xx_boardtypes); i++) {
+               board = &apci16xx_boardtypes[i];
+               if (board->vendor == pcidev->vendor &&
+                   board->device == pcidev->device)
+                       return board;
        }
        return NULL;
 }
@@ -47,16 +45,16 @@ static int apci16xx_auto_attach(struct comedi_device *dev,
                                unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
-       const struct apci16xx_boardinfo *this_board;
+       const struct apci16xx_boardinfo *board;
        struct addi_private *devpriv;
        struct comedi_subdevice *s;
        int ret;
 
-       this_board = addi_find_boardinfo(dev, pcidev);
-       if (!this_board)
+       board = apci16xx_find_boardinfo(dev, pcidev);
+       if (!board)
                return -ENODEV;
-       dev->board_ptr = this_board;
-       dev->board_name = this_board->name;
+       dev->board_ptr = board;
+       dev->board_name = board->name;
 
        devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
        if (!devpriv)
@@ -77,10 +75,10 @@ static int apci16xx_auto_attach(struct comedi_device *dev,
        s = &dev->subdevices[0];
        s->type         = COMEDI_SUBD_DIO;
        s->subdev_flags = SDF_WRITEABLE | SDF_READABLE;
-       s->n_chan       = this_board->n_chan;
+       s->n_chan       = board->n_chan;
        s->maxdata      = 1;
        s->io_bits      = 0;    /* all bits input */
-       s->len_chanlist = this_board->n_chan;
+       s->len_chanlist = board->n_chan;
        s->range_table  = &range_digital;
        s->insn_config  = i_APCI16XX_InsnConfigInitTTLIO;
        s->insn_bits    = i_APCI16XX_InsnBitsReadTTLIO;