ALSA: HDA: hda_local: Less magic numbers.
[safe/jmp/linux-2.6] / sound / pci / bt87x.c
index 42e57fd..3aa8d97 100644 (file)
@@ -21,7 +21,6 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-#include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
@@ -149,6 +148,7 @@ MODULE_PARM_DESC(load_all, "Allow to load the non-whitelisted cards");
 
 /* Cards with configuration information */
 enum snd_bt87x_boardid {
+       SND_BT87X_BOARD_UNKNOWN,
        SND_BT87X_BOARD_GENERIC,        /* both an & dig interfaces, 32kHz */
        SND_BT87X_BOARD_ANALOG,         /* board with no external A/D */
        SND_BT87X_BOARD_OSPREY2x0,
@@ -164,7 +164,10 @@ struct snd_bt87x_board {
        unsigned no_digital:1;  /* No digital input */
 };
 
-static const __devinitdata struct snd_bt87x_board snd_bt87x_boards[] = {
+static __devinitdata struct snd_bt87x_board snd_bt87x_boards[] = {
+       [SND_BT87X_BOARD_UNKNOWN] = {
+               .dig_rate = 32000, /* just a guess */
+       },
        [SND_BT87X_BOARD_GENERIC] = {
                .dig_rate = 32000,
        },
@@ -224,7 +227,6 @@ static inline void snd_bt87x_writel(struct snd_bt87x *chip, u32 reg, u32 value)
 static int snd_bt87x_create_risc(struct snd_bt87x *chip, struct snd_pcm_substream *substream,
                                 unsigned int periods, unsigned int period_bytes)
 {
-       struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream);
        unsigned int i, offset;
        u32 *risc;
 
@@ -243,6 +245,7 @@ static int snd_bt87x_create_risc(struct snd_bt87x *chip, struct snd_pcm_substrea
                rest = period_bytes;
                do {
                        u32 cmd, len;
+                       unsigned int addr;
 
                        len = PAGE_SIZE - (offset % PAGE_SIZE);
                        if (len > rest)
@@ -257,7 +260,8 @@ static int snd_bt87x_create_risc(struct snd_bt87x *chip, struct snd_pcm_substrea
                        if (len == rest)
                                cmd |= RISC_EOL | RISC_IRQ;
                        *risc++ = cpu_to_le32(cmd);
-                       *risc++ = cpu_to_le32((u32)snd_pcm_sgbuf_get_addr(sgbuf, offset));
+                       addr = snd_pcm_sgbuf_get_addr(substream, offset);
+                       *risc++ = cpu_to_le32(addr);
                        offset += len;
                        rest -= len;
                } while (rest > 0);
@@ -678,15 +682,12 @@ static struct snd_kcontrol_new snd_bt87x_capture_source = {
 
 static int snd_bt87x_free(struct snd_bt87x *chip)
 {
-       if (chip->mmio) {
+       if (chip->mmio)
                snd_bt87x_stop(chip);
-               if (chip->irq >= 0)
-                       synchronize_irq(chip->irq);
-
-               iounmap(chip->mmio);
-       }
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
+       if (chip->mmio)
+               iounmap(chip->mmio);
        pci_release_regions(chip->pci);
        pci_disable_device(chip->pci);
        kfree(chip);
@@ -844,7 +845,7 @@ static int __devinit snd_bt87x_detect_card(struct pci_dev *pci)
        int i;
        const struct pci_device_id *supported;
 
-       supported = pci_match_device(&driver, pci);
+       supported = pci_match_id(snd_bt87x_ids, pci);
        if (supported && supported->driver_data > 0)
                return supported->driver_data;
 
@@ -861,7 +862,7 @@ static int __devinit snd_bt87x_detect_card(struct pci_dev *pci)
        snd_printk(KERN_DEBUG "please mail id, board name, and, "
                   "if it works, the correct digital_rate option to "
                   "<alsa-devel@alsa-project.org>\n");
-       return SND_BT87X_BOARD_GENERIC;
+       return SND_BT87X_BOARD_UNKNOWN;
 }
 
 static int __devinit snd_bt87x_probe(struct pci_dev *pci,
@@ -959,8 +960,8 @@ static void __devexit snd_bt87x_remove(struct pci_dev *pci)
 /* default entries for all Bt87x cards - it's not exported */
 /* driver_data is set to 0 to call detection */
 static struct pci_device_id snd_bt87x_default_ids[] __devinitdata = {
-       BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, PCI_ANY_ID, PCI_ANY_ID, GENERIC),
-       BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, PCI_ANY_ID, PCI_ANY_ID, GENERIC),
+       BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, PCI_ANY_ID, PCI_ANY_ID, UNKNOWN),
+       BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, PCI_ANY_ID, PCI_ANY_ID, UNKNOWN),
        { }
 };