Commit 386900781205d203c1141d3e2dae759f1b531193

Authored by Akinobu Mita
Committed by Mauro Carvalho Chehab
1 parent 4a2b108379

V4L/DVB (7077): bt878: remove handcrafted PCI subsystem ID check

This patch moves the subsystem ID and subsystem vendor ID check from probing
function to the PCI generic function by describing subsystem IDs in
pci_device_id table. This enables to add new PCI IDs to a device driver pci_ids
table at runtime by new_id file in sysfs pci driver tree.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

Showing 3 changed files with 45 additions and 49 deletions Side-by-side Diff

Documentation/dvb/bt8xx.txt
... ... @@ -78,6 +78,18 @@
78 78 For a full list of card ID's please see Documentation/video4linux/CARDLIST.bttv.
79 79 In case of further problems please subscribe and send questions to the mailing list: linux-dvb@linuxtv.org.
80 80  
  81 +2c) Probing the cards with broken PCI subsystem ID
  82 +--------------------------------------------------
  83 +There are some TwinHan cards that the EEPROM has become corrupted for some
  84 +reason. The cards do not have correct PCI subsystem ID. But we can force
  85 +probing the cards with broken PCI subsystem ID
  86 +
  87 + $ echo 109e 0878 $subvendor $subdevice > \
  88 + /sys/bus/pci/drivers/bt878/new_id
  89 +
  90 +109e: PCI_VENDOR_ID_BROOKTREE
  91 +0878: PCI_DEVICE_ID_BROOKTREE_878
  92 +
81 93 Authors: Richard Walker,
82 94 Jamie Honan,
83 95 Michael Hunold,
drivers/media/dvb/bt8xx/bt878.c
... ... @@ -378,24 +378,38 @@
378 378  
379 379 EXPORT_SYMBOL(bt878_device_control);
380 380  
  381 +#define BROOKTREE_878_DEVICE(vend, dev, name) \
  382 + { \
  383 + .vendor = PCI_VENDOR_ID_BROOKTREE, \
  384 + .device = PCI_DEVICE_ID_BROOKTREE_878, \
  385 + .subvendor = (vend), .subdevice = (dev), \
  386 + .driver_data = (unsigned long) name \
  387 + }
