]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
HID: bpf: convert in-tree fixes into struct_ops
authorBenjamin Tissoires <bentiss@kernel.org>
Sat, 8 Jun 2024 09:01:19 +0000 (11:01 +0200)
committerBenjamin Tissoires <bentiss@kernel.org>
Fri, 14 Jun 2024 09:20:20 +0000 (11:20 +0200)
Very mechanical:
- Change HID_BPF_DEVICE_EVENT and HID_BPF_RDESC_FIXUP #defines
- add a matching SEC(".struct_ops.link")
- in ArtistPro16Gen2 make the 2 functions static and have a new one
  calling them

Link: https://lore.kernel.org/r/20240608-hid_bpf_struct_ops-v3-7-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 2c2c1637ade8fedf4a7e30189e3b0cea3c7bbb7a..caec91391d32817e37eb32e3ab841ba7acb89e11 100644 (file)
@@ -168,6 +168,11 @@ int BPF_PROG(raptor_mach_2_fix_hat_switch, struct hid_bpf_ctx *hctx)
        return 0;
 }
 
+HID_BPF_OPS(raptor_mach_2) = {
+       .hid_rdesc_fixup = (void *)hid_fix_rdesc_raptor_mach_2,
+       .hid_device_event = (void *)raptor_mach_2_fix_hat_switch,
+};
+
 SEC("syscall")
 int probe(struct hid_bpf_probe_args *ctx)
 {
index 17fc55f6f02cf24f0f512fb4776f6eca6fe7af1c..c2413fa8054340f2f13a9f9354ddd5a98e279467 100644 (file)
@@ -45,6 +45,10 @@ int BPF_PROG(hid_fix_rdesc, struct hid_bpf_ctx *hctx)
        return 0;
 }
 
+HID_BPF_OPS(hp_elite_presenter) = {
+       .hid_rdesc_fixup = (void *)hid_fix_rdesc,
+};
+
 SEC("syscall")
 int probe(struct hid_bpf_probe_args *ctx)
 {
index 24b8a5aa05f3691cb08ad2d3a7baf28b20bb6ffe..a4a4f324aedd5658bb9b5114b2513d37ed719c0f 100644 (file)
@@ -255,6 +255,11 @@ int BPF_PROG(kamvas_pro_19_fix_3rd_button, struct hid_bpf_ctx *hctx)
        return 0;
 }
 
+HID_BPF_OPS(huion_Kamvas_pro_19) = {
+       .hid_rdesc_fixup = (void *)hid_fix_rdesc_huion_kamvas_pro_19,
+       .hid_device_event = (void *)kamvas_pro_19_fix_3rd_button,
+};
+
 SEC("syscall")
 int probe(struct hid_bpf_probe_args *ctx)
 {
index bee37872ee8c58edb207db78daffcdcc6d2adc9e..82f1950445ddec52668e171bf9ff86dfc7063074 100644 (file)
@@ -45,6 +45,10 @@ int BPF_PROG(hid_fix_rdesc, struct hid_bpf_ctx *hctx)
        return 0;
 }
 
+HID_BPF_OPS(iogear_kaliber_momentum) = {
+       .hid_rdesc_fixup = (void *)hid_fix_rdesc,
+};
+
 SEC("syscall")
 int probe(struct hid_bpf_probe_args *ctx)
 {
index f9ad33f4a373de95bbe02642f8ddb350421497f3..70b16edfb59a820b8d829d74e60162380d280e86 100644 (file)
@@ -114,6 +114,10 @@ int BPF_PROG(hid_fix_rdesc, struct hid_bpf_ctx *hctx)
        return 0;
 }
 
+HID_BPF_OPS(xbox_elite_2) = {
+       .hid_rdesc_fixup = (void *)hid_fix_rdesc,
+};
+
 SEC("syscall")
 int probe(struct hid_bpf_probe_args *ctx)
 {
index 39d77c5e91727f4887532db63455e9c08c220155..2da680bc4e111cf8b63167a768d8cbad241f3506 100644 (file)
@@ -139,6 +139,10 @@ int BPF_PROG(artpen_pressure_interpolate, struct hid_bpf_ctx *hctx)
        return 0;
 }
 
+HID_BPF_OPS(wacom_artpen) = {
+       .hid_device_event = (void *)artpen_pressure_interpolate,
+};
+
 SEC("syscall")
 int probe(struct hid_bpf_probe_args *ctx)
 {
index c938808bd589e97c13b24eba02d02c4802daaea5..bc0b85c38445813e4392b2167111fe124c977d31 100644 (file)
@@ -209,6 +209,11 @@ int BPF_PROG(xppen_24_fix_eraser, struct hid_bpf_ctx *hctx)
        return 0;
 }
 
+HID_BPF_OPS(xppen_artist_24) = {
+       .hid_rdesc_fixup = (void *)hid_fix_rdesc_xppen_artist24,
+       .hid_device_event = (void *)xppen_24_fix_eraser,
+};
+
 SEC("syscall")
 int probe(struct hid_bpf_probe_args *ctx)
 {
index 77ef8b95d52e60b419f0cce02685c9556de5d223..a669525691aae1c354259cb3276cc3bb406bf529 100644 (file)
@@ -105,8 +105,7 @@ int BPF_PROG(hid_fix_rdesc_xppen_artistpro16gen2, struct hid_bpf_ctx *hctx)
        return sizeof(fixed_rdesc);
 }
 
-SEC(HID_BPF_DEVICE_EVENT)
-int BPF_PROG(xppen_16_fix_eraser, struct hid_bpf_ctx *hctx)
+static int xppen_16_fix_eraser(struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 10 /* size */);
 
@@ -207,8 +206,7 @@ static void compensate_coordinates_by_tilt(__u8 *data, const __u8 idx,
        data[idx+1] = coords >> 8;
 }
 
-SEC(HID_BPF_DEVICE_EVENT)
-int BPF_PROG(xppen_16_fix_angle_offset, struct hid_bpf_ctx *hctx)
+static int xppen_16_fix_angle_offset(struct hid_bpf_ctx *hctx)
 {
        __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 10 /* size */);
 
@@ -254,6 +252,22 @@ int BPF_PROG(xppen_16_fix_angle_offset, struct hid_bpf_ctx *hctx)
        return 0;
 }
 
+SEC(HID_BPF_DEVICE_EVENT)
+int BPF_PROG(xppen_artist_pro_16_device_event, struct hid_bpf_ctx *hctx)
+{
+       int ret = xppen_16_fix_angle_offset(hctx);
+
+       if (ret)
+               return ret;
+
+       return xppen_16_fix_eraser(hctx);
+}
+
+HID_BPF_OPS(xppen_artist_pro_16) = {
+       .hid_rdesc_fixup = (void *)hid_fix_rdesc_xppen_artistpro16gen2,
+       .hid_device_event = (void *)xppen_artist_pro_16_device_event,
+};
+
 SEC("syscall")
 int probe(struct hid_bpf_probe_args *ctx)
 {
index 1970faf84310f76ea895e4b00a2bf358e50d90e8..8c1cd9e25bc3965a55861ba1b80807a15bfb734e 100644 (file)
@@ -5,8 +5,10 @@
 #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"
+#define HID_BPF_DEVICE_EVENT "struct_ops/hid_device_event"
+#define HID_BPF_RDESC_FIXUP  "struct_ops/hid_rdesc_fixup"
+#define HID_BPF_OPS(name) SEC(".struct_ops.link") \
+       struct hid_bpf_ops name
 
 struct hid_bpf_probe_args {
        unsigned int hid;