Skip to content

Commit 762ced1

Browse files
author
Benjamin Tissoires
committed
HID: bpf: fix gcc warning and unify __u64 into u64
I've got multiple reports of: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]. Let's use the same trick than kernel/bpf/helpers.c to shut up that warning. Even if we were on an architecture with addresses on more than 64 bits, this isn't much of an issue as the address is not used as a pointer, but as an hash and the caller is not supposed to go back to the kernel address ever. And while we change those, make sure we use u64 instead of __u64 for consistency Reported-by: Stephen Rothwell <[email protected]> Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Reported-by: Mirsad Todorovac <[email protected]> Fixes: 67eccf1 ("HID: add source argument to HID low level functions") Link: https://patch.msgid.link/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent fcdf830 commit 762ced1

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

drivers/hid/bpf/hid_bpf_dispatch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
440440
size,
441441
rtype,
442442
reqtype,
443-
(__u64)ctx,
443+
(u64)(long)ctx,
444444
true); /* prevent infinite recursions */
445445

446446
if (ret > 0)
@@ -483,7 +483,7 @@ hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz)
483483
if (!dma_data)
484484
return -ENOMEM;
485485

486-
ret = hid_ops->hid_hw_output_report(hdev, dma_data, size, (__u64)ctx, true);
486+
ret = hid_ops->hid_hw_output_report(hdev, dma_data, size, (u64)(long)ctx, true);
487487

488488
kfree(dma_data);
489489
return ret;
@@ -505,7 +505,7 @@ __hid_bpf_input_report(struct hid_bpf_ctx *ctx, enum hid_report_type type, u8 *b
505505
if (ret)
506506
return ret;
507507

508-
return hid_ops->hid_input_report(ctx->hid, type, buf, size, 0, (__u64)ctx, true,
508+
return hid_ops->hid_input_report(ctx->hid, type, buf, size, 0, (u64)(long)ctx, true,
509509
lock_already_taken);
510510
}
511511

drivers/hid/bpf/hid_bpf_struct_ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static void hid_bpf_unreg(void *kdata)
261261
hid_put_device(hdev);
262262
}
263263

264-
static int __hid_bpf_device_event(struct hid_bpf_ctx *ctx, enum hid_report_type type, __u64 source)
264+
static int __hid_bpf_device_event(struct hid_bpf_ctx *ctx, enum hid_report_type type, u64 source)
265265
{
266266
return 0;
267267
}

drivers/hid/hid-core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,7 +2412,7 @@ int __hid_hw_raw_request(struct hid_device *hdev,
24122412
unsigned char reportnum, __u8 *buf,
24132413
size_t len, enum hid_report_type rtype,
24142414
enum hid_class_request reqtype,
2415-
__u64 source, bool from_bpf)
2415+
u64 source, bool from_bpf)
24162416
{
24172417
unsigned int max_buffer_size = HID_MAX_BUFFER_SIZE;
24182418
int ret;
@@ -2454,7 +2454,7 @@ int hid_hw_raw_request(struct hid_device *hdev,
24542454
}
24552455
EXPORT_SYMBOL_GPL(hid_hw_raw_request);
24562456

2457-
int __hid_hw_output_report(struct hid_device *hdev, __u8 *buf, size_t len, __u64 source,
2457+
int __hid_hw_output_report(struct hid_device *hdev, __u8 *buf, size_t len, u64 source,
24582458
bool from_bpf)
24592459
{
24602460
unsigned int max_buffer_size = HID_MAX_BUFFER_SIZE;

drivers/hid/hidraw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
140140

141141
if ((report_type == HID_OUTPUT_REPORT) &&
142142
!(dev->quirks & HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP)) {
143-
ret = __hid_hw_output_report(dev, buf, count, (__u64)file, false);
143+
ret = __hid_hw_output_report(dev, buf, count, (u64)(long)file, false);
144144
/*
145145
* compatibility with old implementation of USB-HID and I2C-HID:
146146
* if the device does not support receiving output reports,
@@ -151,7 +151,7 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
151151
}
152152

153153
ret = __hid_hw_raw_request(dev, buf[0], buf, count, report_type,
154-
HID_REQ_SET_REPORT, (__u64)file, false);
154+
HID_REQ_SET_REPORT, (u64)(long)file, false);
155155

156156
out_free:
157157
kfree(buf);
@@ -228,7 +228,7 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
228228
}
229229

230230
ret = __hid_hw_raw_request(dev, report_number, buf, count, report_type,
231-
HID_REQ_GET_REPORT, (__u64)file, false);
231+
HID_REQ_GET_REPORT, (u64)(long)file, false);
232232

233233
if (ret < 0)
234234
goto out_free;

include/linux/hid_bpf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ struct hid_ops {
6868
unsigned char reportnum, __u8 *buf,
6969
size_t len, enum hid_report_type rtype,
7070
enum hid_class_request reqtype,
71-
__u64 source, bool from_bpf);
71+
u64 source, bool from_bpf);
7272
int (*hid_hw_output_report)(struct hid_device *hdev, __u8 *buf, size_t len,
73-
__u64 source, bool from_bpf);
73+
u64 source, bool from_bpf);
7474
int (*hid_input_report)(struct hid_device *hid, enum hid_report_type type,
7575
u8 *data, u32 size, int interrupt, u64 source, bool from_bpf,
7676
bool lock_already_taken);
@@ -115,7 +115,7 @@ struct hid_bpf_ops {
115115
* Context: Interrupt context.
116116
*/
117117
int (*hid_device_event)(struct hid_bpf_ctx *ctx, enum hid_report_type report_type,
118-
__u64 source);
118+
u64 source);
119119

120120
/**
121121
* @hid_rdesc_fixup: called when the probe function parses the report descriptor

0 commit comments

Comments
 (0)