Commit 692c6a3f authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] USB gadget: file_storage.c -- remove device_unregister_wait()

It replaces a call to device_unregister_wait() in the File-backed
Storage Gadget.
parent 93976ea5
/* /*
* file_storage.c -- File-backed USB Storage Gadget, for USB development * file_storage.c -- File-backed USB Storage Gadget, for USB development
* *
* Copyright (C) 2003 Alan Stern * Copyright (C) 2003, 2004 Alan Stern
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
#define DRIVER_DESC "File-backed Storage Gadget" #define DRIVER_DESC "File-backed Storage Gadget"
#define DRIVER_NAME "g_file_storage" #define DRIVER_NAME "g_file_storage"
#define DRIVER_VERSION "14 January 2004" #define DRIVER_VERSION "26 January 2004"
static const char longname[] = DRIVER_DESC; static const char longname[] = DRIVER_DESC;
static const char shortname[] = DRIVER_NAME; static const char shortname[] = DRIVER_NAME;
...@@ -848,6 +848,7 @@ struct fsg_dev { ...@@ -848,6 +848,7 @@ struct fsg_dev {
unsigned int nluns; unsigned int nluns;
struct lun *luns; struct lun *luns;
struct lun *curlun; struct lun *curlun;
struct completion lun_released;
}; };
typedef void (*fsg_routine_t)(struct fsg_dev *); typedef void (*fsg_routine_t)(struct fsg_dev *);
...@@ -3771,6 +3772,13 @@ static DEVICE_ATTR(file, 0444, show_file, NULL); ...@@ -3771,6 +3772,13 @@ static DEVICE_ATTR(file, 0444, show_file, NULL);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static void lun_release(struct device *dev)
{
struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev);
complete(&fsg->lun_released);
}
static void fsg_unbind(struct usb_gadget *gadget) static void fsg_unbind(struct usb_gadget *gadget)
{ {
struct fsg_dev *fsg = get_gadget_data(gadget); struct fsg_dev *fsg = get_gadget_data(gadget);
...@@ -3782,12 +3790,14 @@ static void fsg_unbind(struct usb_gadget *gadget) ...@@ -3782,12 +3790,14 @@ static void fsg_unbind(struct usb_gadget *gadget)
clear_bit(REGISTERED, &fsg->atomic_bitflags); clear_bit(REGISTERED, &fsg->atomic_bitflags);
/* Unregister the sysfs attribute files and the LUNs */ /* Unregister the sysfs attribute files and the LUNs */
init_completion(&fsg->lun_released);
for (i = 0; i < fsg->nluns; ++i) { for (i = 0; i < fsg->nluns; ++i) {
curlun = &fsg->luns[i]; curlun = &fsg->luns[i];
if (curlun->registered) { if (curlun->registered) {
device_remove_file(&curlun->dev, &dev_attr_ro); device_remove_file(&curlun->dev, &dev_attr_ro);
device_remove_file(&curlun->dev, &dev_attr_file); device_remove_file(&curlun->dev, &dev_attr_file);
device_unregister_wait(&curlun->dev); device_unregister(&curlun->dev);
wait_for_completion(&fsg->lun_released);
curlun->registered = 0; curlun->registered = 0;
} }
} }
...@@ -4140,6 +4150,7 @@ static int __init fsg_init(void) ...@@ -4140,6 +4150,7 @@ static int __init fsg_init(void)
INFO(fsg, "failed to register LUN%d: %d\n", i, rc); INFO(fsg, "failed to register LUN%d: %d\n", i, rc);
else { else {
curlun->registered = 1; curlun->registered = 1;
curlun->dev.release = lun_release;
device_create_file(&curlun->dev, &dev_attr_ro); device_create_file(&curlun->dev, &dev_attr_ro);
device_create_file(&curlun->dev, &dev_attr_file); device_create_file(&curlun->dev, &dev_attr_file);
} }
......
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