aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/core/jack.c19
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
37static int snd_jack_dev_free(struct snd_device *device) 37static 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
54static 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);