dccp: missing destroy of percpu counter variable while unload module
[safe/jmp/linux-2.6] / sound / isa / sscape.c
index 6a7f842..6618712 100644 (file)
@@ -89,9 +89,6 @@ MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids);
 #endif
 
 
-#define MPU401_IO(i)     ((i) + 0)
-#define MIDI_DATA_IO(i)  ((i) + 0)
-#define MIDI_CTRL_IO(i)  ((i) + 1)
 #define HOST_CTRL_IO(i)  ((i) + 2)
 #define HOST_DATA_IO(i)  ((i) + 3)
 #define ODIE_ADDR_IO(i)  ((i) + 4)
@@ -138,8 +135,6 @@ enum card_type {
 struct soundscape {
        spinlock_t lock;
        unsigned io_base;
-       unsigned wss_base;
-       int codec_type;
        int ic_type;
        enum card_type type;
        struct resource *io_res;
@@ -327,7 +322,7 @@ static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data,
  */
 static inline int verify_mpu401(const struct snd_mpu401 * mpu)
 {
-       return ((inb(MIDI_CTRL_IO(mpu->port)) & 0xc0) == 0x80);
+       return ((inb(MPU401C(mpu)) & 0xc0) == 0x80);
 }
 
 /*
@@ -335,7 +330,7 @@ static inline int verify_mpu401(const struct snd_mpu401 * mpu)
  */
 static inline void initialise_mpu401(const struct snd_mpu401 * mpu)
 {
-       outb(0, MIDI_DATA_IO(mpu->port));
+       outb(0, MPU401D(mpu));
 }
 
 /*
@@ -729,13 +724,7 @@ static int sscape_midi_get(struct snd_kcontrol *kctl,
        unsigned long flags;
 
        spin_lock_irqsave(&s->lock, flags);
-       set_host_mode_unsafe(s->io_base);
-
-       if (host_write_ctrl_unsafe(s->io_base, CMD_GET_MIDI_VOL, 100)) {
-               uctl->value.integer.value[0] = host_read_ctrl_unsafe(s->io_base, 100);
-       }
-
-       set_midi_mode_unsafe(s->io_base);
+       uctl->value.integer.value[0] = s->midi_vol;
        spin_unlock_irqrestore(&s->lock, flags);
        return 0;
 }
@@ -770,6 +759,7 @@ static int sscape_midi_put(struct snd_kcontrol *kctl,
        change = (host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100)
                  && host_write_ctrl_unsafe(s->io_base, ((unsigned char) uctl->value.integer. value[0]) & 127, 100)
                  && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100));
+       s->midi_vol = (unsigned char) uctl->value.integer.value[0] & 127;
       __skip_change:
 
        /*
@@ -812,12 +802,11 @@ static unsigned __devinit get_irq_config(int irq)
  * Perform certain arcane port-checks to see whether there
  * is a SoundScape board lurking behind the given ports.
  */
-static int __devinit detect_sscape(struct soundscape *s)
+static int __devinit detect_sscape(struct soundscape *s, long wss_io)
 {
        unsigned long flags;
        unsigned d;
        int retval = 0;
-       int codec = s->wss_base;
 
        spin_lock_irqsave(&s->lock, flags);
 
@@ -833,13 +822,11 @@ static int __devinit detect_sscape(struct soundscape *s)
        if ((d & 0x80) != 0)
                goto _done;
 
-       if (d == 0) {
-               s->codec_type = 1;
+       if (d == 0)
                s->ic_type = IC_ODIE;
-       } else if ((d & 0x60) != 0) {
-               s->codec_type = 2;
+       else if ((d & 0x60) != 0)
                s->ic_type = IC_OPUS;
-       else
+       else
                goto _done;
 
        outb(0xfa, ODIE_ADDR_IO(s->io_base));
@@ -859,10 +846,10 @@ static int __devinit detect_sscape(struct soundscape *s)
        sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0);
 
        if (s->type == SSCAPE_VIVO)
-               codec += 4;
+               wss_io += 4;
        /* wait for WSS codec */
        for (d = 0; d < 500; d++) {
-               if ((inb(codec) & 0x80) == 0)
+               if ((inb(wss_io) & 0x80) == 0)
                        break;
                spin_unlock_irqrestore(&s->lock, flags);
                msleep(1);
@@ -1060,7 +1047,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
        unsigned dma_cfg;
        unsigned irq_cfg;
        unsigned mpu_irq_cfg;
-       unsigned xport;
        struct resource *io_res;
        struct resource *wss_res;
        unsigned long flags;
@@ -1080,15 +1066,15 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
                printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]);
                return -ENXIO;
        }
-       xport = port[dev];
 
        /*
         * Grab IO ports that we will need to probe so that we
         * can detect and control this hardware ...
         */
-       io_res = request_region(xport, 8, "SoundScape");
+       io_res = request_region(port[dev], 8, "SoundScape");
        if (!io_res) {
-               snd_printk(KERN_ERR "sscape: can't grab port 0x%x\n", xport);
+               snd_printk(KERN_ERR
+                          "sscape: can't grab port 0x%lx\n", port[dev]);
                return -EBUSY;
        }
        wss_res = NULL;
@@ -1115,10 +1101,9 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
        spin_lock_init(&sscape->fwlock);
        sscape->io_res = io_res;
        sscape->wss_res = wss_res;
-       sscape->io_base = xport;
-       sscape->wss_base = wss_port[dev];
+       sscape->io_base = port[dev];
 
-       if (!detect_sscape(sscape)) {
+       if (!detect_sscape(sscape, wss_port[dev])) {
                printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base);
                err = -ENODEV;
                goto _release_dma;
@@ -1191,12 +1176,11 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
        }
 #define MIDI_DEVNUM  0
        if (sscape->type != SSCAPE_VIVO) {
-               err = create_mpu401(card, MIDI_DEVNUM,
-                                   MPU401_IO(xport), mpu_irq[dev]);
+               err = create_mpu401(card, MIDI_DEVNUM, port[dev], mpu_irq[dev]);
                if (err < 0) {
                        printk(KERN_ERR "sscape: Failed to create "
-                                       "MPU-401 device at 0x%x\n",
-                                       MPU401_IO(xport));
+                                       "MPU-401 device at 0x%lx\n",
+                                       port[dev]);
                        goto _release_dma;
                }
 
@@ -1260,10 +1244,10 @@ static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev)
        struct soundscape *sscape;
        int ret;
 
-       card = snd_card_new(index[dev], id[dev], THIS_MODULE,
-                           sizeof(struct soundscape));
-       if (!card)
-               return -ENOMEM;
+       ret = snd_card_create(index[dev], id[dev], THIS_MODULE,
+                             sizeof(struct soundscape), &card);
+       if (ret < 0)
+               return ret;
 
        sscape = get_card_soundscape(card);
        sscape->type = SSCAPE;
@@ -1365,10 +1349,10 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard,
         * Create a new ALSA sound card entry, in anticipation
         * of detecting our hardware ...
         */
-       card = snd_card_new(index[idx], id[idx], THIS_MODULE,
-                           sizeof(struct soundscape));
-       if (!card)
-               return -ENOMEM;
+       ret = snd_card_create(index[idx], id[idx], THIS_MODULE,
+                             sizeof(struct soundscape), &card);
+       if (ret < 0)
+               return ret;
 
        sscape = get_card_soundscape(card);