Commit df67602f authored by Benjamin Tissoires's avatar Benjamin Tissoires
Browse files

HID: bpf: add defines for HID-BPF SEC in in-tree bpf fixes

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: default avatarBenjamin Tissoires <bentiss@kernel.org>
parent e342d6f6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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 */);
+1 −1
Original line number Diff line number Diff line
@@ -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 */);
+2 −2
Original line number Diff line number Diff line
@@ -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 */);
+1 −1
Original line number Diff line number Diff line
@@ -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};
+1 −1
Original line number Diff line number Diff line
@@ -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 */);
Loading