Browse Source

ALSA: add private_data to struct snd_jack

Added private_data and private_free fields to struct snd_jack so that
the caller can assign the data.  It'll be helpful for avoiding the
double-free of the jack instance.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai 16 years ago
parent
commit
9d59065cd6
2 changed files with 5 additions and 0 deletions
  1. 2 0
      include/sound/jack.h
  2. 3 0
      sound/core/jack.c

+ 2 - 0
include/sound/jack.h

@@ -50,6 +50,8 @@ struct snd_jack {
 	int type;
 	int type;
 	const char *id;
 	const char *id;
 	char name[100];
 	char name[100];
+	void *private_data;
+	void (*private_free)(struct snd_jack *);
 };
 };
 
 
 #ifdef CONFIG_SND_JACK
 #ifdef CONFIG_SND_JACK

+ 3 - 0
sound/core/jack.c

@@ -35,6 +35,9 @@ static int snd_jack_dev_free(struct snd_device *device)
 {
 {
 	struct snd_jack *jack = device->device_data;
 	struct snd_jack *jack = device->device_data;
 
 
+	if (jack->private_free)
+		jack->private_free(jack);
+
 	/* If the input device is registered with the input subsystem
 	/* If the input device is registered with the input subsystem
 	 * then we need to use a different deallocator. */
 	 * then we need to use a different deallocator. */
 	if (jack->registered)
 	if (jack->registered)