vserver 1.9.3
[linux-2.6.git] / sound / oss / gus_wave.c
index 35ade6b..2cc924d 100644 (file)
@@ -978,6 +978,13 @@ int __init gus_wave_detect(int baseaddr)
        unsigned long   loc;
        unsigned char   val;
 
+       if (!request_region(baseaddr, 16, "GUS"))
+               return 0;
+       if (!request_region(baseaddr + 0x100, 12, "GUS")) { /* 0x10c-> is MAX */
+               release_region(baseaddr, 16);
+               return 0;
+       }
+
        gus_base = baseaddr;
 
        gus_write8(0x4c, 0);    /* Reset GF1 */
@@ -1015,8 +1022,11 @@ int __init gus_wave_detect(int baseaddr)
 
        /* See if there is first block there.... */
        gus_poke(0L, 0xaa);
-       if (gus_peek(0L) != 0xaa)
-               return (0);
+       if (gus_peek(0L) != 0xaa) {
+               release_region(baseaddr + 0x100, 12);
+               release_region(baseaddr, 16);
+               return 0;
+       }
 
        /* Now zero it out so that I can check for mirroring .. */
        gus_poke(0L, 0x00);
@@ -2932,6 +2942,8 @@ void __init gus_wave_init(struct address_info *hw_config)
                }
                else
                {
+                       struct resource *ports;
+                       ports = request_region(gus_base + 0x10c, 4, "ad1848");
                        model_num = "MAX";
                        gus_type = 0x40;
                        mixer_type = CS4231;
@@ -2953,7 +2965,10 @@ void __init gus_wave_init(struct address_info *hw_config)
                                outb((max_config), gus_base + 0x106);   /* UltraMax control */
                        }
 
-                       if (ad1848_detect(gus_base + 0x10c, &ad_flags, hw_config->osp))
+                       if (!ports)
+                               goto no_cs4231;
+
+                       if (ad1848_detect(ports, &ad_flags, hw_config->osp))
                        {
                                char           *name = "GUS MAX";
                                int             old_num_mixers = num_mixers;
@@ -2967,7 +2982,7 @@ void __init gus_wave_init(struct address_info *hw_config)
                                if (hw_config->name)
                                        name = hw_config->name;
 
-                               hw_config->slots[1] = ad1848_init(name, gus_base + 0x10c,
+                               hw_config->slots[1] = ad1848_init(name, ports,
                                                        -irq, gus_dma2, /* Playback DMA */
                                                        gus_dma,        /* Capture DMA */
                                                        1,              /* Share DMA channels with GF1 */
@@ -2982,8 +2997,11 @@ void __init gus_wave_init(struct address_info *hw_config)
                                        AD1848_REROUTE(SOUND_MIXER_LINE3, SOUND_MIXER_LINE);
                                }
                        }
-                       else
+                       else {
+                               release_region(gus_base + 0x10c, 4);
+                       no_cs4231:
                                printk(KERN_WARNING "GUS: No CS4231 ??");
+                       }
 #else
                        printk(KERN_ERR "GUS MAX found, but not compiled in\n");
 #endif