#define VLDBG(lun, fmt, args...) do { } while (0)
#endif /* VERBOSE_DEBUG */
-#define LDBG(lun, fmt, args...) dev_dbg (&(lun)->dev, fmt, ## args)
-#define LERROR(lun, fmt, args...) dev_err (&(lun)->dev, fmt, ## args)
+#define LDBG(lun, fmt, args...) dev_dbg(&(lun)->dev, fmt, ## args)
+#define LERROR(lun, fmt, args...) dev_err(&(lun)->dev, fmt, ## args)
#define LWARN(lun, fmt, args...) dev_warn(&(lun)->dev, fmt, ## args)
#define LINFO(lun, fmt, args...) dev_info(&(lun)->dev, fmt, ## args)
unsigned int blkbits; /* Bits of logical block size of bound block device */
unsigned int blksize; /* logical block size of bound block device */
struct device dev;
+#ifdef CONFIG_USB_MSC_PROFILING
+ spinlock_t lock;
+ struct {
+
+ unsigned long rbytes;
+ unsigned long wbytes;
+ ktime_t rtime;
+ ktime_t wtime;
+ } perf;
+
+#endif
};
static inline bool fsg_lun_is_open(struct fsg_lun *curlun)
#define EP0_BUFSIZE 256
#define DELAYED_STATUS (EP0_BUFSIZE + 999) /* An impossibly large value */
+#ifdef CONFIG_USB_CSW_HACK
+#define fsg_num_buffers 4
+#else
#ifdef CONFIG_USB_GADGET_DEBUG_FILES
static unsigned int fsg_num_buffers = CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS;
#define fsg_num_buffers CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS
#endif /* CONFIG_USB_DEBUG */
+#endif /* CONFIG_USB_CSW_HACK */
/* check if fsg_num_buffers is within a valid range */
static inline int fsg_num_buffers_validate(void)
if (fsg_num_buffers >= 2 && fsg_num_buffers <= 4)
return 0;
pr_err("fsg_num_buffers %u is out of range (%d to %d)\n",
- fsg_num_buffers, 2 ,4);
+ fsg_num_buffers, 2 , 4);
return -EINVAL;
}
/* Default size of buffer length. */
-#define FSG_BUFLEN ((u32)16384)
+#define FSG_BUFLEN ((u32)65536)
/* Maximal number of LUNs supported in mass storage function */
#define FSG_MAX_LUNS 8
return sprintf(buf, "%u\n", curlun->nofua);
}
+#ifdef CONFIG_USB_MSC_PROFILING
+static ssize_t fsg_show_perf(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct fsg_lun *curlun = fsg_lun_from_dev(dev);
+ unsigned long rbytes, wbytes;
+ int64_t rtime, wtime;
+
+ spin_lock(&curlun->lock);
+ rbytes = curlun->perf.rbytes;
+ wbytes = curlun->perf.wbytes;
+ rtime = ktime_to_us(curlun->perf.rtime);
+ wtime = ktime_to_us(curlun->perf.wtime);
+ spin_unlock(&curlun->lock);
+
+ return snprintf(buf, PAGE_SIZE, "Write performance :"
+ "%lu bytes in %lld microseconds\n"
+ "Read performance :"
+ "%lu bytes in %lld microseconds\n",
+ wbytes, wtime, rbytes, rtime);
+}
+static ssize_t fsg_store_perf(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct fsg_lun *curlun = fsg_lun_from_dev(dev);
+ int value;
+
+ sscanf(buf, "%d", &value);
+ if (!value) {
+ spin_lock(&curlun->lock);
+ memset(&curlun->perf, 0, sizeof(curlun->perf));
+ spin_unlock(&curlun->lock);
+ }
+
+ return count;
+}
+#endif
static ssize_t fsg_show_file(struct device *dev, struct device_attribute *attr,
char *buf)
{
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')
/* 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;
}