[PATCH 16/50] mars: add new file drivers/block/mars/lib_timing.c
From: Thomas Schoebel-Theuer
Date: Tue Jul 01 2014 - 17:48:49 EST
Signed-off-by: Thomas Schoebel-Theuer <tst@xxxxxxxxxxxxxxxxxx>
---
drivers/block/mars/lib_timing.c | 51 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 drivers/block/mars/lib_timing.c
diff --git a/drivers/block/mars/lib_timing.c b/drivers/block/mars/lib_timing.c
new file mode 100644
index 0000000..9221c0b
--- /dev/null
+++ b/drivers/block/mars/lib_timing.c
@@ -0,0 +1,51 @@
+/* (c) 2012 Thomas Schoebel-Theuer / 1&1 Internet AG */
+
+#include <linux/brick/lib_timing.h>
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#ifdef CONFIG_MARS_DEBUG
+
+int report_timing(struct timing_stats *tim, char *str, int maxlen)
+{
+ int len = 0;
+ int time = 1;
+ int resol = 1;
+
+ static const char * const units[] = {
+ "us",
+ "ms",
+ "s",
+ "ERROR"
+ };
+ const char *unit = units[0];
+ int unit_index = 0;
+ int i;
+
+ for (i = 0; i < TIMING_MAX; i++) {
+ int this_len = scnprintf(str,
+
+ maxlen,
+ "<%d%s = %d (%lld) ",
+ resol,
+ unit,
+ tim->tim_count[i],
+ (long long)tim->tim_count[i] * time);
+ str += this_len;
+ len += this_len;
+ maxlen -= this_len;
+ if (maxlen <= 1)
+ break;
+ resol <<= 1;
+ time <<= 1;
+ if (resol >= 1000) {
+ resol = 1;
+ unit = units[++unit_index];
+ }
+ }
+ return len;
+}
+EXPORT_SYMBOL_GPL(report_timing);
+
+#endif
--
2.0.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/