Skip to content

Commit 0b1b0c1

Browse files
t-8chBenjamin Tissoires
authored andcommitted
HID: bpf: drop unneeded casts discarding const
In commit 33c0fb8 ("HID: bpf: make part of struct hid_device writable") the const qualifier was dropped from struct hid_bpf_ctx::hid. The casts are now unnecessary. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://patch.msgid.link/20241127-hid-bpf-cast-v1-1-f26424960e84@weissschuh.net Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
1 parent f9a11da commit 0b1b0c1

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

drivers/hid/bpf/hid_bpf_dispatch.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ __hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz,
352352
{
353353
struct hid_report_enum *report_enum;
354354
struct hid_report *report;
355-
struct hid_device *hdev;
356355
u32 report_len;
357356

358357
/* check arguments */
@@ -371,9 +370,7 @@ __hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz,
371370
if (*buf__sz < 1)
372371
return -EINVAL;
373372

374-
hdev = (struct hid_device *)ctx->hid; /* discard const */
375-
376-
report_enum = hdev->report_enum + rtype;
373+
report_enum = ctx->hid->report_enum + rtype;
377374
report = hid_ops->hid_get_report(report_enum, buf);
378375
if (!report)
379376
return -EINVAL;
@@ -402,7 +399,6 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
402399
enum hid_report_type rtype, enum hid_class_request reqtype)
403400
{
404401
struct hid_bpf_ctx_kern *ctx_kern;
405-
struct hid_device *hdev;
406402
size_t size = buf__sz;
407403
u8 *dma_data;
408404
int ret;
@@ -429,13 +425,11 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
429425
return -EINVAL;
430426
}
431427

432-
hdev = (struct hid_device *)ctx->hid; /* discard const */
433-
434428
dma_data = kmemdup(buf, size, GFP_KERNEL);
435429
if (!dma_data)
436430
return -ENOMEM;
437431

438-
ret = hid_ops->hid_hw_raw_request(hdev,
432+
ret = hid_ops->hid_hw_raw_request(ctx->hid,
439433
dma_data[0],
440434
dma_data,
441435
size,
@@ -464,7 +458,6 @@ __bpf_kfunc int
464458
hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz)
465459
{
466460
struct hid_bpf_ctx_kern *ctx_kern;
467-
struct hid_device *hdev;
468461
size_t size = buf__sz;
469462
u8 *dma_data;
470463
int ret;
@@ -478,13 +471,11 @@ hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz)
478471
if (ret)
479472
return ret;
480473

481-
hdev = (struct hid_device *)ctx->hid; /* discard const */
482-
483474
dma_data = kmemdup(buf, size, GFP_KERNEL);
484475
if (!dma_data)
485476
return -ENOMEM;
486477

487-
ret = hid_ops->hid_hw_output_report(hdev, dma_data, size, (u64)(long)ctx, true);
478+
ret = hid_ops->hid_hw_output_report(ctx->hid, dma_data, size, (u64)(long)ctx, true);
488479

489480
kfree(dma_data);
490481
return ret;

0 commit comments

Comments
 (0)