From: Ian Abbott Date: Tue, 5 May 2015 17:47:25 +0000 (+0100) Subject: staging: comedi: gsc_hpdi: remove multiple board type support X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e899a4165cffe3aa802f813c624e90ce7ca23189;p=linux-beck.git 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 Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 901025216971..0e04f15feb38 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -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)