Skip to content

Commit

Permalink
USB: audio gadget: free alsa devices when unloading
Browse files Browse the repository at this point in the history
Signed-off-by: Cliff Cai <cliff.cai@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Cliff Cai authored and Greg Kroah-Hartman committed Dec 23, 2009
1 parent d16f172 commit feef1d9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions drivers/usb/gadget/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ static int __init audio_bind(struct usb_composite_dev *cdev)

static int __exit audio_unbind(struct usb_composite_dev *cdev)
{
gaudio_cleanup();
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/f_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ int __init audio_bind_config(struct usb_configuration *c)
return status;

add_fail:
gaudio_cleanup(&audio->card);
gaudio_cleanup();
setup_fail:
kfree(audio);
return status;
Expand Down
12 changes: 9 additions & 3 deletions drivers/usb/gadget/u_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ static int gaudio_close_snd_dev(struct gaudio *gau)
return 0;
}

static struct gaudio *the_card;
/**
* gaudio_setup - setup ALSA interface and preparing for USB transfer
*
Expand All @@ -303,6 +304,9 @@ int __init gaudio_setup(struct gaudio *card)
if (ret)
ERROR(card, "we need at least one control device\n");

if (!the_card)
the_card = card;

return ret;

}
Expand All @@ -312,9 +316,11 @@ int __init gaudio_setup(struct gaudio *card)
*
* This is called to free all resources allocated by @gaudio_setup().
*/
void gaudio_cleanup(struct gaudio *card)
void gaudio_cleanup(void)
{
if (card)
gaudio_close_snd_dev(card);
if (the_card) {
gaudio_close_snd_dev(the_card);
the_card = NULL;
}
}

2 changes: 1 addition & 1 deletion drivers/usb/gadget/u_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ struct gaudio {
};

int gaudio_setup(struct gaudio *card);
void gaudio_cleanup(struct gaudio *card);
void gaudio_cleanup(void);

#endif /* __U_AUDIO_H */

0 comments on commit feef1d9

Please sign in to comment.