USB: g_mass_storage: Always allow disabling mass storage by writing to lun file
authorMike Lockwood <lockwood@android.com>
Thu, 29 Jul 2010 18:42:24 +0000 (14:42 -0400)
committerColin Cross <ccross@android.com>
Thu, 30 Sep 2010 00:49:42 +0000 (17:49 -0700)
For android builds we disable the check for curlun->prevent_medium_removal.
Instead we let the framework manage unmounting policy, as we sometimes need
to unmount after the media has been removed.
This also helps support hosts that do not inform the device when the media
has been unmounted.

Signed-off-by: Mike Lockwood <lockwood@android.com>
drivers/usb/gadget/storage_common.c

index 484acfb1a7c5a999e9b2ef5f48c4ab54d1c0a549..2771166ac69a4ace3e0d3e69db6ffadc59c5abdb 100644 (file)
@@ -805,10 +805,16 @@ static ssize_t fsg_store_file(struct device *dev, struct device_attribute *attr,
        struct rw_semaphore     *filesem = dev_get_drvdata(dev);
        int             rc = 0;
 
+
+#ifndef CONFIG_USB_ANDROID_MASS_STORAGE
+       /* disabled in android because we need to allow closing the backing file
+        * if the media was removed
+        */
        if (curlun->prevent_medium_removal && fsg_lun_is_open(curlun)) {
                LDBG(curlun, "eject attempt prevented\n");
                return -EBUSY;                          /* "Door is locked" */
        }
+#endif
 
        /* Remove a trailing newline */
        if (count > 0 && buf[count-1] == '\n')