Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: bpf/dispatch: regroup kfuncs definitions

No code change, just move down the hid_bpf_get_data() kfunc definition
so we have only one block of __bpf_kfunc_start/end_defs()

Link: https://lore.kernel.org/r/20240315-b4-hid-bpf-new-funcs-v4-1-079c282469d3@kernel.org
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>

+38 -42
+38 -42
drivers/hid/bpf/hid_bpf_dispatch.c
··· 143 143 } 144 144 EXPORT_SYMBOL_GPL(call_hid_bpf_rdesc_fixup); 145 145 146 - /* Disables missing prototype warnings */ 147 - __bpf_kfunc_start_defs(); 148 - 149 - /** 150 - * hid_bpf_get_data - Get the kernel memory pointer associated with the context @ctx 151 - * 152 - * @ctx: The HID-BPF context 153 - * @offset: The offset within the memory 154 - * @rdwr_buf_size: the const size of the buffer 155 - * 156 - * @returns %NULL on error, an %__u8 memory pointer on success 157 - */ 158 - __bpf_kfunc __u8 * 159 - hid_bpf_get_data(struct hid_bpf_ctx *ctx, unsigned int offset, const size_t rdwr_buf_size) 160 - { 161 - struct hid_bpf_ctx_kern *ctx_kern; 162 - 163 - if (!ctx) 164 - return NULL; 165 - 166 - ctx_kern = container_of(ctx, struct hid_bpf_ctx_kern, ctx); 167 - 168 - if (rdwr_buf_size + offset > ctx->allocated_size) 169 - return NULL; 170 - 171 - return ctx_kern->data + offset; 172 - } 173 - __bpf_kfunc_end_defs(); 174 - 175 - /* 176 - * The following set contains all functions we agree BPF programs 177 - * can use. 178 - */ 179 - BTF_KFUNCS_START(hid_bpf_kfunc_ids) 180 - BTF_ID_FLAGS(func, hid_bpf_get_data, KF_RET_NULL) 181 - BTF_KFUNCS_END(hid_bpf_kfunc_ids) 182 - 183 - static const struct btf_kfunc_id_set hid_bpf_kfunc_set = { 184 - .owner = THIS_MODULE, 185 - .set = &hid_bpf_kfunc_ids, 186 - }; 187 - 188 146 static int device_match_id(struct device *dev, const void *id) 189 147 { 190 148 struct hid_device *hdev = to_hid_device(dev); ··· 238 280 239 281 /* Disables missing prototype warnings */ 240 282 __bpf_kfunc_start_defs(); 283 + 284 + /** 285 + * hid_bpf_get_data - Get the kernel memory pointer associated with the context @ctx 286 + * 287 + * @ctx: The HID-BPF context 288 + * @offset: The offset within the memory 289 + * @rdwr_buf_size: the const size of the buffer 290 + * 291 + * @returns %NULL on error, an %__u8 memory pointer on success 292 + */ 293 + __bpf_kfunc __u8 * 294 + hid_bpf_get_data(struct hid_bpf_ctx *ctx, unsigned int offset, const size_t rdwr_buf_size) 295 + { 296 + struct hid_bpf_ctx_kern *ctx_kern; 297 + 298 + if (!ctx) 299 + return NULL; 300 + 301 + ctx_kern = container_of(ctx, struct hid_bpf_ctx_kern, ctx); 302 + 303 + if (rdwr_buf_size + offset > ctx->allocated_size) 304 + return NULL; 305 + 306 + return ctx_kern->data + offset; 307 + } 241 308 242 309 /** 243 310 * hid_bpf_attach_prog - Attach the given @prog_fd to the given HID device ··· 456 473 return ret; 457 474 } 458 475 __bpf_kfunc_end_defs(); 476 + 477 + /* 478 + * The following set contains all functions we agree BPF programs 479 + * can use. 480 + */ 481 + BTF_KFUNCS_START(hid_bpf_kfunc_ids) 482 + BTF_ID_FLAGS(func, hid_bpf_get_data, KF_RET_NULL) 483 + BTF_KFUNCS_END(hid_bpf_kfunc_ids) 484 + 485 + static const struct btf_kfunc_id_set hid_bpf_kfunc_set = { 486 + .owner = THIS_MODULE, 487 + .set = &hid_bpf_kfunc_ids, 488 + }; 459 489 460 490 /* our HID-BPF entrypoints */ 461 491 BTF_SET8_START(hid_bpf_fmodret_ids)