summaryrefslogtreecommitdiff
path: root/samples/hid/hid_surface_dial.bpf.c
diff options
context:
space:
mode:
authorBenjamin Tissoires <bentiss@kernel.org>2024-06-08 11:01:17 +0200
committerBenjamin Tissoires <bentiss@kernel.org>2024-06-14 11:20:20 +0200
commite342d6f6f7d82b48c4540b947d8032a3b7b3e6f8 (patch)
tree908cb6c954eef7a2dea1012b642e3f88c0ded633 /samples/hid/hid_surface_dial.bpf.c
parentd7696738d66b4f1379fe77eef61cd1047d7f0773 (diff)
downloadlinux-next-e342d6f6f7d82b48c4540b947d8032a3b7b3e6f8.tar.gz
linux-next-e342d6f6f7d82b48c4540b947d8032a3b7b3e6f8.zip
HID: samples: convert the 2 HID-BPF samples into struct_ops
This is mostly mechanical: attach_prog is dropped, and the SEC are converted into struct_ops. Link: https://lore.kernel.org/r/20240608-hid_bpf_struct_ops-v3-5-6ac6ade58329@kernel.org Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
Diffstat (limited to 'samples/hid/hid_surface_dial.bpf.c')
-rw-r--r--samples/hid/hid_surface_dial.bpf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/samples/hid/hid_surface_dial.bpf.c b/samples/hid/hid_surface_dial.bpf.c
index 1f80478c0918..d8d0fb07391f 100644
--- a/samples/hid/hid_surface_dial.bpf.c
+++ b/samples/hid/hid_surface_dial.bpf.c
@@ -10,7 +10,7 @@
#define HID_UP_BUTTON 0x0009
#define HID_GD_WHEEL 0x0038
-SEC("fmod_ret/hid_bpf_device_event")
+SEC("struct_ops/device_event")
int BPF_PROG(hid_event, struct hid_bpf_ctx *hctx)
{
__u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 9 /* size */);
@@ -101,7 +101,7 @@ int set_haptic(struct haptic_syscall_args *args)
}
/* Convert REL_DIAL into REL_WHEEL */
-SEC("fmod_ret/hid_bpf_rdesc_fixup")
+SEC("struct_ops/rdesc_fixup")
int BPF_PROG(hid_rdesc_fixup, struct hid_bpf_ctx *hctx)
{
__u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 4096 /* size */);
@@ -130,5 +130,11 @@ int BPF_PROG(hid_rdesc_fixup, struct hid_bpf_ctx *hctx)
return 0;
}
+SEC(".struct_ops.link")
+struct hid_bpf_ops surface_dial = {
+ .rdesc_fixup = (void *)hid_rdesc_fixup,
+ .device_event = (void *)hid_event,
+};
+
char _license[] SEC("license") = "GPL";
u32 _version SEC("version") = 1;