Commit c7b81707 authored by Lihua Yao's avatar Lihua Yao Committed by Takashi Iwai

ALSA: ac97: fix device initialization in the compat layer

ac97->dev is an object of 'struct device' type. It should be initialized
via device_initialize() or device_register().

Fixes: 74426fbf ("ALSA: ac97: add an ac97 bus")
Signed-off-by: default avatarLihua Yao <ylhuajnu@163.com>
Tested-by: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
Acked-by: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 82fd4b05
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
#include "ac97_core.h" #include "ac97_core.h"
static void compat_ac97_release(struct device *dev)
{
kfree(to_ac97_t(dev));
}
static void compat_ac97_reset(struct snd_ac97 *ac97) static void compat_ac97_reset(struct snd_ac97 *ac97)
{ {
struct ac97_codec_device *adev = to_ac97_device(ac97->private_data); struct ac97_codec_device *adev = to_ac97_device(ac97->private_data);
...@@ -65,21 +70,31 @@ static struct snd_ac97_bus compat_soc_ac97_bus = { ...@@ -65,21 +70,31 @@ static struct snd_ac97_bus compat_soc_ac97_bus = {
struct snd_ac97 *snd_ac97_compat_alloc(struct ac97_codec_device *adev) struct snd_ac97 *snd_ac97_compat_alloc(struct ac97_codec_device *adev)
{ {
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
int ret;
ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL); ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL);
if (ac97 == NULL) if (ac97 == NULL)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ac97->dev = adev->dev;
ac97->private_data = adev; ac97->private_data = adev;
ac97->bus = &compat_soc_ac97_bus; ac97->bus = &compat_soc_ac97_bus;
ac97->dev.parent = &adev->dev;
ac97->dev.release = compat_ac97_release;
dev_set_name(&ac97->dev, "%s-compat", dev_name(&adev->dev));
ret = device_register(&ac97->dev);
if (ret) {
put_device(&ac97->dev);
return ERR_PTR(ret);
}
return ac97; return ac97;
} }
EXPORT_SYMBOL_GPL(snd_ac97_compat_alloc); EXPORT_SYMBOL_GPL(snd_ac97_compat_alloc);
void snd_ac97_compat_release(struct snd_ac97 *ac97) void snd_ac97_compat_release(struct snd_ac97 *ac97)
{ {
kfree(ac97); device_unregister(&ac97->dev);
} }
EXPORT_SYMBOL_GPL(snd_ac97_compat_release); EXPORT_SYMBOL_GPL(snd_ac97_compat_release);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment