diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-11-14 09:35:46 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-11-14 11:22:45 -0500 |
commit | 32b8544296b944b204b33f9837701d4d0b9adefe (patch) | |
tree | 307ee25de70ac19e9fa93d2e231088c12ce583ef | |
parent | 6408eac2665955343cd0e4bcd7d6237ce39611ed (diff) |
ALSA: jack: Unregister input device at disconnection
The recent change in sysfs triggered a kernel WARNING at unloading a
sound driver like
WARNING: CPU: 3 PID: 2247 at fs/sysfs/group.c:214 sysfs_remove_group+0xe8/0xf0()
sysfs group ffffffff81ab7b20 not found for kobject 'event14'
for each jack instance. It's because the unregistration of jack input
device is done in dev_free callback, which is called after
snd_card_disconnect(). Since device_unregister(card->card_dev) is
called in snd_card_disconnect(), the whole sysfs entries belonging to
card->card_dev have been already removed recursively. Thus this
results in a warning as input_unregister_device() yet tries to
unregister the already removed sysfs entry.
For fixing this mess, we need to unregister the jack input device at
dev_disconnect callback so that it's called before unregistering the
card->card_dev.
Reviwed-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/core/jack.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/sound/core/jack.c b/sound/core/jack.c index b35fe7345c20..8658578eb584 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c | |||
@@ -34,12 +34,12 @@ static int jack_switch_types[SND_JACK_SWITCH_TYPES] = { | |||
34 | SW_LINEIN_INSERT, | 34 | SW_LINEIN_INSERT, |
35 | }; | 35 | }; |
36 | 36 | ||
37 | static int snd_jack_dev_free(struct snd_device *device) | 37 | static int snd_jack_dev_disconnect(struct snd_device *device) |
38 | { | 38 | { |
39 | struct snd_jack *jack = device->device_data; | 39 | struct snd_jack *jack = device->device_data; |
40 | 40 | ||
41 | if (jack->private_free) | 41 | if (!jack->input_dev) |
42 | jack->private_free(jack); | 42 | return 0; |
43 | 43 | ||
44 | /* If the input device is registered with the input subsystem | 44 | /* If the input device is registered with the input subsystem |
45 | * then we need to use a different deallocator. */ | 45 | * then we need to use a different deallocator. */ |
@@ -47,6 +47,18 @@ static int snd_jack_dev_free(struct snd_device *device) | |||
47 | input_unregister_device(jack->input_dev); | 47 | input_unregister_device(jack->input_dev); |
48 | else | 48 | else |
49 | input_free_device(jack->input_dev); | 49 | input_free_device(jack->input_dev); |
50 | jack->input_dev = NULL; | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | static int snd_jack_dev_free(struct snd_device *device) | ||
55 | { | ||
56 | struct snd_jack *jack = device->device_data; | ||
57 | |||
58 | if (jack->private_free) | ||
59 | jack->private_free(jack); | ||
60 | |||
61 | snd_jack_dev_disconnect(device); | ||
50 | 62 | ||
51 | kfree(jack->id); | 63 | kfree(jack->id); |
52 | kfree(jack); | 64 | kfree(jack); |
@@ -110,6 +122,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, | |||
110 | static struct snd_device_ops ops = { | 122 | static struct snd_device_ops ops = { |
111 | .dev_free = snd_jack_dev_free, | 123 | .dev_free = snd_jack_dev_free, |
112 | .dev_register = snd_jack_dev_register, | 124 | .dev_register = snd_jack_dev_register, |
125 | .dev_disconnect = snd_jack_dev_disconnect, | ||
113 | }; | 126 | }; |
114 | 127 | ||
115 | jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL); | 128 | jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL); |