aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/test_lirc_mode2_kern.c
diff options
context:
space:
mode:
authorJiong Wang <jiong.wang@netronome.com>2019-02-11 12:01:20 +0000
committerAlexei Starovoitov <ast@kernel.org>2019-02-11 20:31:38 -0800
commitbd4aed0ee73ca873bef3cb3ec746dd796f03df28 (patch)
tree1dcd4de735f8ca3dbf672dc5d48d064ea1dea5dc /tools/testing/selftests/bpf/progs/test_lirc_mode2_kern.c
parentselftests: bpf: extend sub-register mode compilation to all bpf object files (diff)
downloadlinux-dev-bd4aed0ee73ca873bef3cb3ec746dd796f03df28.tar.xz
linux-dev-bd4aed0ee73ca873bef3cb3ec746dd796f03df28.zip
selftests: bpf: centre kernel bpf objects under new subdir "progs"
At the moment, all kernel bpf objects are listed under BPF_OBJ_FILES. Listing them manually sometimes causing patch conflict when people are adding new testcases simultaneously. It is better to centre all the related source files under a subdir "progs", then auto-generate the object file list. Suggested-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: Jiong Wang <jiong.wang@netronome.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_lirc_mode2_kern.c')
-rw-r--r--tools/testing/selftests/bpf/progs/test_lirc_mode2_kern.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_lirc_mode2_kern.c b/tools/testing/selftests/bpf/progs/test_lirc_mode2_kern.c
new file mode 100644
index 000000000000..4147130cc3b7
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/test_lirc_mode2_kern.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+// test ir decoder
+//
+// Copyright (C) 2018 Sean Young <sean@mess.org>
+
+#include <linux/bpf.h>
+#include <linux/lirc.h>
+#include "bpf_helpers.h"
+
+SEC("lirc_mode2")
+int bpf_decoder(unsigned int *sample)
+{
+ if (LIRC_IS_PULSE(*sample)) {
+ unsigned int duration = LIRC_VALUE(*sample);
+
+ if (duration & 0x10000)
+ bpf_rc_keydown(sample, 0x40, duration & 0xffff, 0);
+ if (duration & 0x20000)
+ bpf_rc_pointer_rel(sample, (duration >> 8) & 0xff,
+ duration & 0xff);
+ }
+
+ return 0;
+}
+
+char _license[] SEC("license") = "GPL";