]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
HID: bpf: add defines for HID-BPF SEC in in-tree bpf fixes
authorBenjamin Tissoires <bentiss@kernel.org>
Sat, 8 Jun 2024 09:01:18 +0000 (11:01 +0200)
committerBenjamin Tissoires <bentiss@kernel.org>
Fri, 14 Jun 2024 09:20:20 +0000 (11:20 +0200)
We are going to switch over struct_ops, so instead of having to manually
replace all fields one by one, let's have a common place to change it.

Link: https://lore.kernel.org/r/20240608-hid_bpf_struct_ops-v3-6-6ac6ade58329@kernel.org
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
drivers/hid/bpf/progs/FR-TEC__Raptor-Mach-2.bpf.c
drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c
drivers/hid/bpf/progs/Huion__Kamvas-Pro-19.bpf.c
drivers/hid/bpf/progs/IOGEAR__Kaliber-MMOmentum.bpf.c
drivers/hid/bpf/progs/Microsoft__XBox-Elite-2.bpf.c
drivers/hid/bpf/progs/Wacom__ArtPen.bpf.c
drivers/hid/bpf/progs/XPPen__Artist24.bpf.c
drivers/hid/bpf/progs/XPPen__ArtistPro16Gen2.bpf.c
drivers/hid/bpf/progs/hid_bpf.h

