]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - lib/vsprintf.c
spi: omap2-mcspi: fix blatant abuse of the resource subsystem
[karo-tx-linux.git] / lib / vsprintf.c
index 6fe2c84eb055695ffb80e766bd2d6fda1005b315..0eced40344dd2499d11d665538fe434b1aaa2e4d 100644 (file)
@@ -1183,6 +1183,21 @@ char *address_val(char *buf, char *end, const void *addr,
        return number(buf, end, num, spec);
 }
 
+static noinline_for_stack
+char *comm_name(char *buf, char *end, struct task_struct *tsk,
+               struct printf_spec spec, const char *fmt)
+{
+       char name[TASK_COMM_LEN];
+
+       /* Caller can pass NULL instead of current. */
+       if (!tsk)
+               tsk = current;
+       /* Not using get_task_comm() in case I'm in IRQ context. */
+       memcpy(name, tsk->comm, TASK_COMM_LEN);
+       name[sizeof(name) - 1] = '\0';
+       return string(buf, end, name, spec);
+}
+
 int kptr_restrict __read_mostly;
 
 /*
@@ -1250,6 +1265,7 @@ int kptr_restrict __read_mostly;
  *           (default assumed to be phys_addr_t, passed by reference)
  * - 'd[234]' For a dentry name (optionally 2-4 last components)
  * - 'D[234]' Same as 'd' but for a struct file
+ * - 'T' task_struct->comm
  *
  * Note: The difference between 'S' and 'F' is that on ia64 and ppc64
  * function pointers are really function descriptors, which contain a
@@ -1261,7 +1277,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
 {
        int default_width = 2 * sizeof(void *) + (spec.flags & SPECIAL ? 2 : 0);
 
-       if (!ptr && *fmt != 'K') {
+       if (!ptr && *fmt != 'K' && *fmt != 'T') {
                /*
                 * Print (null) with the same width as a pointer so it makes
                 * tabular output look nice.
@@ -1389,6 +1405,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
                return dentry_name(buf, end,
                                   ((const struct file *)ptr)->f_path.dentry,
                                   spec, fmt);
+       case 'T':
+               return comm_name(buf, end, ptr, spec, fmt);
        }
        spec.flags |= SMALL;
        if (spec.field_width == -1) {