staging: comedi: gsc_hpdi: remove multiple board type support

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>
This commit is contained in:
Ian Abbott 2015-05-05 18:47:25 +01:00 committed by Greg Kroah-Hartman
parent dc05a7d70b
commit e899a4165c

View File

@ -123,20 +123,6 @@
#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)