arm64: dts: rk3399-evb: add test-power
[firefly-linux-kernel-4.4.55.git] / kernel / trace / trace_printk.c
index 36c1455b7567ee11f2305cc71b2aa9f48c2a0ae1..ad1d6164e94603cf29f1b26f0a58f8c37988d57b 100644 (file)
@@ -36,6 +36,10 @@ struct trace_bprintk_fmt {
 static inline struct trace_bprintk_fmt *lookup_format(const char *fmt)
 {
        struct trace_bprintk_fmt *pos;
+
+       if (!fmt)
+               return ERR_PTR(-EINVAL);
+
        list_for_each_entry(pos, &trace_bprintk_fmt_list, list) {
                if (!strcmp(pos->fmt, fmt))
                        return pos;
@@ -57,7 +61,8 @@ void hold_module_trace_bprintk_format(const char **start, const char **end)
        for (iter = start; iter < end; iter++) {
                struct trace_bprintk_fmt *tb_fmt = lookup_format(*iter);
                if (tb_fmt) {
-                       *iter = tb_fmt->fmt;
+                       if (!IS_ERR(tb_fmt))
+                               *iter = tb_fmt->fmt;
                        continue;
                }
 
@@ -178,6 +183,12 @@ static inline void format_mod_start(void) { }
 static inline void format_mod_stop(void) { }
 #endif /* CONFIG_MODULES */
 
+static bool __read_mostly trace_printk_enabled = true;
+
+void trace_printk_control(bool enabled)
+{
+       trace_printk_enabled = enabled;
+}
 
 __initdata_or_module static
 struct notifier_block module_trace_bprintk_format_nb = {
@@ -192,7 +203,7 @@ int __trace_bprintk(unsigned long ip, const char *fmt, ...)
        if (unlikely(!fmt))
                return 0;
 
-       if (!(trace_flags & TRACE_ITER_PRINTK))
+       if (!trace_printk_enabled)
                return 0;
 
        va_start(ap, fmt);
@@ -207,7 +218,7 @@ int __ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap)
        if (unlikely(!fmt))
                return 0;
 
-       if (!(trace_flags & TRACE_ITER_PRINTK))
+       if (!trace_printk_enabled)
                return 0;
 
        return trace_vbprintk(ip, fmt, ap);
@@ -219,7 +230,7 @@ int __trace_printk(unsigned long ip, const char *fmt, ...)
        int ret;
        va_list ap;
 
-       if (!(trace_flags & TRACE_ITER_PRINTK))
+       if (!trace_printk_enabled)
                return 0;
 
        va_start(ap, fmt);
@@ -231,7 +242,7 @@ EXPORT_SYMBOL_GPL(__trace_printk);
 
 int __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap)
 {
-       if (!(trace_flags & TRACE_ITER_PRINTK))
+       if (!trace_printk_enabled)
                return 0;
 
        return trace_vprintk(ip, fmt, ap);
@@ -267,6 +278,7 @@ static const char **find_next(void *v, loff_t *pos)
        if (*pos < last_index + start_index)
                return __start___tracepoint_str + (*pos - last_index);
 
+       start_index += last_index;
        return find_next_mod_format(start_index, v, fmt, pos);
 }
 
@@ -289,6 +301,9 @@ static int t_show(struct seq_file *m, void *v)
        const char *str = *fmt;
        int i;
 
+       if (!*fmt)
+               return 0;
+
        seq_printf(m, "0x%lx : \"", *(unsigned long *)fmt);
 
        /*