Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 185382
b: refs/heads/master
c: 7f1ee82
h: refs/heads/master
v: v3
  • Loading branch information
Michal Nazarewicz authored and Greg Kroah-Hartman committed Mar 2, 2010
1 parent 4102685 commit b4f2ad5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9f445cb29918dc488b7a9a92ef018599cce33df7
refs/heads/master: 7f1ee82695654faf0a93fc0abf3b08eb354ef1f6
26 changes: 21 additions & 5 deletions trunk/drivers/usb/gadget/f_mass_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ struct fsg_common {
struct task_struct *thread_task;

/* Callback function to call when thread exits. */
void (*thread_exits)(struct fsg_common *common);
int (*thread_exits)(struct fsg_common *common);
/* Gadget's private data. */
void *private_data;

Expand All @@ -392,8 +392,12 @@ struct fsg_config {
const char *lun_name_format;
const char *thread_name;

/* Callback function to call when thread exits. */
void (*thread_exits)(struct fsg_common *common);
/* Callback function to call when thread exits. If no
* callback is set or it returns value lower then zero MSF
* will force eject all LUNs it operates on (including those
* marked as non-removable or with prevent_medium_removal flag
* set). */
int (*thread_exits)(struct fsg_common *common);
/* Gadget's private data. */
void *private_data;

Expand Down Expand Up @@ -2615,8 +2619,20 @@ static int fsg_main_thread(void *common_)
common->thread_task = NULL;
spin_unlock_irq(&common->lock);

if (common->thread_exits)
common->thread_exits(common);
if (!common->thread_exits || common->thread_exits(common) < 0) {
struct fsg_lun *curlun = common->luns;
unsigned i = common->nluns;

down_write(&common->filesem);
for (; i--; ++curlun) {
if (!fsg_lun_is_open(curlun))
continue;

fsg_lun_close(curlun);
curlun->unit_attention_data = SS_MEDIUM_NOT_PRESENT;
}
up_write(&common->filesem);
}

/* Let the unbind and cleanup routines know the thread has exited */
complete_and_exit(&common->thread_notifier, 0);
Expand Down
8 changes: 7 additions & 1 deletion trunk/drivers/usb/gadget/mass_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ FSG_MODULE_PARAMETERS(/* no prefix */, mod_data);
static unsigned long msg_registered = 0;
static void msg_cleanup(void);

static int msg_thread_exits(struct fsg_common *common)
{
msg_cleanup();
return 0;
}

static int __init msg_do_config(struct usb_configuration *c)
{
struct fsg_common *common;
Expand All @@ -147,7 +153,7 @@ static int __init msg_do_config(struct usb_configuration *c)
}

fsg_config_from_params(&config, &mod_data);
config.thread_exits = (void(*)(struct fsg_common*))&msg_cleanup;
config.thread_exits = msg_thread_exits;
common = fsg_common_init(0, c->cdev, &config);
if (IS_ERR(common))
return PTR_ERR(common);
Expand Down

0 comments on commit b4f2ad5

Please sign in to comment.