Commit 146a06a0 authored by Benjamin Tissoires's avatar Benjamin Tissoires

HID: rename struct hid_bpf_ops into hid_ops

Those operations are the ones from HID, not HID-BPF, and I'd like to
reuse hid_bpf_ops as the user facing struct_ops API.

Link: https://lore.kernel.org/r/20240608-hid_bpf_struct_ops-v3-1-6ac6ade58329@kernel.orgSigned-off-by: default avatarBenjamin Tissoires <bentiss@kernel.org>
parent 061d1af7
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#include "hid_bpf_dispatch.h" #include "hid_bpf_dispatch.h"
#include "entrypoints/entrypoints.lskel.h" #include "entrypoints/entrypoints.lskel.h"
struct hid_bpf_ops *hid_bpf_ops; struct hid_ops *hid_ops;
EXPORT_SYMBOL(hid_bpf_ops); EXPORT_SYMBOL(hid_ops);
/** /**
* hid_bpf_device_event - Called whenever an event is coming in from the device * hid_bpf_device_event - Called whenever an event is coming in from the device
...@@ -284,13 +284,13 @@ hid_bpf_attach_prog(unsigned int hid_id, int prog_fd, __u32 flags) ...@@ -284,13 +284,13 @@ hid_bpf_attach_prog(unsigned int hid_id, int prog_fd, __u32 flags)
struct device *dev; struct device *dev;
int err, fd; int err, fd;
if (!hid_bpf_ops) if (!hid_ops)
return -EINVAL; return -EINVAL;
if ((flags & ~HID_BPF_FLAG_MASK)) if ((flags & ~HID_BPF_FLAG_MASK))
return -EINVAL; return -EINVAL;
dev = bus_find_device(hid_bpf_ops->bus_type, NULL, &hid_id, device_match_id); dev = bus_find_device(hid_ops->bus_type, NULL, &hid_id, device_match_id);
if (!dev) if (!dev)
return -EINVAL; return -EINVAL;
...@@ -335,10 +335,10 @@ hid_bpf_allocate_context(unsigned int hid_id) ...@@ -335,10 +335,10 @@ hid_bpf_allocate_context(unsigned int hid_id)
struct hid_bpf_ctx_kern *ctx_kern = NULL; struct hid_bpf_ctx_kern *ctx_kern = NULL;
struct device *dev; struct device *dev;
if (!hid_bpf_ops) if (!hid_ops)
return NULL; return NULL;
dev = bus_find_device(hid_bpf_ops->bus_type, NULL, &hid_id, device_match_id); dev = bus_find_device(hid_ops->bus_type, NULL, &hid_id, device_match_id);
if (!dev) if (!dev)
return NULL; return NULL;
...@@ -386,7 +386,7 @@ __hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz, ...@@ -386,7 +386,7 @@ __hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz,
u32 report_len; u32 report_len;
/* check arguments */ /* check arguments */
if (!ctx || !hid_bpf_ops || !buf) if (!ctx || !hid_ops || !buf)
return -EINVAL; return -EINVAL;
switch (rtype) { switch (rtype) {
...@@ -404,7 +404,7 @@ __hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz, ...@@ -404,7 +404,7 @@ __hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz,
hdev = (struct hid_device *)ctx->hid; /* discard const */ hdev = (struct hid_device *)ctx->hid; /* discard const */
report_enum = hdev->report_enum + rtype; report_enum = hdev->report_enum + rtype;
report = hid_bpf_ops->hid_get_report(report_enum, buf); report = hid_ops->hid_get_report(report_enum, buf);
if (!report) if (!report)
return -EINVAL; return -EINVAL;
...@@ -459,7 +459,7 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz, ...@@ -459,7 +459,7 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
if (!dma_data) if (!dma_data)
return -ENOMEM; return -ENOMEM;
ret = hid_bpf_ops->hid_hw_raw_request(hdev, ret = hid_ops->hid_hw_raw_request(hdev,
dma_data[0], dma_data[0],
dma_data, dma_data,
size, size,
...@@ -501,7 +501,7 @@ hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz) ...@@ -501,7 +501,7 @@ hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz)
if (!dma_data) if (!dma_data)
return -ENOMEM; return -ENOMEM;
ret = hid_bpf_ops->hid_hw_output_report(hdev, ret = hid_ops->hid_hw_output_report(hdev,
dma_data, dma_data,
size); size);
...@@ -534,7 +534,7 @@ hid_bpf_input_report(struct hid_bpf_ctx *ctx, enum hid_report_type type, u8 *buf ...@@ -534,7 +534,7 @@ hid_bpf_input_report(struct hid_bpf_ctx *ctx, enum hid_report_type type, u8 *buf
hdev = (struct hid_device *)ctx->hid; /* discard const */ hdev = (struct hid_device *)ctx->hid; /* discard const */
return hid_bpf_ops->hid_input_report(hdev, type, buf, size, 0); return hid_ops->hid_input_report(hdev, type, buf, size, 0);
} }
__bpf_kfunc_end_defs(); __bpf_kfunc_end_defs();
......
...@@ -2970,7 +2970,7 @@ int hid_check_keys_pressed(struct hid_device *hid) ...@@ -2970,7 +2970,7 @@ int hid_check_keys_pressed(struct hid_device *hid)
EXPORT_SYMBOL_GPL(hid_check_keys_pressed); EXPORT_SYMBOL_GPL(hid_check_keys_pressed);
#ifdef CONFIG_HID_BPF #ifdef CONFIG_HID_BPF
static struct hid_bpf_ops hid_ops = { static struct hid_ops __hid_ops = {
.hid_get_report = hid_get_report, .hid_get_report = hid_get_report,
.hid_hw_raw_request = hid_hw_raw_request, .hid_hw_raw_request = hid_hw_raw_request,
.hid_hw_output_report = hid_hw_output_report, .hid_hw_output_report = hid_hw_output_report,
...@@ -2991,7 +2991,7 @@ static int __init hid_init(void) ...@@ -2991,7 +2991,7 @@ static int __init hid_init(void)
} }
#ifdef CONFIG_HID_BPF #ifdef CONFIG_HID_BPF
hid_bpf_ops = &hid_ops; hid_ops = &__hid_ops;
#endif #endif
ret = hidraw_init(); ret = hidraw_init();
...@@ -3010,7 +3010,7 @@ static int __init hid_init(void) ...@@ -3010,7 +3010,7 @@ static int __init hid_init(void)
static void __exit hid_exit(void) static void __exit hid_exit(void)
{ {
#ifdef CONFIG_HID_BPF #ifdef CONFIG_HID_BPF
hid_bpf_ops = NULL; hid_ops = NULL;
#endif #endif
hid_debug_exit(); hid_debug_exit();
hidraw_exit(); hidraw_exit();
......
...@@ -97,7 +97,7 @@ enum hid_bpf_prog_type { ...@@ -97,7 +97,7 @@ enum hid_bpf_prog_type {
struct hid_report_enum; struct hid_report_enum;
struct hid_bpf_ops { struct hid_ops {
struct hid_report *(*hid_get_report)(struct hid_report_enum *report_enum, const u8 *data); struct hid_report *(*hid_get_report)(struct hid_report_enum *report_enum, const u8 *data);
int (*hid_hw_raw_request)(struct hid_device *hdev, int (*hid_hw_raw_request)(struct hid_device *hdev,
unsigned char reportnum, __u8 *buf, unsigned char reportnum, __u8 *buf,
...@@ -110,7 +110,7 @@ struct hid_bpf_ops { ...@@ -110,7 +110,7 @@ struct hid_bpf_ops {
const struct bus_type *bus_type; const struct bus_type *bus_type;
}; };
extern struct hid_bpf_ops *hid_bpf_ops; extern struct hid_ops *hid_ops;
struct hid_bpf_prog_list { struct hid_bpf_prog_list {
u16 prog_idx[HID_BPF_MAX_PROGS_PER_DEV]; u16 prog_idx[HID_BPF_MAX_PROGS_PER_DEV];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment