V4L/DVB (11992): Add missing __devexit_p()
[linux-2.6.git] / drivers / media / dvb / bt8xx / bt878.c
index 47281c9..a24c125 100644 (file)
@@ -28,7 +28,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <asm/io.h>
@@ -63,8 +62,6 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging, default is 0 (off).");
 int bt878_num;
 struct bt878 bt878[BT878_MAX];
 
-EXPORT_SYMBOL(bt878_debug);
-EXPORT_SYMBOL(bt878_verbose);
 EXPORT_SYMBOL(bt878_num);
 EXPORT_SYMBOL(bt878);
 
@@ -78,7 +75,11 @@ EXPORT_SYMBOL(bt878);
 #if defined(dprintk)
 #undef dprintk
 #endif
-#define dprintk if(bt878_debug) printk
+#define dprintk(fmt, arg...) \
+       do { \
+               if (bt878_debug) \
+                       printk(KERN_DEBUG fmt, ##arg); \
+       } while (0)
 
 static void bt878_mem_free(struct bt878 *bt)
 {
@@ -157,7 +158,7 @@ static int bt878_make_risc(struct bt878 *bt)
        }
 
        if (bt->line_count > 255) {
-               printk("bt878: buffer size error!\n");
+               printk(KERN_ERR "bt878: buffer size error!\n");
                return -EINVAL;
        }
        return 0;
@@ -268,7 +269,7 @@ EXPORT_SYMBOL(bt878_stop);
 /* Interrupt service routine */
 /*****************************/
 
-static irqreturn_t bt878_irq(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t bt878_irq(int irq, void *dev_id)
 {
        u32 stat, astat, mask;
        int count;
@@ -283,12 +284,13 @@ static irqreturn_t bt878_irq(int irq, void *dev_id, struct pt_regs *regs)
                if (!(astat = (stat & mask)))
                        return IRQ_NONE;        /* this interrupt is not for me */
 /*             dprintk("bt878(%d) debug: irq count %d, stat 0x%8.8x, mask 0x%8.8x\n",bt->nr,count,stat,mask); */
-               btwrite(astat, BT878_AINT_STAT);        /* try to clear interupt condition */
+               btwrite(astat, BT878_AINT_STAT);        /* try to clear interrupt condition */
 
 
                if (astat & (BT878_ASCERR | BT878_AOCERR)) {
                        if (bt878_verbose) {
-                               printk("bt878(%d): irq%s%s risc_pc=%08x\n",
+                               printk(KERN_INFO
+                                      "bt878(%d): irq%s%s risc_pc=%08x\n",
                                       bt->nr,
                                       (astat & BT878_ASCERR) ? " SCERR" :
                                       "",
@@ -298,8 +300,8 @@ static irqreturn_t bt878_irq(int irq, void *dev_id, struct pt_regs *regs)
                }
                if (astat & (BT878_APABORT | BT878_ARIPERR | BT878_APPERR)) {
                        if (bt878_verbose) {
-                               printk
-                                   ("bt878(%d): irq%s%s%s risc_pc=%08x\n",
+                               printk(KERN_INFO
+                                    "bt878(%d): irq%s%s%s risc_pc=%08x\n",
                                     bt->nr,
                                     (astat & BT878_APABORT) ? " PABORT" :
                                     "",
@@ -311,8 +313,8 @@ static irqreturn_t bt878_irq(int irq, void *dev_id, struct pt_regs *regs)
                }
                if (astat & (BT878_AFDSR | BT878_AFTRGT | BT878_AFBUS)) {
                        if (bt878_verbose) {
-                               printk
-                                   ("bt878(%d): irq%s%s%s risc_pc=%08x\n",
+                               printk(KERN_INFO
+                                    "bt878(%d): irq%s%s%s risc_pc=%08x\n",
                                     bt->nr,
                                     (astat & BT878_AFDSR) ? " FDSR" : "",
                                     (astat & BT878_AFTRGT) ? " FTRGT" :
@@ -381,22 +383,37 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *
 
 EXPORT_SYMBOL(bt878_device_control);
 
+#define BROOKTREE_878_DEVICE(vend, dev, name) \
+       { \
+               .vendor = PCI_VENDOR_ID_BROOKTREE, \
+               .device = PCI_DEVICE_ID_BROOKTREE_878, \
+               .subvendor = (vend), .subdevice = (dev), \
+               .driver_data = (unsigned long) name \
+       }
 
-static struct cards card_list[] __devinitdata = {
-
-       { 0x01010071, BTTV_BOARD_NEBULA_DIGITV,                 "Nebula Electronics DigiTV" },
-       { 0x07611461, BTTV_BOARD_AVDVBT_761,                    "AverMedia AverTV DVB-T 761" },
-       { 0x001c11bd, BTTV_BOARD_PINNACLESAT,                   "Pinnacle PCTV Sat" },
-       { 0x002611bd, BTTV_BOARD_TWINHAN_DST,                   "Pinnacle PCTV SAT CI" },
-       { 0x00011822, BTTV_BOARD_TWINHAN_DST,                   "Twinhan VisionPlus DVB" },
-       { 0xfc00270f, BTTV_BOARD_TWINHAN_DST,                   "ChainTech digitop DST-1000 DVB-S" },
-       { 0x07711461, BTTV_BOARD_AVDVBT_771,                    "AVermedia AverTV DVB-T 771" },
-       { 0xdb1018ac, BTTV_BOARD_DVICO_DVBT_LITE,               "DViCO FusionHDTV DVB-T Lite" },
-       { 0xd50018ac, BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE,       "DViCO FusionHDTV 5 Lite" },
-       { 0x20007063, BTTV_BOARD_PC_HDTV,                       "pcHDTV HD-2000 TV"},
-       { 0, -1, NULL }
+static struct pci_device_id bt878_pci_tbl[] __devinitdata = {
+       BROOKTREE_878_DEVICE(0x0071, 0x0101, "Nebula Electronics DigiTV"),
+       BROOKTREE_878_DEVICE(0x1461, 0x0761, "AverMedia AverTV DVB-T 761"),
+       BROOKTREE_878_DEVICE(0x11bd, 0x001c, "Pinnacle PCTV Sat"),
+       BROOKTREE_878_DEVICE(0x11bd, 0x0026, "Pinnacle PCTV SAT CI"),
+       BROOKTREE_878_DEVICE(0x1822, 0x0001, "Twinhan VisionPlus DVB"),
+       BROOKTREE_878_DEVICE(0x270f, 0xfc00,
+                               "ChainTech digitop DST-1000 DVB-S"),
+       BROOKTREE_878_DEVICE(0x1461, 0x0771, "AVermedia AverTV DVB-T 771"),
+       BROOKTREE_878_DEVICE(0x18ac, 0xdb10, "DViCO FusionHDTV DVB-T Lite"),
+       BROOKTREE_878_DEVICE(0x18ac, 0xdb11, "Ultraview DVB-T Lite"),
+       BROOKTREE_878_DEVICE(0x18ac, 0xd500, "DViCO FusionHDTV 5 Lite"),
+       BROOKTREE_878_DEVICE(0x7063, 0x2000, "pcHDTV HD-2000 TV"),
+       BROOKTREE_878_DEVICE(0x1822, 0x0026, "DNTV Live! Mini"),
+       { }
 };
 
+MODULE_DEVICE_TABLE(pci, bt878_pci_tbl);
+
+static const char * __devinit card_name(const struct pci_device_id *id)
+{
+       return id->driver_data ? (const char *)id->driver_data : "Unknown";
+}
 
 /***********************/
 /* PCI device handling */
@@ -405,15 +422,13 @@ static struct cards card_list[] __devinitdata = {
 static int __devinit bt878_probe(struct pci_dev *dev,
                                 const struct pci_device_id *pci_id)
 {
-       int result = 0, has_dvb = 0, i;
+       int result = 0;
        unsigned char lat;
        struct bt878 *bt;
 #if defined(__powerpc__)
        unsigned int cmd;
 #endif
        unsigned int cardid;
-       unsigned short id;
-       struct cards *dvb_cards;
 
        printk(KERN_INFO "bt878: Bt878 AUDIO function found (%d).\n",
               bt878_num);
@@ -425,25 +440,11 @@ static int __devinit bt878_probe(struct pci_dev *dev,
        if (pci_enable_device(dev))
                return -EIO;
 
-       pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &id);
-       cardid = id << 16;
-       pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &id);
-       cardid |= id;
-
-       for (i = 0, dvb_cards = card_list; i < ARRAY_SIZE(card_list); i++, dvb_cards++) {
-               if (cardid == dvb_cards->pci_id) {
-                       printk("%s: card id=[0x%x],[ %s ] has DVB functions.\n",
-                               __func__, cardid, dvb_cards->name);
-                       has_dvb = 1;
-               }
-       }
-
-       if (!has_dvb) {
-               printk("%s: card id=[0x%x], Unknown card.\nExiting..\n", __func__, cardid);
-               result = -EINVAL;
+       cardid = dev->subsystem_device << 16;
+       cardid |= dev->subsystem_vendor;
 
-               goto fail0;
-       }
+       printk(KERN_INFO "%s: card id=[0x%x],[ %s ] has DVB functions.\n",
+                               __func__, cardid, card_name(pci_id));
 
        bt = &bt878[bt878_num];
        bt->dev = dev;
@@ -488,7 +489,7 @@ static int __devinit bt878_probe(struct pci_dev *dev,
        btwrite(0, BT848_INT_MASK);
 
        result = request_irq(bt->irq, bt878_irq,
-                            SA_SHIRQ | SA_INTERRUPT, "bt878",
+                            IRQF_SHARED | IRQF_DISABLED, "bt878",
                             (void *) bt);
        if (result == -EINVAL) {
                printk(KERN_ERR "bt878(%d): Bad irq number or handler\n",
@@ -507,14 +508,8 @@ static int __devinit bt878_probe(struct pci_dev *dev,
        pci_set_master(dev);
        pci_set_drvdata(dev, bt);
 
-/*        if(init_bt878(btv) < 0) {
-               bt878_remove(dev);
-               return -EIO;
-       }
-*/
-
        if ((result = bt878_mem_alloc(bt))) {
-               printk("bt878: failed to allocate memory!\n");
+               printk(KERN_ERR "bt878: failed to allocate memory!\n");
                goto fail2;
        }
 
@@ -540,7 +535,7 @@ static void __devexit bt878_remove(struct pci_dev *pci_dev)
        struct bt878 *bt = pci_get_drvdata(pci_dev);
 
        if (bt878_verbose)
-               printk("bt878(%d): unloading\n", bt->nr);
+               printk(KERN_INFO "bt878(%d): unloading\n", bt->nr);
 
        /* turn off all capturing, DMA and IRQs */
        btand(~0x13, BT878_AGPIO_DMA_CTL);
@@ -574,19 +569,11 @@ static void __devexit bt878_remove(struct pci_dev *pci_dev)
        return;
 }
 
-static struct pci_device_id bt878_pci_tbl[] __devinitdata = {
-       {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BROOKTREE_878,
-        PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       {0,}
-};
-
-MODULE_DEVICE_TABLE(pci, bt878_pci_tbl);
-
 static struct pci_driver bt878_pci_driver = {
       .name    = "bt878",
       .id_table = bt878_pci_tbl,
       .probe   = bt878_probe,
-      .remove  = bt878_remove,
+      .remove  = __devexit_p(bt878_remove),
 };
 
 static int bt878_pci_driver_registered;