ChangeSet 1.1500.8.6, 2004/01/29 16:16:12-08:00, stern@rowland.harvard.edu [PATCH] USB gadget: file_storage.c -- remove device_unregister_wait() It replaces a call to device_unregister_wait() in the File-backed Storage Gadget. drivers/usb/gadget/file_storage.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff -Nru a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c --- a/drivers/usb/gadget/file_storage.c Mon Feb 9 14:42:05 2004 +++ b/drivers/usb/gadget/file_storage.c Mon Feb 9 14:42:05 2004 @@ -1,7 +1,7 @@ /* * 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. * * Redistribution and use in source and binary forms, with or without @@ -244,7 +244,7 @@ #define DRIVER_DESC "File-backed Storage Gadget" #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 shortname[] = DRIVER_NAME; @@ -848,6 +848,7 @@ unsigned int nluns; struct lun *luns; struct lun *curlun; + struct completion lun_released; }; typedef void (*fsg_routine_t)(struct fsg_dev *); @@ -3771,6 +3772,13 @@ /*-------------------------------------------------------------------------*/ +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) { struct fsg_dev *fsg = get_gadget_data(gadget); @@ -3782,12 +3790,14 @@ clear_bit(REGISTERED, &fsg->atomic_bitflags); /* Unregister the sysfs attribute files and the LUNs */ + init_completion(&fsg->lun_released); for (i = 0; i < fsg->nluns; ++i) { curlun = &fsg->luns[i]; if (curlun->registered) { device_remove_file(&curlun->dev, &dev_attr_ro); 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; } } @@ -4140,6 +4150,7 @@ INFO(fsg, "failed to register LUN%d: %d\n", i, rc); else { curlun->registered = 1; + curlun->dev.release = lun_release; device_create_file(&curlun->dev, &dev_attr_ro); device_create_file(&curlun->dev, &dev_attr_file); }