381 388  
382   -static struct cards card_list[] __devinitdata = {
383   -
384   - { 0x01010071, BTTV_BOARD_NEBULA_DIGITV, "Nebula Electronics DigiTV" },
385   - { 0x07611461, BTTV_BOARD_AVDVBT_761, "AverMedia AverTV DVB-T 761" },
386   - { 0x001c11bd, BTTV_BOARD_PINNACLESAT, "Pinnacle PCTV Sat" },
387   - { 0x002611bd, BTTV_BOARD_TWINHAN_DST, "Pinnacle PCTV SAT CI" },
388   - { 0x00011822, BTTV_BOARD_TWINHAN_DST, "Twinhan VisionPlus DVB" },
389   - { 0xfc00270f, BTTV_BOARD_TWINHAN_DST, "ChainTech digitop DST-1000 DVB-S" },
390   - { 0x07711461, BTTV_BOARD_AVDVBT_771, "AVermedia AverTV DVB-T 771" },
391   - { 0xdb1018ac, BTTV_BOARD_DVICO_DVBT_LITE, "DViCO FusionHDTV DVB-T Lite" },
392   - { 0xdb1118ac, BTTV_BOARD_DVICO_DVBT_LITE, "Ultraview DVB-T Lite" },
393   - { 0xd50018ac, BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE, "DViCO FusionHDTV 5 Lite" },
394   - { 0x20007063, BTTV_BOARD_PC_HDTV, "pcHDTV HD-2000 TV" },
395   - { 0x00261822, BTTV_BOARD_TWINHAN_DST, "DNTV Live! Mini" }
  389 +static struct pci_device_id bt878_pci_tbl[] __devinitdata = {
  390 + BROOKTREE_878_DEVICE(0x0071, 0x0101, "Nebula Electronics DigiTV"),
  391 + BROOKTREE_878_DEVICE(0x1461, 0x0761, "AverMedia AverTV DVB-T 761"),
  392 + BROOKTREE_878_DEVICE(0x11bd, 0x001c, "Pinnacle PCTV Sat"),
  393 + BROOKTREE_878_DEVICE(0x11bd, 0x0026, "Pinnacle PCTV SAT CI"),
  394 + BROOKTREE_878_DEVICE(0x1822, 0x0001, "Twinhan VisionPlus DVB"),
  395 + BROOKTREE_878_DEVICE(0x270f, 0xfc00,
  396 + "ChainTech digitop DST-1000 DVB-S"),
  397 + BROOKTREE_878_DEVICE(0x1461, 0x0771, "AVermedia AverTV DVB-T 771"),
  398 + BROOKTREE_878_DEVICE(0x18ac, 0xdb10, "DViCO FusionHDTV DVB-T Lite"),
  399 + BROOKTREE_878_DEVICE(0x18ac, 0xdb11, "Ultraview DVB-T Lite"),
  400 + BROOKTREE_878_DEVICE(0x18ac, 0xd500, "DViCO FusionHDTV 5 Lite"),
  401 + BROOKTREE_878_DEVICE(0x7063, 0x2000, "pcHDTV HD-2000 TV"),
  402 + BROOKTREE_878_DEVICE(0x1822, 0x0026, "DNTV Live! Mini"),
  403 + { }
396 404 };
397 405  
  406 +MODULE_DEVICE_TABLE(pci, bt878_pci_tbl);
398 407  
  408 +static const char * __devinit card_name(const struct pci_device_id *id)
  409 +{
  410 + return id->driver_data ? (const char *)id->driver_data : "Unknown";
  411 +}
  412 +
399 413 /***********************/
400 414 /* PCI device handling */
401 415 /***********************/
402 416  
... ... @@ -403,15 +417,13 @@
403 417 static int __devinit bt878_probe(struct pci_dev *dev,
404 418 const struct pci_device_id *pci_id)
405 419 {
406   - int result = 0, has_dvb = 0, i;
  420 + int result = 0;
407 421 unsigned char lat;
408 422 struct bt878 *bt;
409 423 #if defined(__powerpc__)
410 424 unsigned int cmd;
411 425 #endif
412 426 unsigned int cardid;
413   - unsigned short id;
414   - struct cards *dvb_cards;
415 427  
416 428 printk(KERN_INFO "bt878: Bt878 AUDIO function found (%d).\n",
417 429 bt878_num);
418 430  
419 431  
... ... @@ -423,26 +435,12 @@
423 435 if (pci_enable_device(dev))
424 436 return -EIO;
425 437  
426   - pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &id);
427   - cardid = id << 16;
428   - pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &id);
429   - cardid |= id;
  438 + cardid = dev->subsystem_device << 16;
  439 + cardid |= dev->subsystem_vendor;
430 440  
431   - for (i = 0, dvb_cards = card_list; i < ARRAY_SIZE(card_list); i++, dvb_cards++) {
432   - if (cardid == dvb_cards->pci_id) {
433   - printk("%s: card id=[0x%x],[ %s ] has DVB functions.\n",
434   - __func__, cardid, dvb_cards->name);
435   - has_dvb = 1;
436   - }
437   - }
  441 + printk(KERN_INFO "%s: card id=[0x%x],[ %s ] has DVB functions.\n",
  442 + __func__, cardid, card_name(pci_id));
438 443  
439   - if (!has_dvb) {
440   - printk("%s: card id=[0x%x], Unknown card.\nExiting..\n", __func__, cardid);
441   - result = -EINVAL;
442   -
443   - goto fail0;
444   - }
445   -
446 444 bt = &bt878[bt878_num];
447 445 bt->dev = dev;
448 446 bt->nr = bt878_num;
... ... @@ -571,14 +569,6 @@
571 569 pci_disable_device(pci_dev);
572 570 return;
573 571 }
574   -
575   -static struct pci_device_id bt878_pci_tbl[] __devinitdata = {
576   - {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BROOKTREE_878,
577   - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
578   - {0,}
579   -};
580   -
581   -MODULE_DEVICE_TABLE(pci, bt878_pci_tbl);
582 572  
583 573 static struct pci_driver bt878_pci_driver = {
584 574 .name = "bt878",
drivers/media/dvb/bt8xx/bt878.h
... ... @@ -101,12 +101,6 @@
101 101 #define BTTV_BOARD_DVICO_DVBT_LITE 0x80
102 102 #define BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE 0x87
103 103  
104   -struct cards {
105   - __u32 pci_id;
106   - __u16 card_id;
107   - char *name;
108   -};
109   -
110 104 extern int bt878_num;
111 105  
112 106 struct bt878 {