All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hauke Mehrtens <hauke@hauke-m.de>
To: johannes@sipsolutions.net
Cc: backports@vger.kernel.org, Hauke Mehrtens <hauke@hauke-m.de>
Subject: [PATCH 11/21] backport: add __print_array()
Date: Tue, 22 Aug 2017 00:28:07 +0200	[thread overview]
Message-ID: <20170821222817.17376-12-hauke@hauke-m.de> (raw)
In-Reply-To: <20170821222817.17376-1-hauke@hauke-m.de>

This is used in the tracing system and needed by wireless now, it was
introduced in commit 6ea22486ba46bc ("tracing: Add array printing
helper").
This code is copied from kernel 4.0.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 backport/backport-include/linux/ftrace_event.h | 10 ++++++
 backport/backport-include/trace/ftrace.h       |  9 +++++
 backport/compat/backport-4.0.c                 | 46 ++++++++++++++++++++++++++
 3 files changed, 65 insertions(+)
 create mode 100644 backport/backport-include/linux/ftrace_event.h
 create mode 100644 backport/backport-include/trace/ftrace.h

diff --git a/backport/backport-include/linux/ftrace_event.h b/backport/backport-include/linux/ftrace_event.h
new file mode 100644
index 00000000..edea21ee
--- /dev/null
+++ b/backport/backport-include/linux/ftrace_event.h
@@ -0,0 +1,10 @@
+#ifndef __BACKPORT_LINUX_FTRACE_EVENT_H
+#define __BACKPORT_LINUX_FTRACE_EVENT_H
+#include_next <linux/ftrace_event.h>
+
+#if LINUX_VERSION_IS_LESS(4,0,0)
+const char *ftrace_print_array_seq(struct trace_seq *p,
+				   const void *buf, int buf_len,
+				   size_t el_size);
+#endif
+#endif /* __BACKPORT_LINUX_FTRACE_EVENT_H */
diff --git a/backport/backport-include/trace/ftrace.h b/backport/backport-include/trace/ftrace.h
new file mode 100644
index 00000000..5fda0ce5
--- /dev/null
+++ b/backport/backport-include/trace/ftrace.h
@@ -0,0 +1,9 @@
+#undef __print_array
+#define __print_array(array, count, el_size)				\
+	({								\
+		BUILD_BUG_ON(el_size != 1 && el_size != 2 &&		\
+			     el_size != 4 && el_size != 8);		\
+		ftrace_print_array_seq(p, array, count, el_size);	\
+	})
+
+#include_next <trace/ftrace.h>
diff --git a/backport/compat/backport-4.0.c b/backport/compat/backport-4.0.c
index 8ae16115..71095f19 100644
--- a/backport/compat/backport-4.0.c
+++ b/backport/compat/backport-4.0.c
@@ -14,6 +14,8 @@
 #include <linux/ctype.h>
 #include <linux/printk.h>
 #include <linux/export.h>
+#include <linux/trace_seq.h>
+#include <linux/ftrace_event.h>
 #include <asm/unaligned.h>
 
 static __always_inline long __get_user_pages_locked(struct task_struct *tsk,
@@ -321,3 +323,47 @@ overflow1:
 	return ascii ? ascii_column + len : (groupsize * 2 + 1) * ngroups - 1;
 }
 EXPORT_SYMBOL_GPL(hex_dump_to_buffer);
+
+const char *
+ftrace_print_array_seq(struct trace_seq *p, const void *buf, int buf_len,
+		       size_t el_size)
+{
+	const char *ret = trace_seq_buffer_ptr(p);
+	const char *prefix = "";
+	void *ptr = (void *)buf;
+
+	trace_seq_putc(p, '{');
+
+	while (ptr < buf + buf_len) {
+		switch (el_size) {
+		case 1:
+			trace_seq_printf(p, "%s0x%x", prefix,
+					 *(u8 *)ptr);
+			break;
+		case 2:
+			trace_seq_printf(p, "%s0x%x", prefix,
+					 *(u16 *)ptr);
+			break;
+		case 4:
+			trace_seq_printf(p, "%s0x%x", prefix,
+					 *(u32 *)ptr);
+			break;
+		case 8:
+			trace_seq_printf(p, "%s0x%llx", prefix,
+					 *(u64 *)ptr);
+			break;
+		default:
+			trace_seq_printf(p, "BAD SIZE:%zu 0x%x", el_size,
+					 *(u8 *)ptr);
+			el_size = 1;
+		}
+		prefix = ",";
+		ptr += el_size;
+	}
+
+	trace_seq_putc(p, '}');
+	trace_seq_putc(p, 0);
+
+	return ret;
+}
+EXPORT_SYMBOL(ftrace_print_array_seq);
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe backports" in

  parent reply	other threads:[~2017-08-21 22:28 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-21 22:27 [PATCH 00/21] backports: multiple changes for kernel 3.13-rc6 Hauke Mehrtens
2017-08-21 22:27 ` [PATCH 01/21] copy: do not copy files removed in kernel 4.13 Hauke Mehrtens
2017-09-06 14:56   ` Johannes Berg
2017-08-21 22:27 ` [PATCH 02/21] patches: header fix for st-nci not needed any more Hauke Mehrtens
2017-08-21 22:27 ` [PATCH 03/21] header: skbuff: add skb_put_zero(), skb_put_data() and skb_put_u8() Hauke Mehrtens
2017-08-21 22:28 ` [PATCH 04/21] header: skbuff: fix signature of skb_put(), skb_push() and () Hauke Mehrtens
2017-08-21 22:28 ` [PATCH 05/21] header: backport mii_ethtool_{get,set}_link_ksettings() Hauke Mehrtens
2017-08-21 22:28 ` [PATCH 06/21] patches: adapt the stat64 usage for usbnet Hauke Mehrtens
2017-08-21 22:28 ` [PATCH 07/21] header: add module_param_hw_array() Hauke Mehrtens
2017-09-06 15:00   ` Johannes Berg
2017-08-21 22:28 ` [PATCH 08/21] header: backport devm_acpi_dev_add_driver_gpios() Hauke Mehrtens
2017-09-06 15:01   ` Johannes Berg
2017-09-06 21:58     ` Hauke Mehrtens
2017-09-08  9:25       ` Johannes Berg
2017-09-08  9:28         ` Johannes Berg
2017-08-21 22:28 ` [PATCH 09/21] header: add get_random_u32() Hauke Mehrtens
2017-08-21 22:28 ` [PATCH 10/21] header: rename wait_queue_entry_t to wait_queue_t Hauke Mehrtens
2017-08-21 22:28 ` Hauke Mehrtens [this message]
2017-08-21 22:28 ` [PATCH 12/21] compat: avoid usage of kvzalloc() in rhashtable.c Hauke Mehrtens
2017-09-06 15:05   ` Johannes Berg
2017-09-06 22:12     ` Hauke Mehrtens
2017-09-08  9:25       ` Johannes Berg
2017-08-21 22:28 ` [PATCH 13/21] patch: Allow usage of pci_error_handlers->reset_notify Hauke Mehrtens
2017-08-21 22:28 ` [PATCH 14/21] header: add offsetofend() Hauke Mehrtens
2017-08-21 22:28 ` [PATCH 15/21] dependencies: add deps for struct acpi_gpio_mapping Hauke Mehrtens
2017-08-21 22:28 ` [PATCH 16/21] patches: brcmfmac: fix netdev destructor Hauke Mehrtens
2017-09-06 15:05   ` Johannes Berg
2017-09-07  7:48     ` Arend van Spriel
2017-09-07  9:04       ` compilation errors in ath10k driver with latest backports git KAVITA MATHUR
2017-09-07  9:17         ` Arend van Spriel
2017-09-13 19:36   ` [PATCH 16/21] patches: brcmfmac: fix netdev destructor Arend van Spriel
2017-09-14  7:21     ` Johannes Berg
2017-09-17 22:00       ` Hauke Mehrtens
2017-09-18  7:16         ` Arend van Spriel
2017-08-21 22:28 ` [PATCH 17/21] patches: backport the probe_new for i2c drivers Hauke Mehrtens
2017-08-21 22:28 ` [PATCH 18/21] patches: adapt signature of proto_ops->accept Hauke Mehrtens
2017-08-21 22:28 ` [PATCH 19/21] header: add linux/refcount.h Hauke Mehrtens
2017-08-21 22:28 ` [PATCH 20/21] header: add dma_wmb() Hauke Mehrtens
2017-08-21 22:28 ` [PATCH 21/21] copy-list: add quantenna qtnfmac driver Hauke Mehrtens
2017-09-06 15:10   ` Johannes Berg
2017-09-06 15:13     ` Johannes Berg
2017-09-06 22:14       ` Hauke Mehrtens
2017-09-06 15:14     ` Johannes Berg
2017-09-05  9:00 ` [PATCH 00/21] backports: multiple changes for kernel 3.13-rc6 Johannes Berg
2017-09-05 21:41   ` Hauke Mehrtens
2017-09-06  7:23     ` Johannes Berg
2017-09-13 20:00   ` Arend van Spriel
2017-09-17 22:07     ` Hauke Mehrtens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170821222817.17376-12-hauke@hauke-m.de \
    --to=hauke@hauke-m.de \
    --cc=backports@vger.kernel.org \
    --cc=johannes@sipsolutions.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.