ad1848_mixer_reset(devc);
}
-int ad1848_detect(int io_base, int *ad_flags, int *osp)
+int ad1848_detect(struct resource *ports, int *ad_flags, int *osp)
{
unsigned char tmp;
ad1848_info *devc = &adev_info[nr_ad1848_devs];
int ad1847_flag = 0;
int cs4248_flag = 0;
int sscape_flag = 0;
+ int io_base = ports->start;
int i;
printk(KERN_ERR "ad1848 - Too many audio devices\n");
return 0;
}
- if (check_region(io_base, 4))
- {
- printk(KERN_ERR "ad1848.c: Port %x not free.\n", io_base);
- return 0;
- }
spin_lock_init(&devc->lock);
devc->base = io_base;
devc->irq_ok = 0;
return 1;
}
-int ad1848_init (char *name, int io_base, int irq, int dma_playback,
+int ad1848_init (char *name, struct resource *ports, int irq, int dma_playback,
int dma_capture, int share_dma, int *osp, struct module *owner)
{
/*
sprintf(dev_name,
"Generic audio codec (%s)", devc->chip_name);
- if (!request_region(devc->base, 4, devc->name))
- return -1;
+ rename_region(ports, devc->name);
conf_printf2(dev_name, devc->base, devc->irq, dma_playback, dma_capture);
return 1;
}
-int probe_ms_sound(struct address_info *hw_config)
+int probe_ms_sound(struct address_info *hw_config, struct resource *ports)
{
unsigned char tmp;
DDB(printk("Entered probe_ms_sound(%x, %d)\n", hw_config->io_base, hw_config->card_subtype));
- if (check_region(hw_config->io_base, 8))
- {
- printk(KERN_ERR "MSS: I/O port conflict\n");
- return 0;
- }
if (hw_config->card_subtype == 1) /* Has no IRQ/DMA registers */
{
/* check_opl3(0x388, hw_config); */
- return ad1848_detect(hw_config->io_base + 4, NULL, hw_config->osp);
+ return ad1848_detect(ports, NULL, hw_config->osp);
}
if (deskpro_xl && hw_config->card_subtype == 2) /* Compaq Deskpro XL */
int ret;
DDB(printk("I/O address is inactive (%x)\n", tmp));
- if (!(ret = ad1848_detect(hw_config->io_base + 4, NULL, hw_config->osp)))
+ if (!(ret = ad1848_detect(ports, NULL, hw_config->osp)))
return 0;
return 1;
}
MDB(printk(KERN_ERR "No MSS signature detected on port 0x%x (0x%x)\n", hw_config->io_base, (int) inb(hw_config->io_base + 3)));
DDB(printk("Trying to detect codec anyway but IRQ/DMA may not work\n"));
- if (!(ret = ad1848_detect(hw_config->io_base + 4, NULL, hw_config->osp)))
+ if (!(ret = ad1848_detect(ports, NULL, hw_config->osp)))
return 0;
hw_config->card_subtype = 1;
printk(KERN_ERR "MSS: Can't use IRQ%d with a 8 bit card/slot\n", hw_config->irq);
return 0;
}
- return ad1848_detect(hw_config->io_base + 4, NULL, hw_config->osp);
+ return ad1848_detect(ports, NULL, hw_config->osp);
}
-void attach_ms_sound(struct address_info *hw_config, struct module *owner)
+void attach_ms_sound(struct address_info *hw_config, struct resource *ports, struct module *owner)
{
static signed char interrupt_bits[12] =
{
if (hw_config->card_subtype == 1) /* Has no IRQ/DMA registers */
{
- hw_config->slots[0] = ad1848_init("MS Sound System", hw_config->io_base + 4,
+ hw_config->slots[0] = ad1848_init("MS Sound System", ports,
hw_config->irq,
hw_config->dma,
hw_config->dma2, 0,
hw_config->osp,
owner);
- request_region(hw_config->io_base, 4, "WSS config");
return;
}
/*
if (bits == -1)
{
printk(KERN_ERR "MSS: Bad IRQ %d\n", hw_config->irq);
+ release_region(ports->start, 4);
+ release_region(ports->start - 4, 4);
return;
}
outb((bits | 0x40), config_port);
outb((bits | dma_bits[dma] | dma2_bit), config_port); /* Write IRQ+DMA setup */
- hw_config->slots[0] = ad1848_init("MS Sound System", hw_config->io_base + 4,
+ hw_config->slots[0] = ad1848_init("MS Sound System", ports,
hw_config->irq,
dma, dma2, 0,
hw_config->osp,
THIS_MODULE);
- request_region(hw_config->io_base, 4, "WSS config");
}
void unload_ms_sound(struct address_info *hw_config)
#endif
if(io != -1) {
+ struct resource *ports;
if( isapnp == 0 )
{
if(irq == -1 || dma == -1) {
cfg.card_subtype = type;
}
- if(!probe_ms_sound(&cfg))
+ ports = request_region(io + 4, 4, "ad1848");
+
+ if (!ports)
+ return -EBUSY;
+
+ if (!request_region(io, 4, "WSS config")) {
+ release_region(io + 4, 4);
+ return -EBUSY;
+ }
+
+ if (!probe_ms_sound(&cfg, ports)) {
+ release_region(io + 4, 4);
+ release_region(io, 4);
return -ENODEV;
- attach_ms_sound(&cfg, THIS_MODULE);
+ }
+ attach_ms_sound(&cfg, ports, THIS_MODULE);
loaded = 1;
}
return 0;