index dc26a7677d364acfd2d1c47b0ee56e315d8d826c..2c2c1637ade8fedf4a7e30189e3b0cea3c7bbb7a 100644 (file)
@@ -133,7 +133,7 @@ HID_BPF_CONFIG(
  *   integer. We thus divide it by 30 to match what other joysticks are
  *   doing
  */
-SEC("fmod_ret/hid_bpf_rdesc_fixup")
+SEC(HID_BPF_RDESC_FIXUP)
 int BPF_PROG(hid_fix_rdesc_raptor_mach_2, struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, HID_MAX_DESCRIPTOR_SIZE /* size */);
@@ -152,7 +152,7 @@ int BPF_PROG(hid_fix_rdesc_raptor_mach_2, struct hid_bpf_ctx *hctx)
  * divide it by 30.
  * Byte 34 is always null, so it is ignored.
  */
-SEC("fmod_ret/hid_bpf_device_event")
+SEC(HID_BPF_DEVICE_EVENT)
 int BPF_PROG(raptor_mach_2_fix_hat_switch, struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 64 /* size */);
index 3d14bbb6f2762dbfe03331277f0d6701d30f3155..17fc55f6f02cf24f0f512fb4776f6eca6fe7af1c 100644 (file)
@@ -30,7 +30,7 @@ HID_BPF_CONFIG(
  * pointer.
  */
 
-SEC("fmod_ret/hid_bpf_rdesc_fixup")
+SEC(HID_BPF_RDESC_FIXUP)
 int BPF_PROG(hid_fix_rdesc, struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 4096 /* size */);
index ff759f2276f980db48281933ae63213dc77c9b71..24b8a5aa05f3691cb08ad2d3a7baf28b20bb6ffe 100644 (file)
@@ -191,7 +191,7 @@ static const __u8 fixed_rdesc[] = {
        0xc0,                          // End Collection                      327
 };
 
-SEC("fmod_ret/hid_bpf_rdesc_fixup")
+SEC(HID_BPF_RDESC_FIXUP)
 int BPF_PROG(hid_fix_rdesc_huion_kamvas_pro_19, struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, HID_MAX_DESCRIPTOR_SIZE /* size */);
@@ -215,7 +215,7 @@ int BPF_PROG(hid_fix_rdesc_huion_kamvas_pro_19, struct hid_bpf_ctx *hctx)
  * - if there was this out-of-proximity event, we are entering
  *   eraser mode, and we will until the next out-of-proximity.
  */
-SEC("fmod_ret/hid_bpf_device_event")
+SEC(HID_BPF_DEVICE_EVENT)
 int BPF_PROG(kamvas_pro_19_fix_3rd_button, struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 10 /* size */);
index 225cbefdbf0e5a2c23307d27565d149d01d6f2ea..bee37872ee8c58edb207db78daffcdcc6d2adc9e 100644 (file)
@@ -21,7 +21,7 @@ HID_BPF_CONFIG(
  * We just fix the report descriptor to enable those missing 7 buttons.
  */
 
-SEC("fmod_ret/hid_bpf_rdesc_fixup")
+SEC(HID_BPF_RDESC_FIXUP)
 int BPF_PROG(hid_fix_rdesc, struct hid_bpf_ctx *hctx)
 {
        const u8 offsets[] = {84, 112, 140};
index c04abecab8ee9bda4cd3e6048b6f3a291cc7f0bf..f9ad33f4a373de95bbe02642f8ddb350421497f3 100644 (file)
@@ -93,7 +93,7 @@ _Static_assert(sizeof(rdesc_assign_selection) == sizeof(fixed_rdesc_assign_selec
 _Static_assert(sizeof(rdesc_assign_selection) + OFFSET_ASSIGN_SELECTION < ORIGINAL_RDESC_SIZE,
               "Rdesc at given offset is too big");
 
-SEC("fmod_ret/hid_bpf_rdesc_fixup")
+SEC(HID_BPF_RDESC_FIXUP)
 int BPF_PROG(hid_fix_rdesc, struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 4096 /* size */);
index dc05aa48faa7504b8691c7547eef73d207682ef2..39d77c5e91727f4887532db63455e9c08c220155 100644 (file)
@@ -101,7 +101,7 @@ static inline __u8 *get_u8(__u8 *data, unsigned int offset)
        return (__u8 *)get_bits(data, offset);
 }
 
-SEC("fmod_ret/hid_bpf_device_event")
+SEC(HID_BPF_DEVICE_EVENT)
 int BPF_PROG(artpen_pressure_interpolate, struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, PEN_REPORT_LEN /* size */);
index e1be6a12bb75872370963fdd5b554fda28f1c976..c938808bd589e97c13b24eba02d02c4802daaea5 100644 (file)
@@ -91,7 +91,7 @@ static const __u8 fixed_rdesc[] = {
 
 #define U16(index) (data[index] | (data[index + 1] << 8))
 
-SEC("fmod_ret/hid_bpf_rdesc_fixup")
+SEC(HID_BPF_RDESC_FIXUP)
 int BPF_PROG(hid_fix_rdesc_xppen_artist24, struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 4096 /* size */);
@@ -152,7 +152,7 @@ static __u8 prev_state = 0;
  *     E: TipSwitch                     InRange
  *
  */
-SEC("fmod_ret/hid_bpf_device_event")
+SEC(HID_BPF_DEVICE_EVENT)
 int BPF_PROG(xppen_24_fix_eraser, struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 10 /* size */);
index 65ef10036126e72f1c3bd2de829a0a75e965cbe4..77ef8b95d52e60b419f0cce02685c9556de5d223 100644 (file)
@@ -82,7 +82,7 @@ static const __u8 fixed_rdesc[] = {
        0xc0,                          // End Collection                      112
 };
 
-SEC("fmod_ret/hid_bpf_rdesc_fixup")
+SEC(HID_BPF_RDESC_FIXUP)
 int BPF_PROG(hid_fix_rdesc_xppen_artistpro16gen2, struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 4096 /* size */);
@@ -105,7 +105,7 @@ int BPF_PROG(hid_fix_rdesc_xppen_artistpro16gen2, struct hid_bpf_ctx *hctx)
        return sizeof(fixed_rdesc);
 }
 
-SEC("fmod_ret/hid_bpf_device_event")
+SEC(HID_BPF_DEVICE_EVENT)
 int BPF_PROG(xppen_16_fix_eraser, struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 10 /* size */);
@@ -207,7 +207,7 @@ static void compensate_coordinates_by_tilt(__u8 *data, const __u8 idx,
        data[idx+1] = coords >> 8;
 }
 
-SEC("fmod_ret/hid_bpf_device_event")
+SEC(HID_BPF_DEVICE_EVENT)
 int BPF_PROG(xppen_16_fix_angle_offset, struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 10 /* size */);
index 7ee371cac2e149d95982f9f84c052711c1573c70..1970faf84310f76ea895e4b00a2bf358e50d90e8 100644 (file)
@@ -5,6 +5,9 @@
 #ifndef ____HID_BPF__H
 #define ____HID_BPF__H
 
+#define HID_BPF_DEVICE_EVENT "fmod_ret/hid_bpf_device_event"
+#define HID_BPF_RDESC_FIXUP  "fmod_ret/hid_bpf_rdesc_fixup"
+
 struct hid_bpf_probe_args {
        unsigned int hid;
        unsigned int rdesc_size;