patch-2.4.22 linux-2.4.22/drivers/sound/ymfpci.c
Next file: linux-2.4.22/drivers/sound/ymfpci.h
Previous file: linux-2.4.22/drivers/sound/via82cxxx_audio.c
Back to the patch index
Back to the overall index
- Lines: 101
- Date:
2003-08-25 04:44:42.000000000 -0700
- Orig file:
linux-2.4.21/drivers/sound/ymfpci.c
- Orig date:
2002-08-02 17:39:44.000000000 -0700
diff -urN linux-2.4.21/drivers/sound/ymfpci.c linux-2.4.22/drivers/sound/ymfpci.c
@@ -176,15 +176,16 @@
ymfpci_t *codec = dev->private_data;
u32 cmd;
+ spin_lock(&codec->ac97_lock);
/* XXX Do make use of dev->id */
ymfpci_codec_ready(codec, 0, 0);
cmd = ((YDSXG_AC97WRITECMD | reg) << 16) | val;
ymfpci_writel(codec, YDSXGR_AC97CMDDATA, cmd);
+ spin_unlock(&codec->ac97_lock);
}
-static u16 ymfpci_codec_read(struct ac97_codec *dev, u8 reg)
+static u16 _ymfpci_codec_read(ymfpci_t *unit, u8 reg)
{
- ymfpci_t *unit = dev->private_data;
int i;
if (ymfpci_codec_ready(unit, 0, 0))
@@ -199,6 +200,18 @@
return ymfpci_readw(unit, YDSXGR_PRISTATUSDATA);
}
+static u16 ymfpci_codec_read(struct ac97_codec *dev, u8 reg)
+{
+ ymfpci_t *unit = dev->private_data;
+ u16 ret;
+
+ spin_lock(&unit->ac97_lock);
+ ret = _ymfpci_codec_read(unit, reg);
+ spin_unlock(&unit->ac97_lock);
+
+ return ret;
+}
+
/*
* Misc routines
*/
@@ -2442,9 +2455,8 @@
struct ac97_codec *codec;
u16 eid;
- if ((codec = kmalloc(sizeof(struct ac97_codec), GFP_KERNEL)) == NULL)
+ if ((codec = ac97_alloc_codec()) == NULL)
return -ENOMEM;
- memset(codec, 0, sizeof(struct ac97_codec));
/* initialize some basic codec information, other fields will be filled
in ac97_probe_codec */
@@ -2460,7 +2472,7 @@
}
eid = ymfpci_codec_read(codec, AC97_EXTENDED_ID);
- if (eid==0xFFFFFF) {
+ if (eid==0xFFFF) {
printk(KERN_WARNING "ymfpci: no codec attached ?\n");
goto out_kfree;
}
@@ -2476,7 +2488,7 @@
return 0;
out_kfree:
- kfree(codec);
+ ac97_release_codec(codec);
return -ENODEV;
}
@@ -2515,6 +2527,7 @@
spin_lock_init(&codec->reg_lock);
spin_lock_init(&codec->voice_lock);
+ spin_lock_init(&codec->ac97_lock);
init_MUTEX(&codec->open_sem);
INIT_LIST_HEAD(&codec->states);
codec->pci = pcidev;
@@ -2613,7 +2626,7 @@
out_release_region:
release_mem_region(pci_resource_start(pcidev, 0), 0x8000);
out_free:
- kfree(codec);
+ ac97_release_codec(codec->ac97_codec[0]);
return -ENODEV;
}
@@ -2626,7 +2639,7 @@
list_del(&codec->ymf_devs);
unregister_sound_mixer(codec->ac97_codec[0]->dev_mixer);
- kfree(codec->ac97_codec[0]);
+ ac97_release_codec(codec->ac97_codec[0]);
unregister_sound_dsp(codec->dev_audio);
free_irq(pcidev->irq, codec);
ymfpci_memfree(codec);
@@ -2641,7 +2654,6 @@
unload_uart401(&codec->mpu_data);
}
#endif /* CONFIG_SOUND_YMFPCI_LEGACY */
- kfree(codec);
}
MODULE_AUTHOR("Jaroslav Kysela");
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)