X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Foss%2Fsgalaxy.c;h=16cc9ab505b538b1ecdd631b0c18dd6652a7ecb6;hb=82ba8664b914f9985d674bd8773799cd734d9835;hp=1e310971653d04030ce396633147322498b4afd4;hpb=a91482bdcc2e0f6035702e46f1b99043a0893346;p=linux-2.6.git diff --git a/sound/oss/sgalaxy.c b/sound/oss/sgalaxy.c index 1e3109716..16cc9ab50 100644 --- a/sound/oss/sgalaxy.c +++ b/sound/oss/sgalaxy.c @@ -86,19 +86,31 @@ static int __init sb_cmd( int base, unsigned char val ) static int __init probe_sgalaxy( struct address_info *ai ) { - if ( check_region( ai->io_base, 8 ) ) { + struct resource *ports; + int n; + + if (!request_region(ai->io_base, 4, "WSS config")) { printk(KERN_ERR "sgalaxy: WSS IO port 0x%03x not available\n", ai->io_base); return 0; } - - if ( ad1848_detect( ai->io_base+4, NULL, ai->osp ) ) - return probe_ms_sound(ai); /* The card is already active, check irq etc... */ - if ( check_region( ai->ai_sgbase, 0x10 ) ) { + ports = request_region(ai->io_base + 4, 4, "ad1848"); + if (!ports) { + printk(KERN_ERR "sgalaxy: WSS IO port 0x%03x not available\n", ai->io_base); + release_region(ai->io_base, 4); + return 0; + } + + if (!request_region( ai->ai_sgbase, 0x10, "SoundGalaxy SB")) { printk(KERN_ERR "sgalaxy: SB IO port 0x%03x not available\n", ai->ai_sgbase); + release_region(ai->io_base + 4, 4); + release_region(ai->io_base, 4); return 0; } + if (ad1848_detect(ports, NULL, ai->osp)) + goto out; /* The card is already active, check irq etc... */ + /* switch to MSS/WSS mode */ sb_rst( ai->ai_sgbase ); @@ -108,16 +120,15 @@ static int __init probe_sgalaxy( struct address_info *ai ) sleep( HZ/10 ); - return probe_ms_sound(ai); -} +out: + if (!probe_ms_sound(ai, ports)) { + release_region(ai->io_base + 4, 4); + release_region(ai->io_base, 4); + release_region(ai->ai_sgbase, 0x10); + return 0; + } -static void __init attach_sgalaxy( struct address_info *ai ) -{ - int n; - - request_region( ai->ai_sgbase, 0x10, "SoundGalaxy SB" ); - - attach_ms_sound(ai, THIS_MODULE); + attach_ms_sound(ai, ports, THIS_MODULE); n=ai->slots[0]; if (n!=-1 && audio_devs[n]->mixer_dev != -1 ) { @@ -125,6 +136,7 @@ static void __init attach_sgalaxy( struct address_info *ai ) AD1848_REROUTE( SOUND_MIXER_LINE2, SOUND_MIXER_SYNTH ); /* FM+Wavetable*/ AD1848_REROUTE( SOUND_MIXER_LINE3, SOUND_MIXER_CD ); /* CD */ } + return 1; } static void __exit unload_sgalaxy( struct address_info *ai ) @@ -163,8 +175,6 @@ static int __init init_sgalaxy(void) if ( probe_sgalaxy(&cfg) == 0 ) return -ENODEV; - attach_sgalaxy(&cfg); - return 0; }