diff options
Diffstat (limited to 'sound/pci/hda/patch_conexant.c')
-rw-r--r-- | sound/pci/hda/patch_conexant.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 1f2ad76ca94b..56ce19e68cb5 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -350,12 +350,20 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
350 | } | 350 | } |
351 | 351 | ||
352 | #ifdef CONFIG_SND_JACK | 352 | #ifdef CONFIG_SND_JACK |
353 | static void conexant_free_jack_priv(struct snd_jack *jack) | ||
354 | { | ||
355 | struct conexant_jack *jacks = jack->private_data; | ||
356 | jacks->nid = 0; | ||
357 | jacks->jack = NULL; | ||
358 | } | ||
359 | |||
353 | static int conexant_add_jack(struct hda_codec *codec, | 360 | static int conexant_add_jack(struct hda_codec *codec, |
354 | hda_nid_t nid, int type) | 361 | hda_nid_t nid, int type) |
355 | { | 362 | { |
356 | struct conexant_spec *spec; | 363 | struct conexant_spec *spec; |
357 | struct conexant_jack *jack; | 364 | struct conexant_jack *jack; |
358 | const char *name; | 365 | const char *name; |
366 | int err; | ||
359 | 367 | ||
360 | spec = codec->spec; | 368 | spec = codec->spec; |
361 | snd_array_init(&spec->jacks, sizeof(*jack), 32); | 369 | snd_array_init(&spec->jacks, sizeof(*jack), 32); |
@@ -368,7 +376,12 @@ static int conexant_add_jack(struct hda_codec *codec, | |||
368 | jack->nid = nid; | 376 | jack->nid = nid; |
369 | jack->type = type; | 377 | jack->type = type; |
370 | 378 | ||
371 | return snd_jack_new(codec->bus->card, name, type, &jack->jack); | 379 | err = snd_jack_new(codec->bus->card, name, type, &jack->jack); |
380 | if (err < 0) | ||
381 | return err; | ||
382 | jack->jack->private_data = jack; | ||
383 | jack->jack->private_free = conexant_free_jack_priv; | ||
384 | return 0; | ||
372 | } | 385 | } |
373 | 386 | ||
374 | static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) | 387 | static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) |
@@ -455,8 +468,10 @@ static void conexant_free(struct hda_codec *codec) | |||
455 | if (spec->jacks.list) { | 468 | if (spec->jacks.list) { |
456 | struct conexant_jack *jacks = spec->jacks.list; | 469 | struct conexant_jack *jacks = spec->jacks.list; |
457 | int i; | 470 | int i; |
458 | for (i = 0; i < spec->jacks.used; i++) | 471 | for (i = 0; i < spec->jacks.used; i++, jacks++) { |
459 | snd_device_free(codec->bus->card, &jacks[i].jack); | 472 | if (jacks->jack) |
473 | snd_device_free(codec->bus->card, jacks->jack); | ||
474 | } | ||
460 | snd_array_free(&spec->jacks); | 475 | snd_array_free(&spec->jacks); |
461 | } | 476 | } |
462 | #endif | 477 | #endif |