Commit feef1d95 authored by Cliff Cai's avatar Cliff Cai Committed by Greg Kroah-Hartman

USB: audio gadget: free alsa devices when unloading

Signed-off-by: default avatarCliff Cai <cliff.cai@analog.com>
Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent d16f1726
...@@ -158,6 +158,7 @@ fail: ...@@ -158,6 +158,7 @@ fail:
static int __exit audio_unbind(struct usb_composite_dev *cdev) static int __exit audio_unbind(struct usb_composite_dev *cdev)
{ {
gaudio_cleanup();
return 0; return 0;
} }
......
...@@ -792,7 +792,7 @@ int __init audio_bind_config(struct usb_configuration *c) ...@@ -792,7 +792,7 @@ int __init audio_bind_config(struct usb_configuration *c)
return status; return status;
add_fail: add_fail:
gaudio_cleanup(&audio->card); gaudio_cleanup();
setup_fail: setup_fail:
kfree(audio); kfree(audio);
return status; return status;
......
...@@ -288,6 +288,7 @@ static int gaudio_close_snd_dev(struct gaudio *gau) ...@@ -288,6 +288,7 @@ static int gaudio_close_snd_dev(struct gaudio *gau)
return 0; return 0;
} }
static struct gaudio *the_card;
/** /**
* gaudio_setup - setup ALSA interface and preparing for USB transfer * gaudio_setup - setup ALSA interface and preparing for USB transfer
* *
...@@ -303,6 +304,9 @@ int __init gaudio_setup(struct gaudio *card) ...@@ -303,6 +304,9 @@ int __init gaudio_setup(struct gaudio *card)
if (ret) if (ret)
ERROR(card, "we need at least one control device\n"); ERROR(card, "we need at least one control device\n");
if (!the_card)
the_card = card;
return ret; return ret;
} }
...@@ -312,9 +316,11 @@ int __init gaudio_setup(struct gaudio *card) ...@@ -312,9 +316,11 @@ int __init gaudio_setup(struct gaudio *card)
* *
* This is called to free all resources allocated by @gaudio_setup(). * This is called to free all resources allocated by @gaudio_setup().
*/ */
void gaudio_cleanup(struct gaudio *card) void gaudio_cleanup(void)
{ {
if (card) if (the_card) {
gaudio_close_snd_dev(card); gaudio_close_snd_dev(the_card);
the_card = NULL;
}
} }
...@@ -51,6 +51,6 @@ struct gaudio { ...@@ -51,6 +51,6 @@ struct gaudio {
}; };
int gaudio_setup(struct gaudio *card); int gaudio_setup(struct gaudio *card);
void gaudio_cleanup(struct gaudio *card); void gaudio_cleanup(void);
#endif /* __U_AUDIO_H */ #endif /* __U_AUDIO_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment