- Update to 3.3-rc2.
[linux-flexiantxendom0-3.2.10.git] / kernel / printk.c
index 13c0a11..03d695e 100644 (file)
@@ -41,6 +41,8 @@
 #include <linux/cpu.h>
 #include <linux/notifier.h>
 #include <linux/rculist.h>
+#include <linux/jhash.h>
+#include <linux/device.h>
 
 #include <asm/uaccess.h>
 
@@ -488,7 +490,7 @@ SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
        return do_syslog(type, buf, len, SYSLOG_FROM_CALL);
 }
 
-#ifdef CONFIG_KGDB_KDB
+#if defined(CONFIG_KGDB_KDB) || defined(CONFIG_DEBUG_KERNEL)
 /* kdb dmesg command needs access to the syslog buffer.  do_syslog()
  * uses locks so it cannot be used during debugging.  Just tell kdb
  * where the start and end of the physical and logical logs are.  This
@@ -1760,3 +1762,46 @@ void kmsg_dump(enum kmsg_dump_reason reason)
        rcu_read_unlock();
 }
 #endif
+
+#if defined CONFIG_PRINTK && defined CONFIG_KMSG_IDS
+
+/**
+ * printk_hash - print a kernel message include a hash over the message
+ * @prefix: message prefix including the ".%06x" for the hash
+ * @fmt: format string
+ */
+asmlinkage int printk_hash(const char *prefix, const char *fmt, ...)
+{
+       va_list args;
+       int r;
+
+       r = printk(prefix, jhash(fmt, strlen(fmt), 0) & 0xffffff);
+       va_start(args, fmt);
+       r += vprintk(fmt, args);
+       va_end(args);
+
+       return r;
+}
+EXPORT_SYMBOL(printk_hash);
+
+/**
+ * printk_dev_hash - print a kernel message include a hash over the message
+ * @prefix: message prefix including the ".%06x" for the hash
+ * @dev: device this printk is all about
+ * @fmt: format string
+ */
+asmlinkage int printk_dev_hash(const char *prefix, const char *driver_name,
+                              const char *fmt, ...)
+{
+       va_list args;
+       int r;
+
+       r = printk(prefix, driver_name, jhash(fmt, strlen(fmt), 0) & 0xffffff);
+       va_start(args, fmt);
+       r += vprintk(fmt, args);
+       va_end(args);
+
+       return r;
+}
+EXPORT_SYMBOL(printk_dev_hash);
+#endif