staging: comedi: gsc_hpdi: remove multiple board type support
authorIan Abbott <abbotti@mev.co.uk>
Tue, 5 May 2015 17:47:25 +0000 (18:47 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 May 2015 12:57:26 +0000 (14:57 +0200)
The code for determining which board type matches the PCI device ID is
over-the-top since only a single board type is supported.  Also, the
method it uses match the PCI device ID to a board type is a little
antiquated.  Most comedi drivers for PCI devices use `driver_data` from
the probed PCI device as an index into an array of supported board
types, but "gsc_hpdi" uses a `for` loop to find an element of
`hpdi_boards[]` that matches the PCI device.  The only thing in
`hpdi_boards[]` not used for finding a matching PCI device is the `name`
member of `struct hpdi_board` which points to a string literal and ends
up getting assigned to `dev->board_name`.

Get rid of the multiple board type support, and set `dev->board_name` to
point to the original string literal pointed to by
`hpdi_boards[0].name`.  This string is visible to userspace.

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

index 901025216971f831255c1c4e52c8273179731524..0e04f15feb389ea1658c970c3e18451da5f92de1 100644 (file)
 #define NUM_DMA_BUFFERS                                4
 #define NUM_DMA_DESCRIPTORS                    256
 
-struct hpdi_board {
-       const char *name;
-       int device_id;
-       int subdevice_id;
-};
-
-static const struct hpdi_board hpdi_boards[] = {
-       {
-               .name           = "pci-hpdi32",
-               .device_id      = PCI_DEVICE_ID_PLX_9080,
-               .subdevice_id   = 0x2400,
-        },
-};
-
 struct hpdi_private {
        void __iomem *plx9080_mmio;
        uint32_t *dio_buffer[NUM_DMA_BUFFERS];  /* dma buffers */
@@ -601,35 +587,16 @@ static void gsc_hpdi_init_plx9080(struct comedi_device *dev)
        writel(bits, plx_iobase + PLX_DMA0_MODE_REG);
 }
 
-static const struct hpdi_board *gsc_hpdi_find_board(struct pci_dev *pcidev)
-{
-       unsigned int i;
-
-       for (i = 0; i < ARRAY_SIZE(hpdi_boards); i++)
-               if (pcidev->device == hpdi_boards[i].device_id &&
-                   pcidev->subsystem_device == hpdi_boards[i].subdevice_id)
-                       return &hpdi_boards[i];
-       return NULL;
-}
-
 static int gsc_hpdi_auto_attach(struct comedi_device *dev,
                                unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
-       const struct hpdi_board *thisboard;
        struct hpdi_private *devpriv;
        struct comedi_subdevice *s;
        int i;
        int retval;
 
-       thisboard = gsc_hpdi_find_board(pcidev);
-       if (!thisboard) {
-               dev_err(dev->class_dev, "gsc_hpdi: pci %s not supported\n",
-                       pci_name(pcidev));
-               return -EINVAL;
-       }
-       dev->board_ptr = thisboard;
-       dev->board_name = thisboard->name;
+       dev->board_name = "pci-hpdi32";
 
        devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
        if (!devpriv)
This page took 0.028179 seconds and 5 git commands to generate.