Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965905AbbEERtx (ORCPT ); Tue, 5 May 2015 13:49:53 -0400 Received: from smtp121.iad3a.emailsrvr.com ([173.203.187.121]:48743 "EHLO smtp121.iad3a.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761797AbbEERrn (ORCPT ); Tue, 5 May 2015 13:47:43 -0400 X-Sender-Id: abbotti@mev.co.uk From: Ian Abbott To: Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Subject: [PATCH 2/6] staging: comedi: gsc_hpdi: remove multiple board type support Date: Tue, 5 May 2015 18:47:25 +0100 Message-Id: <1430848049-29741-3-git-send-email-abbotti@mev.co.uk> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1430848049-29741-1-git-send-email-abbotti@mev.co.uk> References: <1430848049-29741-1-git-send-email-abbotti@mev.co.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3021 Lines: 90 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 --- drivers/staging/comedi/drivers/gsc_hpdi.c | 35 +------------------------------ 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 9010252..0e04f15 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) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/