diff options
author | Herton Ronaldo Krzesinski <herton@mandriva.com.br> | 2009-06-18 13:43:56 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-07-12 16:21:45 -0400 |
commit | 8231eb5672e7a020174eb7ce0436766eea57cae8 (patch) | |
tree | 1edf130c4fe74a4a2c10f8dfc7e50567612667fb | |
parent | 91fca6da389b897483b4c1edea29885172989fda (diff) |
Staging: comedi: s626: use subvendor:subdevice ids for SAA7146 board
The current s626 comedi driver in staging conflicts with philips SAA7146
media/dvb based cards, because it claims the same vendor:device pci id
for all subdevice/subvendor ids. What happens is that for people that have a
philips SAA7146 media/dvb based card, s626 if available gets loaded by udev
and makes system freeze (https://qa.mandriva.com/show_bug.cgi?id=51445).
The s626 driver shouldn't claim all 1131:7146 devices. Fix this by
specifying specific known subvendor:subdevice ids in its pci id table
list.
Also s626_attach is modified to use now pci_get_subsys instead of
pci_get_device as reported by Ian Abbott, and now we loop over pci id
table entries in case more ids are added in the future.
Reference: http://lkml.org/lkml/2009/6/16/552
Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/comedi/drivers/s626.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 92121cf8c45c..5d9bab352c1d 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c | |||
@@ -111,9 +111,13 @@ static const struct s626_board s626_boards[] = { | |||
111 | #define PCI_VENDOR_ID_S626 0x1131 | 111 | #define PCI_VENDOR_ID_S626 0x1131 |
112 | #define PCI_DEVICE_ID_S626 0x7146 | 112 | #define PCI_DEVICE_ID_S626 0x7146 |
113 | 113 | ||
114 | /* | ||
115 | * For devices with vendor:device id == 0x1131:0x7146 you must specify | ||
116 | * also subvendor:subdevice ids, because otherwise it will conflict with | ||
117 | * Philips SAA7146 media/dvb based cards. | ||
118 | */ | ||
114 | static DEFINE_PCI_DEVICE_TABLE(s626_pci_table) = { | 119 | static DEFINE_PCI_DEVICE_TABLE(s626_pci_table) = { |
115 | {PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 120 | {PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, 0x6000, 0x0272, 0, 0, 0}, |
116 | 0}, | ||
117 | {0} | 121 | {0} |
118 | }; | 122 | }; |
119 | 123 | ||
@@ -499,25 +503,26 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
499 | resource_size_t resourceStart; | 503 | resource_size_t resourceStart; |
500 | dma_addr_t appdma; | 504 | dma_addr_t appdma; |
501 | struct comedi_subdevice *s; | 505 | struct comedi_subdevice *s; |
502 | struct pci_dev *pdev; | 506 | const struct pci_device_id *ids; |
507 | struct pci_dev *pdev = NULL; | ||
503 | 508 | ||
504 | if (alloc_private(dev, sizeof(struct s626_private)) < 0) | 509 | if (alloc_private(dev, sizeof(struct s626_private)) < 0) |
505 | return -ENOMEM; | 510 | return -ENOMEM; |
506 | 511 | ||
507 | for (pdev = pci_get_device(PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, | 512 | for (i = 0; i < (ARRAY_SIZE(s626_pci_table) - 1) && !pdev; i++) { |
508 | NULL); pdev != NULL; | 513 | ids = &s626_pci_table[i]; |
509 | pdev = pci_get_device(PCI_VENDOR_ID_S626, | 514 | do { |
510 | PCI_DEVICE_ID_S626, pdev)) { | 515 | pdev = pci_get_subsys(ids->vendor, ids->device, ids->subvendor, |
511 | if (it->options[0] || it->options[1]) { | 516 | ids->subdevice, pdev); |
512 | if (pdev->bus->number == it->options[0] && | 517 | |
513 | PCI_SLOT(pdev->devfn) == it->options[1]) { | 518 | if ((it->options[0] || it->options[1]) && pdev) { |
514 | /* matches requested bus/slot */ | 519 | /* matches requested bus/slot */ |
520 | if (pdev->bus->number == it->options[0] && | ||
521 | PCI_SLOT(pdev->devfn) == it->options[1]) | ||
522 | break; | ||
523 | } else | ||
515 | break; | 524 | break; |
516 | } | 525 | } while (1); |
517 | } else { | ||
518 | /* no bus/slot specified */ | ||
519 | break; | ||
520 | } | ||
521 | } | 526 | } |
522 | devpriv->pdev = pdev; | 527 | devpriv->pdev = pdev; |
523 | 528 | ||