diff options
author | Lihua Yao <ylhuajnu@163.com> | 2018-08-15 08:59:46 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-08-19 12:34:31 -0400 |
commit | c7b8170790c19293acd835dc50b8247ec207d4a3 (patch) | |
tree | fec30276f4c3b015f3746cd44cf057b7cf0f2f6e /sound | |
parent | 82fd4b05d704623a0e4aa7fda48e272a9889337d (diff) |
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: 74426fbff66e ("ALSA: ac97: add an ac97 bus")
Signed-off-by: Lihua Yao <ylhuajnu@163.com>
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/ac97/snd_ac97_compat.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sound/ac97/snd_ac97_compat.c b/sound/ac97/snd_ac97_compat.c index 61544e0d8de4..8bab44f74bb8 100644 --- a/sound/ac97/snd_ac97_compat.c +++ b/sound/ac97/snd_ac97_compat.c | |||
@@ -15,6 +15,11 @@ | |||
15 | 15 | ||
16 | #include "ac97_core.h" | 16 | #include "ac97_core.h" |
17 | 17 | ||
18 | static void compat_ac97_release(struct device *dev) | ||
19 | { | ||
20 | kfree(to_ac97_t(dev)); | ||
21 | } | ||
22 | |||
18 | static void compat_ac97_reset(struct snd_ac97 *ac97) | 23 | static void compat_ac97_reset(struct snd_ac97 *ac97) |
19 | { | 24 | { |
20 | struct ac97_codec_device *adev = to_ac97_device(ac97->private_data); | 25 | 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 | struct snd_ac97 *snd_ac97_compat_alloc(struct ac97_codec_device *adev) | 70 | struct snd_ac97 *snd_ac97_compat_alloc(struct ac97_codec_device *adev) |
66 | { | 71 | { |
67 | struct snd_ac97 *ac97; | 72 | struct snd_ac97 *ac97; |
73 | int ret; | ||
68 | 74 | ||
69 | ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL); | 75 | ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL); |
70 | if (ac97 == NULL) | 76 | if (ac97 == NULL) |
71 | return ERR_PTR(-ENOMEM); | 77 | return ERR_PTR(-ENOMEM); |
72 | 78 | ||
73 | ac97->dev = adev->dev; | ||
74 | ac97->private_data = adev; | 79 | ac97->private_data = adev; |
75 | ac97->bus = &compat_soc_ac97_bus; | 80 | ac97->bus = &compat_soc_ac97_bus; |
81 | |||
82 | ac97->dev.parent = &adev->dev; | ||
83 | ac97->dev.release = compat_ac97_release; | ||
84 | dev_set_name(&ac97->dev, "%s-compat", dev_name(&adev->dev)); | ||
85 | ret = device_register(&ac97->dev); | ||
86 | if (ret) { | ||
87 | put_device(&ac97->dev); | ||
88 | return ERR_PTR(ret); | ||
89 | } | ||
90 | |||
76 | return ac97; | 91 | return ac97; |
77 | } | 92 | } |
78 | EXPORT_SYMBOL_GPL(snd_ac97_compat_alloc); | 93 | EXPORT_SYMBOL_GPL(snd_ac97_compat_alloc); |
79 | 94 | ||
80 | void snd_ac97_compat_release(struct snd_ac97 *ac97) | 95 | void snd_ac97_compat_release(struct snd_ac97 *ac97) |
81 | { | 96 | { |
82 | kfree(ac97); | 97 | device_unregister(&ac97->dev); |
83 | } | 98 | } |
84 | EXPORT_SYMBOL_GPL(snd_ac97_compat_release); | 99 | EXPORT_SYMBOL_GPL(snd_ac97_compat_release); |
85 | 100 | ||