staging: comedi: adv_pci_dio: remove CheckAndAllocCard()
PATCH 22/90 staging: comedi: adv_pci_dio: remove CheckAndAllocCard()
This driver creates a linked list of all the pci devices in the system while it's looking for a match. It's only use is to determine if a device is "free" to use. The pci_is_enabled() helper can give us the same information. Use that instead and remove the linked list.
--- drivers/staging/comedi/drivers/adv_pci_dio.c | 39 +--------------------------- 1 file changed, 1 insertion(+), 38 deletions(-)
drivers/staging/comedi/drivers/adv_pci_dio.c +1 -38
@@ -382,8 +382,6 @@ static const struct dio_boardtype boardtypes[] = { };struct pci_dio_private { -struct pci_dio_private *prev;/* previous private struct */ -struct pci_dio_private *next;/* next private struct */ struct pci_dev *pcidev;/* pointer to board's pci_dev */ char valid;/* card is usable */ char GlobalIrqEnabled;/* 1= any IRQ source is enabled */
@@ -404,8 +402,6 @@ struct pci_dio_private {unsigned short IDIFiltrHigh[8 ];/* IDI's filter value high signal */ }; -static struct pci_dio_private *pci_priv;/* list of allocated cards */ -#define devpriv ((struct pci_dio_private *)dev->private)#define this_board ((const struct dio_boardtype *)dev->board_ptr)
@@ -1055,38 +1051,12 @@ static int pci_dio_add_8254(struct comedi_device *dev,return 0 ; } -/* -============================================================================== -*/ -static int CheckAndAllocCard (struct comedi_device *dev, -struct comedi_devconfig *it, -struct pci_dev *pcidev) -{ -struct pci_dio_private *pr, *prev; - -for (pr = pci_priv, prev =NULL ; pr !=NULL ; prev = pr, pr = pr->next) { -if (pr->pcidev == pcidev) -return 0 ;/* this card is used, look for another */ - - } - -if (prev) { - devpriv->prev = prev; - prev->next = devpriv; - }else { - pci_priv = devpriv; - } - -return 1 ; -} -static struct pci_dev *pci_dio_find_pci_dev (struct comedi_device *dev,struct comedi_devconfig *it) {struct pci_dev *pcidev =NULL ;unsigned long iobase;int i; -int ret;for_each_pci_dev (pcidev) {/* loop through cards supported by this driver */
@@ -1103,8 +1073,7 @@ static struct pci_dev *pci_dio_find_pci_dev(struct comedi_device *dev,continue ; } } - ret =CheckAndAllocCard (dev, it, pcidev); -if (ret !=1 ) +if (pci_is_enabled (pcidev))continue ; dev->board_ptr = boardtypes + i;break ;
@@ -1260,12 +1229,6 @@ static void pci_dio_detach(struct comedi_device *dev)comedi_pci_disable (devpriv->pcidev);pci_dev_put (devpriv->pcidev); } -if (devpriv->prev) - devpriv->prev->next = devpriv->next; -else - pci_priv = devpriv->next; -if (devpriv->next) - devpriv->next->prev = devpriv->prev; } }
Signature · 1 line
1.7.11
Quoted 5 lines · H Hartley Sweeten
This driver creates a linked list of all the pci devices in the system while it's looking for a match. It's only use is to determine if a device is "free" to use. The
pci_is_enabled()helper can give us the same information. Use that instead and remove the linked list.
As mentioned in my replies to your patches to adv_pci1723 and adv_pci1710, pci_is_enabled() might not be sufficient. I think it's better just to take out the free/in-use test.
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-