USB: fix usb mass storage umonut err.

This commit is contained in:
wlf
2014-09-04 19:39:59 +08:00
parent 3564738cba
commit a197fb6717

View File

@@ -703,10 +703,12 @@ 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_G_ANDROID
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')
@@ -715,12 +717,14 @@ static ssize_t fsg_store_file(struct device *dev, struct device_attribute *attr,
/* Load new medium */
down_write(filesem);
if (count > 0 && buf[0]) {
LDBG(curlun, "fsg_lun_open\n");
/* fsg_lun_open() will close existing file if any. */
rc = fsg_lun_open(curlun, buf);
if (rc == 0)
curlun->unit_attention_data =
SS_NOT_READY_TO_READY_TRANSITION;
} else if (fsg_lun_is_open(curlun)) {
LDBG(curlun, "fsg_lun_open\n");
fsg_lun_close(curlun);
curlun->unit_attention_data = SS_MEDIUM_NOT_PRESENT;
}