Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/hid: ensure CKI can compile our new tests on old kernels

In the same way than commit ae7487d112cf ("selftests/hid: ensure we can
compile the tests on kernels pre-6.3") we should expose struct hid_bpf_ops
when it's not available in vmlinux.h.

So unexpose an eventual struct hid_bpf_ops, include vmlinux.h, and
re-export struct hid_bpf_ops.

Fixes: d7696738d66b ("selftests/hid: convert the hid_bpf selftests with struct_ops")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202406270328.bscLN1IF-lkp@intel.com/
Link: https://patch.msgid.link/20240701-fix-cki-v2-1-20564e2e1393@kernel.org
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>

+16
+16
tools/testing/selftests/hid/progs/hid_bpf_helpers.h
··· 7 7 8 8 /* "undefine" structs and enums in vmlinux.h, because we "override" them below */ 9 9 #define hid_bpf_ctx hid_bpf_ctx___not_used 10 + #define hid_bpf_ops hid_bpf_ops___not_used 10 11 #define hid_report_type hid_report_type___not_used 11 12 #define hid_class_request hid_class_request___not_used 12 13 #define hid_bpf_attach_flags hid_bpf_attach_flags___not_used ··· 25 24 #include "vmlinux.h" 26 25 27 26 #undef hid_bpf_ctx 27 + #undef hid_bpf_ops 28 28 #undef hid_report_type 29 29 #undef hid_class_request 30 30 #undef hid_bpf_attach_flags ··· 68 66 HID_REQ_SET_REPORT = 0x09, 69 67 HID_REQ_SET_IDLE = 0x0A, 70 68 HID_REQ_SET_PROTOCOL = 0x0B, 69 + }; 70 + 71 + struct hid_bpf_ops { 72 + int hid_id; 73 + u32 flags; 74 + struct list_head list; 75 + int (*hid_device_event)(struct hid_bpf_ctx *ctx, enum hid_report_type report_type, 76 + u64 source); 77 + int (*hid_rdesc_fixup)(struct hid_bpf_ctx *ctx); 78 + int (*hid_hw_request)(struct hid_bpf_ctx *ctx, unsigned char reportnum, 79 + enum hid_report_type rtype, enum hid_class_request reqtype, 80 + u64 source); 81 + int (*hid_hw_output_report)(struct hid_bpf_ctx *ctx, u64 source); 82 + struct hid_device *hdev; 71 83 }; 72 84 73 85 #ifndef BPF_F_BEFORE