Hi,

                Please consider applying.

- Arnaldo

--- linux-2.4.0-test8-pre2/drivers/sound/adlib_card.c   Thu Aug 24 07:40:05 2000
+++ linux-2.4.0-test8-pre2.acme/drivers/sound/adlib_card.c      Sun Sep  3 12:48:03 
+2000
@@ -20,15 +20,10 @@
 static void __init attach_adlib_card(struct address_info *hw_config)
 {
        hw_config->slots[0] = opl3_init(hw_config->io_base, hw_config->osp, 
THIS_MODULE);
-       request_region(hw_config->io_base, 4, "OPL3/OPL2");
 }
 
 static int __init probe_adlib(struct address_info *hw_config)
 {
-       if (check_region(hw_config->io_base, 4)) {
-               DDB(printk("opl3.c: I/O port %x already in use\n", 
hw_config->io_base));
-               return 0;
-       }
        return opl3_detect(hw_config->io_base, hw_config->osp);
 }
 
@@ -55,7 +50,6 @@
 
 static void __exit cleanup_adlib(void)
 {
-       release_region(cfg.io_base, 4);
        sound_unload_synthdev(cfg.slots[0]);
        
 }
--- linux-2.4.0-test8-pre2/drivers/sound/opl3.c Thu Aug 24 07:40:07 2000
+++ linux-2.4.0-test8-pre2.acme/drivers/sound/opl3.c    Sun Sep  3 12:42:59 2000
@@ -15,6 +15,8 @@
  *     Thomas Sailer           ioctl code reworked (vmalloc/vfree removed)
  *     Alan Cox                modularisation, fixed sound_mem allocs.
  *     Christoph Hellwig       Adapted to module_init/module_exit
+ *     Arnaldo C. de Melo      get rid of check_region, use request_region for
+ *                             OPL4, release it on exit, some cleanups.
  *
  * Status
  *     Believed to work. Badly needs rewriting a bit to support multiple
@@ -172,6 +174,15 @@
                        "structure \n ");
                return 0;
        }
+
+       memset(devc, 0, sizeof(*devc));
+       strcpy(devc->fm_info.name, "OPL2");
+
+       if (!request_region(ioaddr, 4, devc->fm_info.name)) {
+               printk(KERN_WARNING "opl3: I/O port 0x%x already in use\n", ioaddr);
+               goto cleanup_devc;
+       }
+
        devc->osp = osp;
        devc->base = ioaddr;
 
@@ -187,7 +198,7 @@
                signature != 0x0f)
        {
                MDB(printk(KERN_INFO "OPL3 not detected %x\n", signature));
-               return 0;
+               goto cleanup_region;
        }
 
        if (signature == 0x06)          /* OPL2 */
@@ -214,7 +225,7 @@
                        detected_model = 4;
                }
 
-               if (!check_region(ioaddr - 8, 2))       /* OPL4 port is free */
+               if (request_region(ioaddr - 8, 2, "OPL4"))      /* OPL4 port was free 
+*/
                {
                        int tmp;
 
@@ -232,7 +243,10 @@
                                udelay(10);
                        }
                        else
+                       { /* release OPL4 port */
+                               release_region(ioaddr - 8, 2);
                                detected_model = 3;
+                       }
                }
                opl3_command(ioaddr + 2, OPL3_MODE_REGISTER, 0);
        }
@@ -246,6 +260,12 @@
                                                                 * Melodic mode.
                                                                 */
        return 1;
+cleanup_region:
+       release_region(ioaddr, 4);
+cleanup_devc:
+       kfree(devc);
+       devc = NULL;
+       return 0;
 }
 
 static int opl3_kill_note  (int devno, int voice, int note, int velocity)
@@ -1099,12 +1119,7 @@
                return -1;
        }
 
-       memset((char *) devc, 0x00, sizeof(*devc));
-       devc->osp = osp;
-       devc->base = ioaddr;
-
        devc->nr_voice = 9;
-       strcpy(devc->fm_info.name, "OPL2");
 
        devc->fm_info.device = 0;
        devc->fm_info.synth_type = SYNTH_TYPE_FM;
@@ -1191,18 +1206,12 @@
 
        if (io != -1)   /* User loading pure OPL3 module */
        {
-               if (check_region(io, 4))
-               {
-                       printk(KERN_WARNING "opl3: I/O port 0x%x already in use\n", 
io);
-                       return 0;
-               }
                if (!opl3_detect(io, NULL))
                {
                        return -ENODEV;
                }
-               me = opl3_init(io, NULL, THIS_MODULE);
-               request_region(io, 4, devc->fm_info.name);
 
+               me = opl3_init(io, NULL, THIS_MODULE);
        }
 
        return 0;
@@ -1212,8 +1221,11 @@
 {
        if (devc && io != -1)
        {
-               if(devc->base)
+               if (devc->base) {
                        release_region(devc->base,4);
+                       if (devc->is_opl4)
+                               release_region(devc->base - 8, 2);
+               }
                kfree(devc);
                devc = NULL;
                sound_unload_synthdev(me);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/

Reply via email to