| 0/0 |
2026/09/21 00:04 |
flow |
assessment-security |
1h13m
Error:
|
| 1/1 |
2026/09/21 00:04 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/09/21 00:04 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/fe4ac171720cc33d58390e3690cb7da561a240e2]
|
| 3/1 |
2026/09/21 00:06 |
action |
kernel-builder |
30m
Results: map[KernelObj:/app/workdir/cache/build/3d96be73c806e16304c15d62a4511644580b3925]
|
| 4/1 |
2026/09/21 00:36 |
action |
codesearch-prepare |
21m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/09/21 00:58 |
agent |
expert |
20m
Model:
Error:
Instruction: You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by grepping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption, elevated privileges, or an information leak.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completely wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control transfers, that also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitability depends on how exactly the uninit value
is used in the code, and what it affects.
Information leaks are exploitable on their own and should be classified as such. A bug that copies kernel
memory contents to userspace (e.g. an out-of-bounds read whose result is returned to the caller, or
uninitialized stack/heap bytes written to a user buffer) is exploitable: it can reveal kernel pointer
values and defeat KASLR, expose sensitive data such as cryptographic keys or other processes' memory, and
serves as a necessary building block in most modern kernel privilege-escalation exploit chains. Do not classify
an information leak as non-exploitable solely because it does not directly cause a memory write or control-flow
hijack; the leak itself is the exploit primitive.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidential Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The kernel bug report is:
kcov: kcov_start: t = ffff88805cfd0000, size = 524288, area = ffffc90007923000
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000065: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000328-0x000000000000032f]
CPU: 3 UID: 0 PID: 8172 Comm: syz.1.689 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:wacom_intuos_irq+0x62b/0x3430 drivers/hid/wacom_wac.c:1036
Code: c3 cc cc cc cc e8 35 b4 f1 f8 48 8b 04 24 44 0f b6 c5 48 8d b8 28 03 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 d4 27 00 00 48 8b 04 24 48 c7 c7 b8 d5 3e 91 48
RSP: 0018:ffffc90023e179f8 EFLAGS: 00010206
RAX: dffffc0000000000 RBX: ffff88804be480ae RCX: ffffc90007923000
RDX: 0000000000000065 RSI: ffffffff891a6b7b RDI: 0000000000000328
RBP: 000000000000002e R08: 000000000000002e R09: 0000000000000011
R10: 000000000000002e R11: 0000000000000001 R12: 000000000000005b
R13: ffff88804bc42048 R14: 000000000000002e R15: 0000000000000021
FS: 00007f1ee72ce6c0(0000) GS:ffff8880d5e56000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f1ee72cdff8 CR3: 000000002b6bc000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000400
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
wacom_bpt_irq drivers/hid/wacom_wac.c:3290 [inline]
wacom_wac_irq+0x196b/0xab80 drivers/hid/wacom_wac.c:3560
wacom_raw_event+0x6db/0xbf0 drivers/hid/wacom_sys.c:182
__hid_input_report.constprop.0+0x319/0x470 drivers/hid/hid-core.c:2175
uhid_dev_input2 drivers/hid/uhid.c:609 [inline]
uhid_char_write+0xb6b/0x10e0 drivers/hid/uhid.c:767
vfs_write+0x2aa/0x1050 fs/read_write.c:685
ksys_write+0x1f8/0x250 fs/read_write.c:739
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f1ee639e159
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f1ee72ce028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f1ee6626090 RCX: 00007f1ee639e159
RDX: 0000000000000061 RSI: 0000200000000040 RDI: 0000000000000003
RBP: 00007f1ee643506b R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f1ee6626128 R14: 00007f1ee6626090 R15: 00007ffec2a751d8
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:wacom_intuos_irq+0x62b/0x3430 drivers/hid/wacom_wac.c:1036
Code: c3 cc cc cc cc e8 35 b4 f1 f8 48 8b 04 24 44 0f b6 c5 48 8d b8 28 03 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 d4 27 00 00 48 8b 04 24 48 c7 c7 b8 d5 3e 91 48
RSP: 0018:ffffc90023e179f8 EFLAGS: 00010206
RAX: dffffc0000000000 RBX: ffff88804be480ae RCX: ffffc90007923000
RDX: 0000000000000065 RSI: ffffffff891a6b7b RDI: 0000000000000328
RBP: 000000000000002e R08: 000000000000002e R09: 0000000000000011
R10: 000000000000002e R11: 0000000000000001 R12: 000000000000005b
R13: ffff88804bc42048 R14: 000000000000002e R15: 0000000000000021
FS: 00007f1ee72ce6c0(0000) GS:ffff8880d5e56000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f1ee72cdff8 CR3: 000000002b6bc000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000400
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: c3 ret
1: cc int3
2: cc int3
3: cc int3
4: cc int3
5: e8 35 b4 f1 f8 call 0xf8f1b43f
a: 48 8b 04 24 mov (%rsp),%rax
e: 44 0f b6 c5 movzbl %bpl,%r8d
12: 48 8d b8 28 03 00 00 lea 0x328(%rax),%rdi
19: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax
20: fc ff df
23: 48 89 fa mov %rdi,%rdx
26: 48 c1 ea 03 shr $0x3,%rdx
* 2a: 80 3c 02 00 cmpb $0x0,(%rdx,%rax,1) <-- trapping instruction
2e: 0f 85 d4 27 00 00 jne 0x2808
34: 48 8b 04 24 mov (%rsp),%rax
38: 48 c7 c7 b8 d5 3e 91 mov $0xffffffff913ed5b8,%rdi
3f: 48 rex.W
|
| 6/2 |
2026/09/21 00:58 |
llm |
expert |
0m
Model:
Tokens:
input: 9187
output: 40
thoughts: 377
Thoughts: **Analyzing a Kernel Null-Pointer Dereference**
Okay, so I've got a KASAN null-pointer dereference report. The interesting thing here is that it's in the `wacom_intuos_irq` function, within the `drivers/hid/wacom_wac.c` file. Specifically, the error is occurring at line 1036. That's a good starting point. The address range it's complaining about is also given, that can also be helpful.
Looking at the call trace, I can see the issue propagates from `wacom_bpt_irq` and `wacom_wac_irq` all the way up through `wacom_raw_event`, then through the HID core (`__hid_input_report`), and finally gets passed through `uhid_char_write` and down to `vfs_write`. That call stack gives me the execution flow, which is crucial. `uhid` is involved as well, so there could also be some issues with the virtual HID device interactions.
This looks like it could be a race condition, or some sort of invalid pointer access in the Wacom driver's interrupt handling. I need to get to line 1036 in `wacom_wac.c` and figure out what's going on, and track back through that call stack to understand the context. The fact that the error occurs within the interrupt handler suggests the issue is time-critical. Let's see what that code does.
|
| 7/2 |
2026/09/21 00:58 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:1020 LineCount:50]
Results: map[Contents:1020: }
1021:
1022: static int wacom_intuos_irq(struct wacom_wac *wacom)
1023: {
1024: unsigned char *data = wacom->data;
1025: struct input_dev *input = wacom->pen_input;
1026: int result;
1027:
1028: if (data[0] != WACOM_REPORT_PENABLED &&
1029: data[0] != WACOM_REPORT_INTUOS_ID1 &&
1030: data[0] != WACOM_REPORT_INTUOS_ID2 &&
1031: data[0] != WACOM_REPORT_INTUOSPAD &&
1032: data[0] != WACOM_REPORT_INTUOS_PEN &&
1033: data[0] != WACOM_REPORT_CINTIQ &&
1034: data[0] != WACOM_REPORT_CINTIQPAD &&
1035: data[0] != WACOM_REPORT_INTUOS5PAD) {
1036: dev_dbg(input->dev.parent,
1037: "%s: received unknown report #%d\n", __func__, data[0]);
1038: return 0;
1039: }
1040:
1041: /* process pad events */
1042: result = wacom_intuos_pad(wacom);
1043: if (result)
1044: return result;
1045:
1046: /* process in/out prox events */
1047: result = wacom_intuos_inout(wacom);
1048: if (result)
1049: return result - 1;
1050:
1051: /* process general packets */
1052: result = wacom_intuos_general(wacom);
1053: if (result)
1054: return result - 1;
1055:
1056: return 0;
1057: }
1058:
1059: static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
1060: {
1061: unsigned char *data = wacom_wac->data;
1062: struct input_dev *input;
1063: struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1064: struct wacom_remote *remote = wacom->remote;
1065: int bat_charging, bat_percent, touch_ring_mode;
1066: __u32 serial;
1067: int i, index = -1;
1068: unsigned long flags;
1069:
]
|
| 8/2 |
2026/09/21 00:58 |
llm |
expert |
0m
Model:
Tokens:
input: 10725
output: 21
thoughts: 87
Thoughts: Here's my thought process, as if I were analyzing that crash:
**Debugging the Input Device Crash**
Okay, so the kernel's dumped a crash, specifically at line 1036. The culprit is `dev_dbg(input->dev.parent, ...)` β a debug print, which is normally innocuous, but obviously not this time. The stack trace tells me that `input` is `wacom->pen_input`. Now, alarm bells are ringing because dereferencing something like `input->dev.parent` is a classic recipe for disaster if `input` is NULL.
My immediate hypothesis is that `wacom->pen_input` is NULL at this point. That debug print is trying to access `input->dev.parent`. If `input` is NULL, that's a NULL pointer dereference. The kernel, in its infinite wisdom, will be trying to access memory at offset `dev` of the `struct input_dev` + the offset of `parent` member of `struct device` within `struct device`. Essentially it is treating NULL as a pointer. Let's make sure I understand the struct layout, and how the `dev` member of `input_dev` is structured, so I can see what's actually being dereferenced.
|
| 9/2 |
2026/09/21 00:58 |
tool |
codesearch-struct-layout |
0m
Args:
Results: map[Fields:[map[Name:name OffsetBits:0 SizeBits:64] map[Name:phys OffsetBits:64 SizeBits:64] map[Name:uniq OffsetBits:128 SizeBits:64] map[Name:id OffsetBits:192 SizeBits:64] map[Name:propbit OffsetBits:256 SizeBits:64] map[Name:evbit OffsetBits:320 SizeBits:64] map[Name:keybit OffsetBits:384 SizeBits:768] map[Name:relbit OffsetBits:1152 SizeBits:64] map[Name:absbit OffsetBits:1216 SizeBits:64] map[Name:mscbit OffsetBits:1280 SizeBits:64] map[Name:ledbit OffsetBits:1344 SizeBits:64] map[Name:sndbit OffsetBits:1408 SizeBits:64] map[Name:ffbit OffsetBits:1472 SizeBits:128] map[Name:swbit OffsetBits:1600 SizeBits:64] map[Name:hint_events_per_packet OffsetBits:1664 SizeBits:32] map[Name:keycodemax OffsetBits:1696 SizeBits:32] map[Name:keycodesize OffsetBits:1728 SizeBits:32] map[Name:keycode OffsetBits:1792 SizeBits:64] map[Name:setkeycode OffsetBits:1856 SizeBits:64] map[Name:getkeycode OffsetBits:1920 SizeBits:64] map[Name:ff OffsetBits:1984 SizeBits:64] map[Name:poller OffsetBits:2048 SizeBits:64] map[Name:repeat_key OffsetBits:2112 SizeBits:32] map[Name:timer OffsetBits:2176 SizeBits:640] map[Name:rep OffsetBits:2816 SizeBits:64] map[Name:mt OffsetBits:2880 SizeBits:64] map[Name:absinfo OffsetBits:2944 SizeBits:64] map[Name:key OffsetBits:3008 SizeBits:768] map[Name:led OffsetBits:3776 SizeBits:64] map[Name:snd OffsetBits:3840 SizeBits:64] map[Name:sw OffsetBits:3904 SizeBits:64] map[Name:open OffsetBits:3968 SizeBits:64] map[Name:close OffsetBits:4032 SizeBits:64] map[Name:flush OffsetBits:4096 SizeBits:64] map[Name:event OffsetBits:4160 SizeBits:64] map[Name:grab OffsetBits:4224 SizeBits:64] map[Name:event_lock OffsetBits:4288 SizeBits:512] map[Name:mutex OffsetBits:4800 SizeBits:1088] map[Name:users OffsetBits:5888 SizeBits:32] map[Name:going_away OffsetBits:5920 SizeBits:8] map[Name:dev OffsetBits:5952 SizeBits:9792] map[Name:h_list OffsetBits:15744 SizeBits:128] map[Name:node OffsetBits:15872 SizeBits:128] map[Name:num_vals OffsetBits:16000 SizeBits:32] map[Name:max_vals OffsetBits:16032 SizeBits:32] map[Name:vals OffsetBits:16064 SizeBits:64] map[Name:devres_managed OffsetBits:16128 SizeBits:8] map[Name:timestamp OffsetBits:16192 SizeBits:192] map[Name:inhibited OffsetBits:16384 SizeBits:8] map[Name:ready OffsetBits:16392 SizeBits:8]]]
|
| 10/2 |
2026/09/21 00:58 |
llm |
expert |
0m
Model:
Tokens:
input: 12167
output: 19
thoughts: 113
Thoughts: **Analyzing a Null Pointer Dereference**
Okay, so I'm looking at this crash report. The offset of `dev` is 5952 bits, which translates to 744 bytes, or in hexadecimal, 0x2e8. The critical part is the crash itself: a KASAN null-pointer dereference. The address range of the problem is between 0x328 and 0x32f. Now, 0x328 is the decimal 808.
My immediate thought is, let's figure out what's going on with the `parent` pointer within the `struct device`. Given the null-pointer dereference, it's highly probable that something is wrong with how `parent` is being accessed or initialized. Understanding its offset within the structure is key to pinpointing the root cause. I need to correlate that offset with the crash address to understand the memory layout and the sequence of events that led to this error. This offset will give me critical context for tracing the pointer's lifecycle.
|
| 11/2 |
2026/09/21 00:58 |
tool |
codesearch-struct-layout |
0m
Args:
Results: map[Fields:[map[Name:kobj OffsetBits:0 SizeBits:512] map[Name:parent OffsetBits:512 SizeBits:64] map[Name:p OffsetBits:576 SizeBits:64] map[Name:init_name OffsetBits:640 SizeBits:64] map[Name:type OffsetBits:704 SizeBits:64] map[Name:bus OffsetBits:768 SizeBits:64] map[Name:driver OffsetBits:832 SizeBits:64] map[Name:platform_data OffsetBits:896 SizeBits:64] map[Name:driver_data OffsetBits:960 SizeBits:64] map[Name:driver_override OffsetBits:1024 SizeBits:576] map[Name:mutex OffsetBits:1600 SizeBits:1088] map[Name:links OffsetBits:2688 SizeBits:448] map[Name:power OffsetBits:3136 SizeBits:4416] map[Name:pm_domain OffsetBits:7552 SizeBits:64] map[Name:msi OffsetBits:7616 SizeBits:128] map[Name:dma_mask OffsetBits:7744 SizeBits:64] map[Name:coherent_dma_mask OffsetBits:7808 SizeBits:64] map[Name:bus_dma_limit OffsetBits:7872 SizeBits:64] map[Name:dma_range_map OffsetBits:7936 SizeBits:64] map[Name:dma_parms OffsetBits:8000 SizeBits:64] map[Name:dma_pools OffsetBits:8064 SizeBits:128] map[Name:dma_mem OffsetBits:8192 SizeBits:64] map[Name:cma_area OffsetBits:8256 SizeBits:64] map[Name:dma_io_tlb_mem OffsetBits:8320 SizeBits:64] map[Name:archdata OffsetBits:8384 SizeBits:0] map[Name:of_node OffsetBits:8384 SizeBits:64] map[Name:fwnode OffsetBits:8448 SizeBits:64] map[Name:numa_node OffsetBits:8512 SizeBits:32] map[Name:devt OffsetBits:8544 SizeBits:32] map[Name:id OffsetBits:8576 SizeBits:32] map[Name:devres_lock OffsetBits:8640 SizeBits:512] map[Name:devres_head OffsetBits:9152 SizeBits:128] map[Name:class OffsetBits:9280 SizeBits:64] map[Name:groups OffsetBits:9344 SizeBits:64] map[Name:release OffsetBits:9408 SizeBits:64] map[Name:iommu_group OffsetBits:9472 SizeBits:64] map[Name:iommu OffsetBits:9536 SizeBits:64] map[Name:physical_location OffsetBits:9600 SizeBits:64] map[Name:removable OffsetBits:9664 SizeBits:32] map[Name:flags OffsetBits:9728 SizeBits:64]]]
|
| 12/2 |
2026/09/21 00:58 |
llm |
expert |
0m
Model:
Tokens:
input: 13411
output: 38
thoughts: 1108
Thoughts: **Analysis of a Kernel NULL Pointer Dereference**
Okay, so I've got this crash. The offset of `parent` within the `input` struct is 64 bytes or 0x40. Adding that to the base address 0x2e8 gives me 0x328, which perfectly matches where the crash is happening. It's a textbook NULL pointer dereference because `wacom->pen_input` is NULL.
Now, I need to figure out how `wacom->pen_input` gets initialized and how `wacom_intuos_irq` gets called. The call trace points to a route: `uhid_char_write` -> `wacom_raw_event` -> `wacom_wac_irq` -> `wacom_bpt_irq`. That means it's triggered via the `/dev/uhid` character device.
Normally, `/dev/uhid` is locked down; itβs typically only accessible to root or users with specific permissions. However, it's a misc device, not tied to network or user namespaces. So anyone with access to `/dev/uhid` can trigger it.
But wait, how else could this be triggered? The bug is in `wacom_wac.c`, which is a HID driver. Aha! This means it *could* be triggered by a malicious USB device (pretending to be a Wacom) sending a bad report. Or even a malicious Bluetooth device using HID over Bluetooth (BTHID) or something similar. So yes, this is a peripheral trigger.
Next, I need to assess exploitability. It's a NULL pointer dereference, which is generally not good. Looking at the code:
```c
if (data[0] != WACOM_REPORT_PENABLED &&
data[0] != WACOM_REPORT_INTUOS_ID1 &&
data[0] != WACOM_REPORT_INTUOS_ID2 &&
data[0] != WACOM_REPORT_INTUOSPAD &&
data[0] != WACOM_REPORT_INTUOS_PEN &&
data[0] != WACOM_REPORT_CINTIQ &&
data[0] != WACOM_REPORT_CINTIQPAD &&
data[0] != WACOM_REPORT_INTUOS5PAD) {
dev_dbg(input->dev.parent,
"%s: received unknown report #%d\n", __func__, data[0]);
return 0;
}
```
If `input` is NULL, the code attempts to dereference `input->dev.parent`. Since 0x328 is a small offset, this is indeed a classic NULL pointer dereference. The problem is that in modern kernels, you can't usually exploit this for privilege escalation directly because `mmap(0)` is restricted by `mmap_min_addr`. It will cause a kernel oops/panic, which means Denial of Service.
Wait, is this still exploitable though? Looking at the assembly, it's doing a `cmpb $0x0, (%rdx,%rax,1)`. The comparison implies KASAN is enabled, checking the shadow memory, and not actually performing a read from memory. However, without KASAN, it *would* be a read.
But then I remember `dev_dbg` is a macro, and maybe nothing is actually being read. Looking at the definition:
```c
#define dev_dbg(dev, fmt, ...) \
({ \
if (dev_dbg_default_noop()) \
if (0) \
dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \
else \
dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__); \
})
```
If dynamic debug is not enabled, then `dev_dbg` might actually not even evaluate its arguments, or just read the `dev` pointer without dereferencing anything! Okay, so I need to check the exact behavior of `dev_dbg` to confirm.
|
| 13/2 |
2026/09/21 00:58 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/hid/wacom_wac.c Name:dev_dbg]
Results: map[SourceCode: SourceFile:]
|
| 14/2 |
2026/09/21 00:58 |
llm |
expert |
0m
Model:
Tokens:
input: 15498
output: 35
thoughts: 10
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Debugging Initiative: Utilizing `dev_dbg`**
Okay, so I need to get some more granular debugging information. Time to start digging into the code and narrow down the scope. My initial thought is to do a quick `grep` for instances of `dev_dbg`. That should give me a good starting point, showing me where the developer *intended* to leave diagnostic outputs. It's a pragmatic first step β quickly identifying existing debug infrastructure instead of starting completely from scratch. Iβll be looking not just for direct calls, but also for macros that might expand to `dev_dbg`. I need to remember any project-specific conventions, too, since the code base may not be consistent with the standard coding practices. From there, I can analyze the surrounding code to determine if those calls are being used effectively, and if the information they provide is relevant to the issue I'm tracking down. I'll mentally note the context of each call - what function is it in, what conditions trigger the output, and what specifically is being logged. This gives me a quick map of the diagnostic possibilities that I can then leverage.
|
| 15/2 |
2026/09/21 00:58 |
tool |
grepper |
0m
Args: map[Expression:#define dev_dbg\( PathPrefix:include/linux/dev_printk.h]
Results: map[Output:include/linux/dev_printk.h=95=void _dev_info(const struct device *dev, const char *fmt, ...)
--
include/linux/dev_printk.h-163- (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
include/linux/dev_printk.h:164:#define dev_dbg(dev, fmt, ...) \
include/linux/dev_printk.h-165- dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
include/linux/dev_printk.h-166-#elif defined(DEBUG)
include/linux/dev_printk.h:167:#define dev_dbg(dev, fmt, ...) \
include/linux/dev_printk.h-168- dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
include/linux/dev_printk.h-169-#else
include/linux/dev_printk.h:170:#define dev_dbg(dev, fmt, ...) \
include/linux/dev_printk.h-171- dev_no_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
]
|
| 16/2 |
2026/09/21 00:58 |
llm |
expert |
0m
Model:
Tokens:
input: 16106
output: 36
thoughts: 11
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm deep in my domain of expertise:
**Checking the `dev_no_printk` Flag**
Right, let's just quickly confirm something crucial. Before diving deeper, I need to make absolutely sure the `dev_no_printk` flag is set correctly. This flag is so critical to debugging and logging in this particular subsystem. I know I've been focusing on X, Y, and Z, but if `dev_no_printk` isn't behaving as expected, any conclusions I've drawn so far could be completely off-base. It's a fundamental parameter that impacts the diagnostic output, especially the logging granularity. If it's disabled when I expect it to be enabled, or vice versa, it would completely skew my understanding of the behavior I'm seeing. Better to verify this now, before I waste time chasing a phantom. I need to make sure the logging I'm relying on is giving me accurate information. Let's verify it's the correct state for the context of this issue. Quick check, then back to the main investigation.
|
| 17/2 |
2026/09/21 00:58 |
tool |
grepper |
0m
Args: map[Expression:#define dev_no_printk PathPrefix:include/linux/dev_printk.h]
Results: map[Output:include/linux/dev_printk.h=95=void _dev_info(const struct device *dev, const char *fmt, ...)
--
include/linux/dev_printk.h-135- */
include/linux/dev_printk.h:136:#define dev_no_printk(level, dev, fmt, ...) \
include/linux/dev_printk.h-137- ({ \
]
|
| 18/2 |
2026/09/21 00:58 |
llm |
expert |
0m
Model:
Tokens:
input: 16504
output: 37
thoughts: 13
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing the `dev_no_printk` Definition**
Okay, let's dive right in. The task is to understand the `dev_no_printk` definition. I need to refresh my memory on what this macro represents and how it functions within the kernel's print infrastructure. My initial hypothesis is that it likely pertains to suppressing or managing print messages from device drivers under specific circumstances. Perhaps it's tied to debugging levels, module loading/unloading states, or even error handling during early boot stages. I'll need to confirm these hunches by inspecting its actual implementation and where it's used within the codebase. Understanding this mechanism is crucial for diagnosing any potential print-related issues in a development workflow, and knowing what this definition means will definitely help determine how to best approach it.
|
| 19/2 |
2026/09/21 00:59 |
tool |
read-file |
0m
Args: map[File:include/linux/dev_printk.h FirstLine:130 LineCount:20]
Results: map[Contents: 130: })
131:
132: /*
133: * Dummy dev_printk for disabled debugging statements to use whilst maintaining
134: * gcc's format checking.
135: */
136: #define dev_no_printk(level, dev, fmt, ...) \
137: ({ \
138: if (0) \
139: _dev_printk(level, dev, fmt, ##__VA_ARGS__); \
140: })
141:
142: /*
143: * #defines for all the dev_<level> macros to prefix with whatever
144: * possible use of #define dev_fmt(fmt) ...
145: */
146:
147: #define dev_emerg(dev, fmt, ...) \
148: dev_printk_index_wrap(_dev_emerg, KERN_EMERG, dev, dev_fmt(fmt), ##__VA_ARGS__)
149: #define dev_crit(dev, fmt, ...) \
]
|
| 20/2 |
2026/09/21 00:59 |
llm |
expert |
0m
Model:
Tokens:
input: 17045
output: 36
thoughts: 72
Thoughts: **Debugging a Tricky Kernel Issue**
Okay, hold on a second. This is strange. If `dev_no_printk` is active, the `dev` variable *should* only be evaluated within that `if (0)` block. But the crash log clearly shows `dev` being evaluated! That doesn't make any sense... unless... Aha! I bet it's that `dynamic_dev_dbg` macro. I vaguely recall something like that. It likely gets used when `CONFIG_DYNAMIC_DEBUG` is enabled. Time to delve into the `dynamic_dev_dbg` macro and see what's going on there. I need to understand *why* `dev` is being accessed outside that conditional. This is likely the key to understanding the crash.
|
| 21/2 |
2026/09/21 00:59 |
tool |
grepper |
0m
Args: map[Expression:#define dynamic_dev_dbg PathPrefix:include/linux/dynamic_debug.h]
Results: map[Output:include/linux/dynamic_debug.h=160=void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
--
include/linux/dynamic_debug.h-282-
include/linux/dynamic_debug.h:283:#define dynamic_dev_dbg(dev, fmt, ...) \
include/linux/dynamic_debug.h-284- _dynamic_func_call(fmt, __dynamic_dev_dbg, \
--
include/linux/dynamic_debug.h-319- no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
include/linux/dynamic_debug.h:320:#define dynamic_dev_dbg(dev, fmt, ...) \
include/linux/dynamic_debug.h-321- dev_no_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__)
]
|
| 22/2 |
2026/09/21 00:59 |
llm |
expert |
0m
Model:
Tokens:
input: 17541
output: 37
thoughts: 13
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing the `dynamic_dev_dbg` Definition**
Okay, time to dissect this `dynamic_dev_dbg` definition. I'm already anticipating some of the nuances involved, given the name. I'm expecting this to be a debugging macro or function related to dynamically allocated devices or drivers. I'll need to drill down into the specifics of how it's implemented. Is it conditional compilation based on a debug flag? Does it employ a specific logging mechanism, like `printk` or something more sophisticated?
I'll be looking for potential pitfalls. Does it introduce any performance overhead that might be problematic in a production environment, even when debugging is disabled? Does it manage its debug level efficiently, perhaps allowing for selective enabling of debugging output for specific devices or modules? And critically, I want to see how this interacts with any existing kernel debug infrastructure. Does it integrate seamlessly, or does it reinvent the wheel? A close look at its arguments will tell me a lot about its intended usage and any device context that it assumes. I'll be particularly interested in any synchronization primitives involved. A poorly designed debug mechanism could introduce serious concurrency issues.
|
| 23/2 |
2026/09/21 00:59 |
tool |
read-file |
0m
Args: map[File:include/linux/dynamic_debug.h FirstLine:275 LineCount:20]
Results: map[Contents: 275: #define dynamic_pr_debug_cls(cls, fmt, ...) \
276: _dynamic_func_call_cls(cls, fmt, __dynamic_pr_debug, \
277: pr_fmt(fmt), ##__VA_ARGS__)
278:
279: #define dynamic_pr_debug(fmt, ...) \
280: _dynamic_func_call(fmt, __dynamic_pr_debug, \
281: pr_fmt(fmt), ##__VA_ARGS__)
282:
283: #define dynamic_dev_dbg(dev, fmt, ...) \
284: _dynamic_func_call(fmt, __dynamic_dev_dbg, \
285: dev, fmt, ##__VA_ARGS__)
286:
287: #define dynamic_netdev_dbg(dev, fmt, ...) \
288: _dynamic_func_call(fmt, __dynamic_netdev_dbg, \
289: dev, fmt, ##__VA_ARGS__)
290:
291: #define dynamic_ibdev_dbg(dev, fmt, ...) \
292: _dynamic_func_call(fmt, __dynamic_ibdev_dbg, \
293: dev, fmt, ##__VA_ARGS__)
294:
]
|
| 24/2 |
2026/09/21 00:59 |
llm |
expert |
0m
Model:
Tokens:
input: 18231
output: 37
thoughts: 12
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:
**Analyzing the Function Call**
Alright, let's get into it. The first thing I'm doing is focusing on that specific function call: `_dynamic_func_call`. It's immediately interesting because of the leading underscore. That typically signifies a "private" or internal function, one that the developer likely doesn't want to expose directly to external use. Understanding why it's there and what it *does* is key. Is it a helper function? A utility? Does it represent some underlying mechanism of abstraction? What kind of dynamic behavior does it enable? Does it suggest a more complex architecture than a cursory glance might reveal? Let's read this.
|
| 25/2 |
2026/09/21 00:59 |
tool |
read-file |
0m
Args: map[File:include/linux/dynamic_debug.h FirstLine:250 LineCount:20]
Results: map[Contents: 250: /*
251: * "Factory macro" for generating a call to func, guarded by a
252: * DYNAMIC_DEBUG_BRANCH. The dynamic debug descriptor will be
253: * initialized using the fmt argument. The function will be called with
254: * the address of the descriptor as first argument, followed by all
255: * the varargs. Note that fmt is repeated in invocations of this
256: * macro.
257: */
258: #define _dynamic_func_call_cls(cls, fmt, func, ...) \
259: __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS__)
260: #define _dynamic_func_call(fmt, func, ...) \
261: _dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__)
262:
263: /*
264: * A variant that does the same, except that the descriptor is not
265: * passed as the first argument to the function; it is only called
266: * with precisely the macro's varargs.
267: */
268: #define _dynamic_func_call_cls_no_desc(cls, fmt, func, ...) \
269: __dynamic_func_call_cls_no_desc(__UNIQUE_ID(ddebug), cls, fmt, \
]
|
| 26/2 |
2026/09/21 00:59 |
llm |
expert |
0m
Model:
Tokens:
input: 18857
output: 37
thoughts: 14
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing the Dynamic Function Call Class**
Okay, let's dive into this `__dynamic_func_call_cls`. My initial thought is to immediately parse the name and try to infer its purpose. The prefix "__" often denotes a special or internal method in Python, suggesting that this class probably handles some kind of dynamic behavior or metadata. The "func_call" part is quite telling; it strongly implies that the core functionality revolves around invoking functions, potentially in a flexible or runtime-determined manner. I'm already anticipating that it might be related to things like function decorators, metaprogramming, or perhaps even a custom implementation of dispatching logic. I wonder if it's involved in creating proxies or wrappers for functions. Is it designed to abstract away the details of the function being called, or provide some kind of pre- or post-processing capabilities? Is it for a specific framework or is it more general? I'll be looking for clues in its attributes and methods that will help me build out a clear understanding of its operation. Time to dig in and see the details.
|
| 27/2 |
2026/09/21 00:59 |
tool |
read-file |
0m
Args: map[File:include/linux/dynamic_debug.h FirstLine:230 LineCount:20]
Results: map[Contents: 230: if (DYNAMIC_DEBUG_BRANCH(id)) { \
231: func(&id, ##__VA_ARGS__); \
232: __dynamic_dump_stack(id); \
233: } \
234: } while (0)
235: #define __dynamic_func_call(id, fmt, func, ...) \
236: __dynamic_func_call_cls(id, _DPRINTK_CLASS_DFLT, fmt, \
237: func, ##__VA_ARGS__)
238:
239: #define __dynamic_func_call_cls_no_desc(id, cls, fmt, func, ...) do { \
240: DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \
241: if (DYNAMIC_DEBUG_BRANCH(id)) { \
242: func(__VA_ARGS__); \
243: __dynamic_dump_stack(id); \
244: } \
245: } while (0)
246: #define __dynamic_func_call_no_desc(id, fmt, func, ...) \
247: __dynamic_func_call_cls_no_desc(id, _DPRINTK_CLASS_DFLT, \
248: fmt, func, ##__VA_ARGS__)
249:
]
|
| 28/2 |
2026/09/21 00:59 |
llm |
expert |
0m
Model:
Tokens:
input: 19545
output: 38
thoughts: 790
Thoughts: **Debugging a Potentially Unsafe Kernel Memory Access**
Okay, so I'm looking at this code and trying to figure out why we're hitting a KASAN trap. The call to `func(&id, ##__VA_ARGS__)` seems to be the culprit. Specifically, it involves the `dev` variable, which I know is passed to `__dynamic_dev_dbg` at some point. But, hang on, this `dev` gets evaluated *before* it's actually used by `__dynamic_dev_dbg`. That's a key detail. The `__dynamic_func_call_cls` macro only actually evaluates `__VA_ARGS__` if `DYNAMIC_DEBUG_BRANCH(id)` is true.
The big question is, what is the value of `DYNAMIC_DEBUG_BRANCH` at the time of execution? If it's true, it evaluates `dev`, but if not, then it doesn't. Now, `dev` is, according to the code, `input->dev.parent`. The crucial question is, if `DYNAMIC_DEBUG_BRANCH` is false, is `input->dev.parent` *still* evaluated? The call to `func(&id, ##__VA_ARGS__)` is nested inside an `if` statement so the result is no, so `input->dev.parent` should NOT be evaluated.
Let's look at the assembly in the crash report. Specifically, I'm focusing on the instruction at address `0x2a: 80 3c 02 00` which I see is a `cmpb` instruction, specifically checking KASAN shadow memory for `input->dev.parent`. But why?
Then it hit me, it's possible that `dev_dbg` isn't calling `dynamic_dev_dbg`, but rather it's calling `dev_printk`, so let's look at the implementation of `dev_dbg`.
I check `include/linux/dev_printk.h` and see the implementation:
```c
#define dev_dbg(dev, fmt, ...) \
({ \
if (dev_dbg_default_noop()) \
if (0) \
dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \
else \
dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__); \
})
```
Okay, `dev_dbg` uses a macro that first checks `dev_dbg_default_noop()`. What is `dev_dbg_default_noop()`? Is it a function, or a macro? I need to check. This might provide the missing clue.
|
| 29/2 |
2026/09/21 00:59 |
tool |
grepper |
0m
Error:
Args: map[Expression:#define dev_dbg_default_noop PathPrefix:include/linux/dev_printk.h]
Results:
|
| 30/2 |
2026/09/21 00:59 |
llm |
expert |
0m
Model:
Tokens:
input: 20977
output: 36
thoughts: 11
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert and I'm framing it as my own thought:
**Quick Sanity Check: `dev_dbg`**
Alright, let's just do a quick re-examination of `dev_dbg`. I've been working on this for a while and my brain's starting to feel fuzzy. Before I dive into anything new or try any complex debugging steps, I need to confirm the basics. I just want to run through that piece of the puzzle again in my head. A little re-check of `dev_dbg` seems like a good starting point. Make sure my understanding is solid. No need to make a mountain out of a molehill, let's keep it simple.
|
| 31/2 |
2026/09/21 00:59 |
tool |
grepper |
0m
Error:
Args: map[Expression:dev_dbg_default_noop PathPrefix:include/linux/dev_printk.h]
Results:
|
| 32/2 |
2026/09/21 00:59 |
llm |
expert |
0m
Model:
Tokens:
input: 21206
output: 34
thoughts: 1626
Thoughts: **Analyzing the Root Cause of a KASAN Crash in `dev_dbg`**
Okay, so I was looking at this crash and my initial grep of `dev_dbg` gave me the typical macro definitions. It seems like the behavior of `dev_dbg` really hinges on whether `CONFIG_DYNAMIC_DEBUG` is enabled, or if `DEBUG` is defined. If neither of those are true, we're dealing with `dev_no_printk`. My first thought was that if `dev_no_printk` is used because of the `if (0)` construct, the `dev` argument is never evaluated at runtime, and I initially dismissed KASAN as the cause.
However, the assembly code is showing me otherwise. I can see a KASAN shadow memory check, specifically targeting the address `0x328` offset from `%rax`, which appears to be reading `input->dev.parent`. Now, the tricky part is figuring out *why* this read is happening. Initially, I thought this was just a normal field access inside the macro. That's `input`, which is a pointer to a `struct input_dev`, then `input->dev`, and then `input->dev.parent`. The address is calculated as `input + 0x328`, then a KASAN check is performed. Clearly, since `input` is NULL, the crash occurs when KASAN attempts to check the shadow memory for the invalid address `0x328`.
The obvious question, then, is *why* is it dereferencing `input->dev.parent` if it is supposed to be optimized out in `dev_no_printk`? My thought immediately goes to `CONFIG_DYNAMIC_DEBUG`. If dynamic debug is enabled, `dev_dbg` expands to `dynamic_dev_dbg`. I went back and looked at the assembly, where I saw what appeared to be a `__sanitizer_cov_trace_pc` call. That makes sense. It looks like the KASAN check, which causes the crash, *must* be happening inside `dynamic_dev_dbg`.
In the `dynamic_dev_dbg` code, `dev` is passed as part of the variadic arguments. If `DYNAMIC_DEBUG_BRANCH` is true, it *should* evaluate `dev`. If it is false, it *should not* be evaluating `dev`. But the crash is happening. I need to re-examine the assembly closely, particularly the call stack, to see if `dynamic_dev_dbg` is actually being called, or something *like* `dynamic_dev_dbg`. Also, it's worth checking to see if `DEBUG` is defined anywhere.
|
| 33/2 |
2026/09/21 01:00 |
tool |
grepper |
0m
Error:
Args: map[Expression:#define DEBUG PathPrefix:drivers/hid/wacom_wac.c]
Results:
|
| 34/2 |
2026/09/21 01:00 |
llm |
expert |
0m
Model:
Tokens:
input: 23454
output: 34
thoughts: 64
Thoughts: **Debugging a Debugging Macro**
Okay, so I'm digging into this code and a question popped into my head: if `CONFIG_DYNAMIC_DEBUG` is enabled, could there be a problem if the `dev` variable is evaluated *before* the conditional check? It seems like it might be a potential optimization issue, or maybe even a bug. But then, I quickly remembered that it's a macro, right? Macros are substituted directly during compilation, so the order of evaluation shouldn't be a problem. That eliminates that as a concern.
Just to be sure, though, I should double-check the definition of `dev_dbg` in `include/linux/dev_printk.h`. Gotta make sure my assumptions are solid. It's always the best practice to verify what I *think* I know.
|
| 35/2 |
2026/09/21 01:00 |
tool |
grepper |
0m
Args: map[Expression:#define dev_dbg PathPrefix:include/linux/dev_printk.h]
Results: map[Output:include/linux/dev_printk.h=95=void _dev_info(const struct device *dev, const char *fmt, ...)
--
include/linux/dev_printk.h-163- (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
include/linux/dev_printk.h:164:#define dev_dbg(dev, fmt, ...) \
include/linux/dev_printk.h-165- dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
include/linux/dev_printk.h-166-#elif defined(DEBUG)
include/linux/dev_printk.h:167:#define dev_dbg(dev, fmt, ...) \
include/linux/dev_printk.h-168- dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
include/linux/dev_printk.h-169-#else
include/linux/dev_printk.h:170:#define dev_dbg(dev, fmt, ...) \
include/linux/dev_printk.h-171- dev_no_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
--
include/linux/dev_printk.h=186=do { \
--
include/linux/dev_printk.h-205- dev_level_once(dev_info, dev, fmt, ##__VA_ARGS__)
include/linux/dev_printk.h:206:#define dev_dbg_once(dev, fmt, ...) \
include/linux/dev_printk.h-207- dev_level_once(dev_dbg, dev, fmt, ##__VA_ARGS__)
--
include/linux/dev_printk.h=210=do { \
--
include/linux/dev_printk.h-234-/* descriptor check is first to prevent flooding with "callbacks suppressed" */
include/linux/dev_printk.h:235:#define dev_dbg_ratelimited(dev, fmt, ...) \
include/linux/dev_printk.h-236-do { \
--
include/linux/dev_printk.h-246-#elif defined(DEBUG)
include/linux/dev_printk.h:247:#define dev_dbg_ratelimited(dev, fmt, ...) \
include/linux/dev_printk.h-248-do { \
--
include/linux/dev_printk.h-255-#else
include/linux/dev_printk.h:256:#define dev_dbg_ratelimited(dev, fmt, ...) \
include/linux/dev_printk.h-257- dev_no_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
]
|
| 36/2 |
2026/09/21 01:00 |
llm |
expert |
0m
Model:
Tokens:
input: 24426
output: 37
thoughts: 956
Thoughts: **Analyzing Kernel Debugging Macros and Potential KASAN Issues**
Okay, let's break this down. I'm looking at `dev_no_printk` β that macro uses `if (0)`, so any expression within it, like the `dev` argument, shouldn't be evaluated at runtime. But, `dev` is still passed to `_dev_printk` inside the macro. I need to be absolutely certain that `dev` is not evaluated in the "no print" case. In standard C, expressions inside `if (0)` are indeed optimized out at compile time and not evaluated at runtime. However, I need to consider other possibilities, like what happens if `dev_dbg` isn't `dev_no_printk`. And the elephant in the room: `CONFIG_DYNAMIC_DEBUG`.
Aha! If dynamic debug is on, `dev_dbg` becomes `dynamic_dev_dbg`, which then goes through a series of macro calls: `_dynamic_func_call`, `_dynamic_func_call_cls`, and finally `__dynamic_func_call_cls`. Crucially, this last one has a `DYNAMIC_DEBUG_BRANCH(id)`. Now, if that branch is *taken* (i.e., `DYNAMIC_DEBUG_BRANCH(id)` is true), then `dev` *is* evaluated. Syzkaller kernels often have `CONFIG_DYNAMIC_DEBUG` enabled, but I have to remember that `DYNAMIC_DEBUG_BRANCH(id)` only enables dynamic debug for *this specific callsite*. So it's conditional.
Right, back to the assembly. That's where the real problem lies. The code loads an address relative to `rax`, which I believe is my input pointer, into `rdi`. Then, it checks the KASAN shadow memory at an address related to `input + 0x328`, which happens to be the address of `input->dev.parent`. It's checking KASAN, and this *must* mean the `dev` is evaluated! But wait. That branch is *conditionally* executed. The branch is taken *only* if dynamic debug is enabled at the call site.
Here's the critical question: is `dev` evaluated before the `if` statement? What if it's evaluated unconditionally, *then* the `if` happens? That could explain the KASAN check! I need to re-examine the definition of `dev_dbg`. Maybe it is a function. No. It is still a macro. Okay, let me go back to `include/linux/dev_printk.h` and check again...
|
| 37/2 |
2026/09/21 01:00 |
tool |
read-file |
0m
Args: map[File:include/linux/dev_printk.h FirstLine:150 LineCount:30]
Results: map[Contents: 150: dev_printk_index_wrap(_dev_crit, KERN_CRIT, dev, dev_fmt(fmt), ##__VA_ARGS__)
151: #define dev_alert(dev, fmt, ...) \
152: dev_printk_index_wrap(_dev_alert, KERN_ALERT, dev, dev_fmt(fmt), ##__VA_ARGS__)
153: #define dev_err(dev, fmt, ...) \
154: dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
155: #define dev_warn(dev, fmt, ...) \
156: dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__)
157: #define dev_notice(dev, fmt, ...) \
158: dev_printk_index_wrap(_dev_notice, KERN_NOTICE, dev, dev_fmt(fmt), ##__VA_ARGS__)
159: #define dev_info(dev, fmt, ...) \
160: dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
161:
162: #if defined(CONFIG_DYNAMIC_DEBUG) || \
163: (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
164: #define dev_dbg(dev, fmt, ...) \
165: dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
166: #elif defined(DEBUG)
167: #define dev_dbg(dev, fmt, ...) \
168: dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
169: #else
170: #define dev_dbg(dev, fmt, ...) \
171: dev_no_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
172: #endif
173:
174: #ifdef CONFIG_PRINTK
175: #define dev_level_once(dev_level, dev, fmt, ...) \
176: do { \
177: static bool __print_once __read_mostly; \
178: \
179: if (!__print_once) { \
]
|
| 38/2 |
2026/09/21 01:00 |
llm |
expert |
0m
Model:
Tokens:
input: 26649
output: 37
thoughts: 85
Thoughts: Here's my summary, as if I were thinking it:
**Digging into the `dev_dbg` Macro**
Okay, let's break this down. I'm looking at this `dev_dbg` macro definition, and it's calling out to `dynamic_dev_dbg`, which is interesting. Wait, now I see the conditional aspect. If `CONFIG_DYNAMIC_DEBUG` is enabled, then `dev_dbg` is aliased to `dynamic_dev_dbg`. That makes sense; so, if dynamic debugging is off, something else is probably happening with `dev_dbg`.
Alright, I should take another look at the `dynamic_dev_dbg` implementation itself, as that's where the core logic of the debug message likely is if the config is enabled. I need to be sure this is working correctly.
|
| 39/2 |
2026/09/21 01:00 |
tool |
read-file |
0m
Args: map[File:include/linux/dynamic_debug.h FirstLine:270 LineCount:30]
Results: map[Contents: 270: func, ##__VA_ARGS__)
271: #define _dynamic_func_call_no_desc(fmt, func, ...) \
272: _dynamic_func_call_cls_no_desc(_DPRINTK_CLASS_DFLT, fmt, \
273: func, ##__VA_ARGS__)
274:
275: #define dynamic_pr_debug_cls(cls, fmt, ...) \
276: _dynamic_func_call_cls(cls, fmt, __dynamic_pr_debug, \
277: pr_fmt(fmt), ##__VA_ARGS__)
278:
279: #define dynamic_pr_debug(fmt, ...) \
280: _dynamic_func_call(fmt, __dynamic_pr_debug, \
281: pr_fmt(fmt), ##__VA_ARGS__)
282:
283: #define dynamic_dev_dbg(dev, fmt, ...) \
284: _dynamic_func_call(fmt, __dynamic_dev_dbg, \
285: dev, fmt, ##__VA_ARGS__)
286:
287: #define dynamic_netdev_dbg(dev, fmt, ...) \
288: _dynamic_func_call(fmt, __dynamic_netdev_dbg, \
289: dev, fmt, ##__VA_ARGS__)
290:
291: #define dynamic_ibdev_dbg(dev, fmt, ...) \
292: _dynamic_func_call(fmt, __dynamic_ibdev_dbg, \
293: dev, fmt, ##__VA_ARGS__)
294:
295: #define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
296: groupsize, buf, len, ascii) \
297: _dynamic_func_call_no_desc(__builtin_constant_p(prefix_str) ? prefix_str : "hexdump", \
298: print_hex_dump, \
299: KERN_DEBUG, prefix_str, prefix_type, \
]
|
| 40/2 |
2026/09/21 01:00 |
llm |
expert |
0m
Model:
Tokens:
input: 27557
output: 30
thoughts: 404
Thoughts: **Analyzing the `_dynamic_func_call` Macro and Debugging a Crash**
Okay, let's break this down. First, I see that `_dynamic_func_call` is a macro defined in a chain. It starts with the basic `_dynamic_func_call` that ultimately calls `__dynamic_func_call_cls`. This macro seems to be responsible for conditionally executing a function call based on a dynamic debug setting.
My initial concern was whether the arguments to the called function, specifically the `dev` argument, were being evaluated before the `if` statement, which could potentially cause issues if `dev` was uninitialized or had side effects that shouldn't always occur. However, I quickly realized the macro expansion handles this correctly. `dev` is being substituted directly into the function call `func(&id, ##__VA_ARGS__)`, so the evaluation of `dev` happens *inside* the `if` block, only when the condition `DYNAMIC_DEBUG_BRANCH(id)` is true. That clears that up.
So, if `DYNAMIC_DEBUG_BRANCH(id)` is true, as indicated by the crash, `dev` *should* be evaluated. Why is it crashing then? It's likely because dynamic debug *is* enabled for this call. Now, the next question is, what's enabling dynamic debug? Does syzkaller enable it for the entire file, perhaps as a general testing approach, or is it triggered by fault injection or some other specific test condition?
Another possibility, and this is important, is to check the configuration. Could it be that `CONFIG_DYNAMIC_DEBUG` is *not* enabled, but `DEBUG` *is*? This might lead to unexpected behavior. To confirm this, the next step is to examine the `drivers/hid/Makefile` to see if there are any conditional definitions of `DEBUG` or related flags that could be influencing this behavior. This would help identify if a broader debugging flag might be causing the issue.
|
| 41/2 |
2026/09/21 01:00 |
tool |
grepper |
0m
Error:
Args: map[Expression:ccflags-y.*DEBUG PathPrefix:drivers/hid/]
Results:
|
| 42/2 |
2026/09/21 01:00 |
llm |
expert |
0m
Model:
Tokens:
input: 28427
output: 36
thoughts: 216
Thoughts: **Analyzing Dynamic Debug and Potential Syzkaller Interactions**
Okay, so I'm looking into how dynamic debug, specifically within the context of syzkaller fuzzing, might be causing an issue. First, I need to confirm if `CONFIG_DYNAMIC_DEBUG` is even enabled in the syzkaller configuration. Typically, it's set to 'y'. If it *is* enabled, then `DYNAMIC_DEBUG_BRANCH(id)` translates to `unlikely(id.flags & _DPRINTK_FLAGS_PRINT)`. Hmm, if that condition *is* true, that tells me that dynamic debug has been specifically enabled for that particular `printk` statement. That's a red flag. Syzkaller could've done this through the `/sys/kernel/debug/dynamic_debug/control` interface. And if it *is* evaluated, boom - crash.
Now, my mind shifts to other potential ways `dev` could be evaluated and trigger the issue. I need to exhaust all possibilities. Is `dev_dbg` a function? No, of course not, it's a macro. Right, let's trace through the macros. What about `dev_fmt`? Does *that* evaluate `dev`? Let's refresh our memories. I know it's something like:
```c
#define dev_fmt(fmt) fmt
```
Ah, simple string formatting macro. That's not the problem. But wait... is `dev_fmt` redefined *anywhere* in the code base that could cause trouble? I'm specifically thinking of those driver directories, let's check `drivers/hid/wacom_wac.c`. I have to be thorough.
|
| 43/2 |
2026/09/21 01:00 |
tool |
grepper |
0m
Error:
Args: map[Expression:#define dev_fmt PathPrefix:drivers/hid/wacom_wac.c]
Results:
|
| 44/2 |
2026/09/21 01:00 |
llm |
expert |
0m
Model:
Tokens:
input: 29055
output: 34
thoughts: 1418
Thoughts: **Debugging a Suspected Null Pointer Dereference in Kernel Code**
Okay, so I'm digging into this crash, and it looks like it might be related to a potentially uninitialized value being used in a `dev_dbg` call. My initial thought was that perhaps `dev_dbg` wasn't being used, but some other debug call like `hid_dbg` was instead. I can eliminate that by just confirming that's not the case.
Looking at the code, it seems the crash happens when encountering an "unknown report." The core of the problem seems to be the potential evaluation of `input->dev.parent` within the `dev_dbg` call. I started by tracing the call, thinking that maybe `dev_dbg` unconditionally evaluates its first argument.
I checked the definition of `dev_dbg` and remembered it uses `dynamic_dev_dbg` which can potentially be nullified to `dev_no_printk` if `CONFIG_DYNAMIC_DEBUG` is not enabled, or `DEBUG` isn't defined. This seemed like a potential issue, as in the `dev_no_printk` case, the `dev` argument is *supposed* to be inside an `if (0)` block. Then, if the code is dead, is the `dev` argument evaluated at all? The compiler, if all is working properly, should eliminate dead code.
Then I recalled KASAN, the kernel address sanitizer, and its role as a compiler plugin. I wondered if KASAN might be instrumenting those memory accesses, even within the `if (0)` block. But that's a dead end, as KASAN would either be elided or have no affect, and the issue would be different. I went back and re-examined `dev_no_printk`. `dev` is passed to `_dev_printk` and the `_dev_printk` function is *never* called, making it's arguments un-evaluated!
I had to look at the assembly. And that's where things got interesting. The assembly shows that the stack is being read and some value is loaded into `%rax`, then an offset from `%rax` is computed. That value from `%rax` is being checked with KASAN, and this occurs before a conditional jump. Then `%rax` is loaded with some seemingly static format string. This assembly confirmed that `dev_dbg` *is* being called.
So why is it being called? I went back to the source to understand. If `DYNAMIC_DEBUG_BRANCH(id)` is true, dynamic debug is enabled for this `printk`. This prompted me to question how that setting is made in the first place, and if an unprivileged user can enable it. Dynamic debug requires root access. If dynamic debug is disabled the crash wouldn't happen.
I started to check if `dev_dbg` is always evaluated and I'm going to look to make sure it is defined as I expect it to be, in `include/linux/dev_printk.h` in the kernel source.
|
| 45/2 |
2026/09/21 01:01 |
tool |
grepper |
0m
Args: map[Expression:#define dev_dbg PathPrefix:include/linux/dev_printk.h]
Results: map[Output:include/linux/dev_printk.h=95=void _dev_info(const struct device *dev, const char *fmt, ...)
--
include/linux/dev_printk.h-163- (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
include/linux/dev_printk.h:164:#define dev_dbg(dev, fmt, ...) \
include/linux/dev_printk.h-165- dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
include/linux/dev_printk.h-166-#elif defined(DEBUG)
include/linux/dev_printk.h:167:#define dev_dbg(dev, fmt, ...) \
include/linux/dev_printk.h-168- dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
include/linux/dev_printk.h-169-#else
include/linux/dev_printk.h:170:#define dev_dbg(dev, fmt, ...) \
include/linux/dev_printk.h-171- dev_no_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
--
include/linux/dev_printk.h=186=do { \
--
include/linux/dev_printk.h-205- dev_level_once(dev_info, dev, fmt, ##__VA_ARGS__)
include/linux/dev_printk.h:206:#define dev_dbg_once(dev, fmt, ...) \
include/linux/dev_printk.h-207- dev_level_once(dev_dbg, dev, fmt, ##__VA_ARGS__)
--
include/linux/dev_printk.h=210=do { \
--
include/linux/dev_printk.h-234-/* descriptor check is first to prevent flooding with "callbacks suppressed" */
include/linux/dev_printk.h:235:#define dev_dbg_ratelimited(dev, fmt, ...) \
include/linux/dev_printk.h-236-do { \
--
include/linux/dev_printk.h-246-#elif defined(DEBUG)
include/linux/dev_printk.h:247:#define dev_dbg_ratelimited(dev, fmt, ...) \
include/linux/dev_printk.h-248-do { \
--
include/linux/dev_printk.h-255-#else
include/linux/dev_printk.h:256:#define dev_dbg_ratelimited(dev, fmt, ...) \
include/linux/dev_printk.h-257- dev_no_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
]
|
| 46/2 |
2026/09/21 01:01 |
llm |
expert |
0m
Model:
Tokens:
input: 31854
output: 31
thoughts: 535
Thoughts: **Analyzing the Potential for Device Driver Debug Information Exposure**
Okay, so I'm looking at how `dev_dbg` works and trying to understand a possible vulnerability. If `CONFIG_DYNAMIC_DEBUG` is enabled, then `dev_dbg` becomes `dynamic_dev_dbg`. Digging into that macro, it's clear it ultimately calls `__dynamic_dev_dbg`, passing the device pointer (`dev`), the format string (`fmt`), and any other arguments (`##__VA_ARGS__`). Crucially, the `dev` argument is *inside* the `if (DYNAMIC_DEBUG_BRANCH(id))` block. This means `dev` is only evaluated if that branch is taken.
Now, my initial thought is, is `DYNAMIC_DEBUG_BRANCH(id)` true by default? No, not usually. These dynamic debug statements are disabled unless someone enables them through a boot parameter, such as `ddebug_query`, or by writing to the `/sys/kernel/debug/dynamic_debug/control` file. However, syzkaller is known for messing with those sorts of things.
But that's not the only way `dev_dbg` can be defined. What if `DEBUG` is defined? If `DEBUG` is defined, `dev_dbg` becomes `dev_printk`, which always evaluates the device pointer (`dev`). That's a critical difference. In that case, the `dev` pointer would always be evaluated, regardless of dynamic debug settings. So, the question is whether `DEBUG` is defined for the target driver, `drivers/hid/wacom_wac.c`, or any driver that may be affected. Time to check the `Makefile` and see if there are any conditional compilation flags at play.
|
| 47/2 |
2026/09/21 01:01 |
tool |
read-file |
0m
Args: map[File:drivers/hid/Makefile FirstLine:1 LineCount:50]
Results: map[Contents: 1: # SPDX-License-Identifier: GPL-2.0
2: #
3: # Makefile for the HID driver
4: #
5: hid-y := hid-core.o hid-input.o hid-quirks.o
6: hid-$(CONFIG_DEBUG_FS) += hid-debug.o
7: hid-$(CONFIG_HID_HAPTIC) += hid-haptic.o
8:
9: obj-$(CONFIG_HID_BPF) += bpf/
10:
11: obj-$(CONFIG_HID) += hid.o
12: obj-$(CONFIG_UHID) += uhid.o
13:
14: obj-$(CONFIG_HID_GENERIC) += hid-generic.o
15:
16: hid-$(CONFIG_HIDRAW) += hidraw.o
17:
18: hid-logitech-y := hid-lg.o
19: hid-logitech-$(CONFIG_LOGITECH_FF) += hid-lgff.o
20: hid-logitech-$(CONFIG_LOGIRUMBLEPAD2_FF) += hid-lg2ff.o
21: hid-logitech-$(CONFIG_LOGIG940_FF) += hid-lg3ff.o
22: hid-logitech-$(CONFIG_LOGIWHEELS_FF) += hid-lg4ff.o
23:
24: hid-wiimote-y := hid-wiimote-core.o hid-wiimote-modules.o
25: hid-wiimote-$(CONFIG_DEBUG_FS) += hid-wiimote-debug.o
26:
27: obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
28: obj-$(CONFIG_HID_ACCUTOUCH) += hid-accutouch.o
29: obj-$(CONFIG_HID_ALPS) += hid-alps.o
30: obj-$(CONFIG_HID_ACRUX) += hid-axff.o
31: obj-$(CONFIG_HID_APPLE) += hid-apple.o
32: obj-$(CONFIG_HID_APPLEIR) += hid-appleir.o
33: obj-$(CONFIG_HID_APPLETB_BL) += hid-appletb-bl.o
34: obj-$(CONFIG_HID_APPLETB_KBD) += hid-appletb-kbd.o
35: obj-$(CONFIG_HID_CREATIVE_SB0540) += hid-creative-sb0540.o
36: obj-$(CONFIG_HID_ASUS) += hid-asus.o
37: obj-$(CONFIG_HID_AUREAL) += hid-aureal.o
38: obj-$(CONFIG_HID_BELKIN) += hid-belkin.o
39: obj-$(CONFIG_HID_BETOP_FF) += hid-betopff.o
40: obj-$(CONFIG_HID_BIGBEN_FF) += hid-bigbenff.o
41: obj-$(CONFIG_HID_CHERRY) += hid-cherry.o
42: obj-$(CONFIG_HID_CHICONY) += hid-chicony.o
43: obj-$(CONFIG_HID_CMEDIA) += hid-cmedia.o
44: obj-$(CONFIG_HID_CORSAIR) += hid-corsair.o hid-corsair-void.o
45: obj-$(CONFIG_HID_COUGAR) += hid-cougar.o
46: obj-$(CONFIG_HID_CP2112) += hid-cp2112.o
47: obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o
48: obj-$(CONFIG_HID_DRAGONRISE) += hid-dr.o
49: obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o
50: obj-$(CONFIG_HID_ELAN) += hid-elan.o
]
|
| 48/2 |
2026/09/21 01:01 |
llm |
expert |
0m
Model:
Tokens:
input: 33885
output: 27
thoughts: 456
Thoughts: **Debugging a Potential NULL Pointer Dereference**
Okay, so I'm looking at this issue, and the first thing that jumps out is the lack of a `DEBUG` definition in the Makefile. That's a classic starting point, but wait, what about the kernel config syzkaller is using? Could it be disabling `CONFIG_DYNAMIC_DEBUG` directly, but enabling `CONFIG_DEBUG_KERNEL` or something similar, and still defining `DEBUG` in a roundabout way? No, that's unlikely; `DEBUG` is usually controlled on a file-by-file basis or through `ccflags-y += -DDEBUG`.
Now, here's a wrinkle: what if `dev_dbg` is actually aliased to `dev_no_printk`, but KASAN is still instrumenting it? Aha! Let's check whether KASAN even bothers to instrument a memory access inside an `if (0)` block. Let me visualize this:
```c
if (0) {
_dev_printk(KERN_DEBUG, input->dev.parent, ...);
}
```
Okay, the compiler parses it, builds the AST, and then, during the optimization pass, it should remove the dead code. KASAN instrumentation happens during a compiler pass, so if KASAN ran *before* dead code elimination, it *could* instrument that memory access, right? Let's consider `input->dev.parent`. KASAN would insert a check for `input + 0x328`, which is the offset of `dev.parent`. But wait! If the whole block is within `if (0)`, the whole block is eliminated. KASAN instrumentation is inserted into the Intermediate Representation (IR). If the block is eliminated, the KASAN checks are gone too! It CANNOT be that it's inside an `if (0)` statement, right? That means that `dev_dbg` *is* actually getting executed.
So, why is `dev_dbg` being executed? Maybe syzkaller enables dynamic debugging using fault injection or boot parameters? Ah, yes! Syzkaller *often* boots with `dyndbg="file * +p"` or something to enable all dynamic debugs for maximum code coverage! I'll assume that `dev_dbg` is indeed executed.
Now, the bug is a NULL pointer dereference on `wacom->pen_input`. So why is `wacom->pen_input` NULL? Time to track down where this thing is initialized. Let's see...
|
| 49/2 |
2026/09/21 01:01 |
tool |
codesearch-find-references |
0m
Args: map[Name:wacom_wac::pen_input]
Results: map[References:[map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_allocate_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2112] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_allocate_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2115] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_allocate_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2120] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_bpt_pen SourceFile:drivers/hid/wacom_wac.c SourceLine:3212] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_dtu_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:263] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_dtus_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:293] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_exit_report SourceFile:drivers/hid/wacom_wac.c SourceLine:736] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_force_proxout SourceFile:drivers/hid/wacom_wac.c SourceLine:43] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_graphire_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:345] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1215] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1224] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1242] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_bt_process_data SourceFile:drivers/hid/wacom_wac.c SourceLine:1201] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_general SourceFile:drivers/hid/wacom_wac.c SourceLine:853] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_inout SourceFile:drivers/hid/wacom_wac.c SourceLine:777] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1025] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_pro2_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1548] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_pro2_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1556] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_pro2_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1561] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_pro2_bt_pen SourceFile:drivers/hid/wacom_wac.c SourceLine:1279] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_penpartner_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:129] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_pl_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:174] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_ptu_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:234] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_register_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2173] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_register_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2200] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_release_resources SourceFile:drivers/hid/wacom_sys.c SourceLine:2339] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_set_barrel_switch3_usage SourceFile:drivers/hid/wacom_wac.c SourceLine:2322] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_basic_pro_pen SourceFile:drivers/hid/wacom_wac.c SourceLine:3596] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_cintiq SourceFile:drivers/hid/wacom_wac.c SourceLine:3610] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2133] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2144] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_intuos SourceFile:drivers/hid/wacom_wac.c SourceLine:3629] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_tpc_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1799] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_tpc_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1800] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_tpc_pen SourceFile:drivers/hid/wacom_wac.c SourceLine:1768] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_collection SourceFile:drivers/hid/wacom_wac.c SourceLine:3018] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_event SourceFile:drivers/hid/wacom_wac.c SourceLine:2966] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:3585] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:3586] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pen_event SourceFile:drivers/hid/wacom_wac.c SourceLine:2429] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pen_report SourceFile:drivers/hid/wacom_wac.c SourceLine:2586] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pen_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2341] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_report SourceFile:drivers/hid/wacom_wac.c SourceLine:3056]] TruncatedOutput:false]
|
| 50/2 |
2026/09/21 01:01 |
llm |
expert |
0m
Model:
Tokens:
input: 40558
output: 39
thoughts: 17
Thoughts: Okay, here's my interpretation of that thought process, from an expert's perspective:
**Allocation of Input Structures for Wacom Devices**
Right, so we're diving into the Wacom driver, specifically the input handling. The function `wacom_allocate_inputs` is the key here. From the name, it's pretty clear: its primary function is to allocate the input structures related to a Wacom tablet. I'm assuming we're dealing with the core input layer here, not just setting up the device, or initializing the hardware.
What's it allocating? Ah, it's allocating `wacom->pen_input`. This tells me that the focus is on the pen input component, which is standard. Likely, this structure will hold all the necessary elements related to the pen's physical properties (e.g. pressure levels, button states, tilt data) and the associated input devices. And of course, it includes the actual `input_dev` struct, used by the kernel's input subsystem. This implies that there will also likely be the allocation of related structs.
This function is essentially the setup stage for the Wacom tablet, where we're going from the lower level hardware data to the standardized input handling system within the Linux kernel. It's the point where raw data is interpreted and prepared for higher level programs to use. This is where we hook into the whole input subsystem infrastructure, making everything compatible.
|
| 51/2 |
2026/09/21 01:01 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2100 LineCount:50]
Results: map[Contents:2100: input_dev->id.vendor = hdev->vendor;
2101: input_dev->id.product = wacom_wac->pid ? wacom_wac->pid : hdev->product;
2102: input_dev->id.version = hdev->version;
2103: input_set_drvdata(input_dev, wacom);
2104:
2105: return input_dev;
2106: }
2107:
2108: static int wacom_allocate_inputs(struct wacom *wacom)
2109: {
2110: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2111:
2112: wacom_wac->pen_input = wacom_allocate_input(wacom);
2113: wacom_wac->touch_input = wacom_allocate_input(wacom);
2114: wacom_wac->pad_input = wacom_allocate_input(wacom);
2115: if (!wacom_wac->pen_input ||
2116: !wacom_wac->touch_input ||
2117: !wacom_wac->pad_input)
2118: return -ENOMEM;
2119:
2120: wacom_wac->pen_input->name = wacom_wac->pen_name;
2121: wacom_wac->touch_input->name = wacom_wac->touch_name;
2122: wacom_wac->pad_input->name = wacom_wac->pad_name;
2123:
2124: return 0;
2125: }
2126:
2127: static int wacom_setup_inputs(struct wacom *wacom)
2128: {
2129: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
2130: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2131: int error = 0;
2132:
2133: pen_input_dev = wacom_wac->pen_input;
2134: touch_input_dev = wacom_wac->touch_input;
2135: pad_input_dev = wacom_wac->pad_input;
2136:
2137: if (!pen_input_dev || !touch_input_dev || !pad_input_dev)
2138: return -EINVAL;
2139:
2140: error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
2141: if (error) {
2142: /* no pen in use on this interface */
2143: input_free_device(pen_input_dev);
2144: wacom_wac->pen_input = NULL;
2145: pen_input_dev = NULL;
2146: }
2147:
2148: error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac);
2149: if (error) {
]
|
| 52/2 |
2026/09/21 01:01 |
llm |
expert |
0m
Model:
Tokens:
input: 41817
output: 39
thoughts: 67
Thoughts: **My Analysis of Wacom Input Setup**
Okay, so `wacom_setup_inputs` is handling the cleanup nicely. It *should* free the `pen_input_dev` and nullify `wacom_wac->pen_input` if `wacom_setup_pen_input_capabilities` returns an error. That's good, prevents a memory leak. Now, the real crux of this setup lies in that `wacom_setup_pen_input_capabilities` function. I need to understand what it's doing, the conditions it's checking, and where it might fail. Let's delve into that function and make sure there are no obvious oversights or potential issues with the capabilities setup itself, as that's the point of failure. I expect it's handling the pen's initial configuration.
|
| 53/2 |
2026/09/21 01:01 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2000 LineCount:50]
Results: map[Contents:2000: .store = wacom_store_unpair_remote,
2001: };
2002:
2003: static const struct attribute *remote_unpair_attrs[] = {
2004: &unpair_remote_attr.attr,
2005: NULL
2006: };
2007:
2008: static void wacom_remotes_destroy(void *data)
2009: {
2010: struct wacom *wacom = data;
2011: struct wacom_remote *remote = wacom->remote;
2012:
2013: if (!remote)
2014: return;
2015:
2016: kobject_put(remote->remote_dir);
2017: kfifo_free(&remote->remote_fifo);
2018: wacom->remote = NULL;
2019: }
2020:
2021: static int wacom_initialize_remotes(struct wacom *wacom)
2022: {
2023: int error = 0;
2024: struct wacom_remote *remote;
2025: int i;
2026:
2027: if (wacom->wacom_wac.features.type != REMOTE)
2028: return 0;
2029:
2030: remote = devm_kzalloc(&wacom->hdev->dev, sizeof(*wacom->remote),
2031: GFP_KERNEL);
2032: if (!remote)
2033: return -ENOMEM;
2034:
2035: wacom->remote = remote;
2036:
2037: spin_lock_init(&remote->remote_lock);
2038:
2039: error = kfifo_alloc(&remote->remote_fifo,
2040: 5 * sizeof(struct wacom_remote_work_data),
2041: GFP_KERNEL);
2042: if (error) {
2043: hid_err(wacom->hdev, "failed allocating remote_fifo\n");
2044: return -ENOMEM;
2045: }
2046:
2047: remote->remotes[0].group = remote0_serial_group;
2048: remote->remotes[1].group = remote1_serial_group;
2049: remote->remotes[2].group = remote2_serial_group;
]
|
| 54/2 |
2026/09/21 01:01 |
llm |
expert |
0m
Model:
Tokens:
input: 42799
output: 44
thoughts: 18
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Investigating Pen Input Capabilities**
Okay, so I'm digging into this code, and the first thing I'm after is the `wacom_setup_pen_input_capabilities` function. Itβs pretty clear from the name that's where the core initialization of pen input likely happens, the setting up of the groundwork for the device to respond as, well, a pen. Knowing that, and given my experience, I'm expecting to find the key initializations here, the crucial device-specific details. I'm imagining it's the gatekeeper to understanding how the driver actually *knows* what the pen *can* do, what its limitations are, and how it translates that into the system. Knowing this is critical to figuring out how the low level details get translated to the application layer.
I anticipate it'll be walking through different input modes, checking for various feature flags, possibly interacting with the hardware through some kind of register read/write mechanism... maybe even some probing for firmware versions. I'll be looking for where it sets up the data structures that'll be referenced later, things like the device capabilities struct, maybe some bitfields indicating pressure sensitivity, tilt support, number of buttons, and all those device-specific nuances. And of course, I'll be tracing the error handling β I always make a note of the likely failure cases, the corner cases. That gives me a head start on debugging later.
|
| 55/2 |
2026/09/21 01:01 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_sys.c Name:wacom_setup_pen_input_capabilities]
Results: map[SourceCode:3801: int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3802: struct wacom_wac *wacom_wac)
3803: {
3804: struct wacom_features *features = &wacom_wac->features;
3805:
3806: if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3807: return -ENODEV;
3808:
3809: if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3810: __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3811: else
3812: __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3813:
3814: if (features->type == HID_GENERIC)
3815: /* setup has already been done */
3816: return 0;
3817:
3818: input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3819: __set_bit(BTN_TOUCH, input_dev->keybit);
3820: __set_bit(ABS_MISC, input_dev->absbit);
3821:
3822: input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3823: features->x_max - features->offset_right,
3824: features->x_fuzz, 0);
3825: input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3826: features->y_max - features->offset_bottom,
3827: features->y_fuzz, 0);
3828: input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3829: features->pressure_max, features->pressure_fuzz, 0);
3830:
3831: /* penabled devices have fixed resolution for each model */
3832: input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3833: input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3834:
3835: switch (features->type) {
3836: case GRAPHIRE_BT:
3837: __clear_bit(ABS_MISC, input_dev->absbit);
3838: fallthrough;
3839:
3840: case WACOM_MO:
3841: case WACOM_G4:
3842: input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3843: features->distance_max,
3844: features->distance_fuzz, 0);
3845: fallthrough;
3846:
3847: case GRAPHIRE:
3848: input_set_capability(input_dev, EV_REL, REL_WHEEL);
3849:
3850: __set_bit(BTN_LEFT, input_dev->keybit);
3851: __set_bit(BTN_RIGHT, input_dev->keybit);
3852: __set_bit(BTN_MIDDLE, input_dev->keybit);
3853:
3854: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3855: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3856: __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3857: __set_bit(BTN_STYLUS, input_dev->keybit);
3858: __set_bit(BTN_STYLUS2, input_dev->keybit);
3859: break;
3860:
3861: case WACOM_27QHD:
3862: case WACOM_24HD:
3863: case DTK:
3864: case WACOM_22HD:
3865: case WACOM_21UX2:
3866: case WACOM_BEE:
3867: case CINTIQ:
3868: case WACOM_13HD:
3869: case CINTIQ_HYBRID:
3870: case CINTIQ_COMPANION_2:
3871: input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3872: input_abs_set_res(input_dev, ABS_Z, 287);
3873: wacom_setup_cintiq(wacom_wac);
3874: break;
3875:
3876: case INTUOS3:
3877: case INTUOS3L:
3878: case INTUOS3S:
3879: case INTUOS4:
3880: case INTUOS4WL:
3881: case INTUOS4L:
3882: case INTUOS4S:
3883: input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3884: input_abs_set_res(input_dev, ABS_Z, 287);
3885: fallthrough;
3886:
3887: case INTUOS:
3888: wacom_setup_intuos(wacom_wac);
3889: break;
3890:
3891: case INTUOS5:
3892: case INTUOS5L:
3893: case INTUOSPM:
3894: case INTUOSPL:
3895: case INTUOS5S:
3896: case INTUOSPS:
3897: case INTUOSP2_BT:
3898: case INTUOSP2S_BT:
3899: input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3900: features->distance_max,
3901: features->distance_fuzz, 0);
3902:
3903: input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3904: input_abs_set_res(input_dev, ABS_Z, 287);
3905:
3906: wacom_setup_intuos(wacom_wac);
3907: break;
3908:
3909: case WACOM_24HDT:
3910: case WACOM_27QHDT:
3911: case MTSCREEN:
3912: case MTTPC:
3913: case MTTPC_B:
3914: case TABLETPC2FG:
3915: case TABLETPC:
3916: case TABLETPCE:
3917: __clear_bit(ABS_MISC, input_dev->absbit);
3918: fallthrough;
3919:
3920: case DTUS:
3921: case DTUSX:
3922: case PL:
3923: case DTU:
3924: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3925: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3926: __set_bit(BTN_STYLUS, input_dev->keybit);
3927: __set_bit(BTN_STYLUS2, input_dev->keybit);
3928: break;
3929:
3930: case PTU:
3931: __set_bit(BTN_STYLUS2, input_dev->keybit);
3932: fallthrough;
3933:
3934: case PENPARTNER:
3935: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3936: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3937: __set_bit(BTN_STYLUS, input_dev->keybit);
3938: break;
3939:
3940: case INTUOSHT:
3941: case BAMBOO_PT:
3942: case BAMBOO_PEN:
3943: case INTUOSHT2:
3944: case INTUOSHT3_BT:
3945: if (features->type == INTUOSHT2 ||
3946: features->type == INTUOSHT3_BT) {
3947: wacom_setup_basic_pro_pen(wacom_wac);
3948: } else {
3949: __clear_bit(ABS_MISC, input_dev->absbit);
3950: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3951: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3952: __set_bit(BTN_STYLUS, input_dev->keybit);
3953: __set_bit(BTN_STYLUS2, input_dev->keybit);
3954: input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3955: features->distance_max,
3956: features->distance_fuzz, 0);
3957: }
3958: break;
3959: case BAMBOO_PAD:
3960: __clear_bit(ABS_MISC, input_dev->absbit);
3961: break;
3962: }
3963: return 0;
3964: }
SourceFile:drivers/hid/wacom_wac.c]
|
| 56/2 |
2026/09/21 01:01 |
llm |
expert |
0m
Model:
Tokens:
input: 45951
output: 40
thoughts: 125
Thoughts: Okay, let me break this down.
**My Analysis of Wacom Pen Input Initialization**
Right, so `wacom_setup_pen_input_capabilities` is the gatekeeper. It's supposed to determine if the device is actually a pen device. The code says that if the `device_type` field doesn't have the `WACOM_DEVICETYPE_PEN` bit set, it's going to return `-ENODEV`. Makes sense; can't set up pen input if it's not a pen device, or if it isn't configured as such.
Now, here's the crucial part. If that `-ENODEV` pops up, indicating a pen isn't supported or isn't detected as present, `wacom_setup_inputs` jumps into action. It frees `pen_input_dev` β the input device representing the pen β and *crucially*, sets `wacom_wac->pen_input = NULL`. This is the signal that pen input isn't initialized. I need to keep this in mind as I debug the subsequent code.
Okay, so far so good. I know how pen input is *supposed* to be set up. But, that's assuming that the device is correctly identified.
Now the interesting thing, when a device is connected and an interrupt comes... which is likely a pen input event, `wacom_intuos_irq` gets called. Hold on a second, though, wasn't that supposed to be disabled? Ah, it makes sense now, `wacom_intuos_irq` is called by `wacom_wac_irq`. I need to figure out how this is correctly handled. I have a feeling there's a race condition or some unexpected logic flow that is leading to issues. I need to check how the input events are handled at the lower levels and ensure that `pen_input_dev` is used correctly. This could indicate a problem if the pen input is expected but wasn't properly initialized. I'll need to double check that NULL check.
|
| 57/2 |
2026/09/21 01:02 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3550 LineCount:50]
Results: map[Contents:3550: break;
3551:
3552: case BAMBOO_PT:
3553: case BAMBOO_PEN:
3554: case BAMBOO_TOUCH:
3555: case INTUOSHT:
3556: case INTUOSHT2:
3557: if (wacom_wac->data[0] == WACOM_REPORT_USB)
3558: sync = wacom_status_irq(wacom_wac, len);
3559: else
3560: sync = wacom_bpt_irq(wacom_wac, len);
3561: break;
3562:
3563: case BAMBOO_PAD:
3564: sync = wacom_bamboo_pad_irq(wacom_wac, len);
3565: break;
3566:
3567: case WIRELESS:
3568: sync = wacom_wireless_irq(wacom_wac, len);
3569: break;
3570:
3571: case REMOTE:
3572: sync = false;
3573: if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
3574: wacom_remote_status_irq(wacom_wac, len);
3575: else
3576: sync = wacom_remote_irq(wacom_wac, len);
3577: break;
3578:
3579: default:
3580: sync = false;
3581: break;
3582: }
3583:
3584: if (sync) {
3585: if (wacom_wac->pen_input)
3586: input_sync(wacom_wac->pen_input);
3587: if (wacom_wac->touch_input)
3588: input_sync(wacom_wac->touch_input);
3589: if (wacom_wac->pad_input)
3590: input_sync(wacom_wac->pad_input);
3591: }
3592: }
3593:
3594: static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
3595: {
3596: struct input_dev *input_dev = wacom_wac->pen_input;
3597:
3598: input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
3599:
]
|
| 58/2 |
2026/09/21 01:02 |
llm |
expert |
0m
Model:
Tokens:
input: 47299
output: 40
thoughts: 27
Thoughts: Here's my take on the thought process, as though I were the one thinking it:
**Interrupt Handler Investigation**
Okay, so the `wacom_bpt_irq` interrupt handler has been triggered. My first step is to confirm that this is indeed the routine I'm dealing with. Let's delve into the `wacom_bpt_irq` function. I need to understand what events are generating the interrupt, what the interrupt handler is designed to do, and the context in which it's operating. I'm going to start by reviewing the interrupt service routine itself, looking for any immediate clues about its function and the hardware it's managing. I need to quickly ascertain the function's responsibility, and then begin to reconstruct the chain of events that lead to this interrupt, especially the devices or operations that trigger it.
|
| 59/2 |
2026/09/21 01:02 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3280 LineCount:50]
Results: map[Contents:3280:
3281: return 1;
3282: }
3283:
3284: static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
3285: {
3286: struct wacom_features *features = &wacom->features;
3287:
3288: if ((features->type == INTUOSHT2) &&
3289: (features->device_type & WACOM_DEVICETYPE_PEN))
3290: return wacom_intuos_irq(wacom);
3291: else if (len == WACOM_PKGLEN_BBTOUCH)
3292: return wacom_bpt_touch(wacom);
3293: else if (len == WACOM_PKGLEN_BBTOUCH3)
3294: return wacom_bpt3_touch(wacom);
3295: else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
3296: return wacom_bpt_pen(wacom);
3297:
3298: return 0;
3299: }
3300:
3301: static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
3302: unsigned char *data)
3303: {
3304: unsigned char prefix;
3305:
3306: /*
3307: * We need to reroute the event from the debug interface to the
3308: * pen interface.
3309: * We need to add the report ID to the actual pen report, so we
3310: * temporary overwrite the first byte to prevent having to kzalloc/kfree
3311: * and memcpy the report.
3312: */
3313: prefix = data[0];
3314: data[0] = WACOM_REPORT_BPAD_PEN;
3315:
3316: /*
3317: * actually reroute the event.
3318: * No need to check if wacom->shared->pen is valid, hid_input_report()
3319: * will check for us.
3320: */
3321: hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
3322: WACOM_PKGLEN_PENABLED, 1);
3323:
3324: data[0] = prefix;
3325: }
3326:
3327: static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
3328: unsigned char *data)
3329: {
]
|
| 60/2 |
2026/09/21 01:02 |
llm |
expert |
0m
Model:
Tokens:
input: 48318
output: 40
thoughts: 403
Thoughts: **Debugging a Wacom Pen Input Issue**
Okay, let's break this down. My initial thought is: the `wacom_bpt_irq` function is clearly checking for the `WACOM_DEVICETYPE_PEN` flag. If it's set, which it should be in this scenario, then it calls `wacom_intuos_irq`. But, hang on a second... if that flag *is* set, then `wacom_setup_pen_input_capabilities` wouldn't have returned `-ENODEV`, right? The code explicitly checks for that. So, the `pen_input` device should *not* be NULL. And yet, it is.
So, why is `pen_input` unexpectedly NULL? It's allocated in `wacom_allocate_inputs`, so I need to check how it could be unset later. The obvious first thought is allocation failure in `wacom_allocate_inputs`, which would return `-ENOMEM`. But if that happened, `wacom_probe` itself would fail, right? The device wouldn't even register. So, that's likely not the problem.
Aha! What about the post-allocation setup? The code *does* call `wacom_setup_pen_input_capabilities` after allocation. The code snippet shows this:
```c
error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
if (error) {
/* no pen in use on this interface */
input_free_device(pen_input_dev);
wacom_wac->pen_input = NULL;
pen_input_dev = NULL;
}
```
If that function returns an *error* other than `-ENODEV`, it deallocates the input device and sets `pen_input` to NULL. That's a definite possibility! I need to re-examine the implementation of `wacom_setup_pen_input_capabilities` to understand what other errors could be returned. I need to figure out which failures would result in the device being freed and the `pen_input` pointer being set to NULL. That's where I need to focus my attention.
|
| 61/2 |
2026/09/21 01:02 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3800 LineCount:50]
Results: map[Contents:3800:
3801: int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3802: struct wacom_wac *wacom_wac)
3803: {
3804: struct wacom_features *features = &wacom_wac->features;
3805:
3806: if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3807: return -ENODEV;
3808:
3809: if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3810: __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3811: else
3812: __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3813:
3814: if (features->type == HID_GENERIC)
3815: /* setup has already been done */
3816: return 0;
3817:
3818: input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3819: __set_bit(BTN_TOUCH, input_dev->keybit);
3820: __set_bit(ABS_MISC, input_dev->absbit);
3821:
3822: input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3823: features->x_max - features->offset_right,
3824: features->x_fuzz, 0);
3825: input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3826: features->y_max - features->offset_bottom,
3827: features->y_fuzz, 0);
3828: input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3829: features->pressure_max, features->pressure_fuzz, 0);
3830:
3831: /* penabled devices have fixed resolution for each model */
3832: input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3833: input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3834:
3835: switch (features->type) {
3836: case GRAPHIRE_BT:
3837: __clear_bit(ABS_MISC, input_dev->absbit);
3838: fallthrough;
3839:
3840: case WACOM_MO:
3841: case WACOM_G4:
3842: input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3843: features->distance_max,
3844: features->distance_fuzz, 0);
3845: fallthrough;
3846:
3847: case GRAPHIRE:
3848: input_set_capability(input_dev, EV_REL, REL_WHEEL);
3849:
]
|
| 62/2 |
2026/09/21 01:02 |
llm |
expert |
0m
Model:
Tokens:
input: 50127
output: 39
thoughts: 91
Thoughts: **Debugging a Wacom Driver Issue**
Okay, so I'm seeing a consistent behavior here that's bugging me. Specifically, when `features->device_type` indicates a pen device (using `WACOM_DEVICETYPE_PEN`), the function is *always* returning 0, and not reporting any other errors. That's highly suspect, it's not the correct behaviour and I'm not seeing any other errors.
Aha! What if the problem *isn't* inside `wacom_setup_pen_input_capabilities`, but happens *after* that, within the call to `wacom_setup_inputs`? That could explain the symptoms. Let's dig into that `wacom_setup_inputs` function. I'll need to check the code in `drivers/hid/wacom_sys.c` and see what it's doing. Hopefully, I'll see something obvious when inspecting this part of the code.
|
| 63/2 |
2026/09/21 01:02 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2130 LineCount:50]
Results: map[Contents:2130: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2131: int error = 0;
2132:
2133: pen_input_dev = wacom_wac->pen_input;
2134: touch_input_dev = wacom_wac->touch_input;
2135: pad_input_dev = wacom_wac->pad_input;
2136:
2137: if (!pen_input_dev || !touch_input_dev || !pad_input_dev)
2138: return -EINVAL;
2139:
2140: error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
2141: if (error) {
2142: /* no pen in use on this interface */
2143: input_free_device(pen_input_dev);
2144: wacom_wac->pen_input = NULL;
2145: pen_input_dev = NULL;
2146: }
2147:
2148: error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac);
2149: if (error) {
2150: /* no touch in use on this interface */
2151: input_free_device(touch_input_dev);
2152: wacom_wac->touch_input = NULL;
2153: touch_input_dev = NULL;
2154: }
2155:
2156: error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
2157: if (error) {
2158: /* no pad events using this interface */
2159: input_free_device(pad_input_dev);
2160: wacom_wac->pad_input = NULL;
2161: pad_input_dev = NULL;
2162: }
2163:
2164: return 0;
2165: }
2166:
2167: static int wacom_register_inputs(struct wacom *wacom)
2168: {
2169: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
2170: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2171: int error = 0;
2172:
2173: pen_input_dev = wacom_wac->pen_input;
2174: touch_input_dev = wacom_wac->touch_input;
2175: pad_input_dev = wacom_wac->pad_input;
2176:
2177: if (pen_input_dev) {
2178: error = input_register_device(pen_input_dev);
2179: if (error)
]
|
| 64/2 |
2026/09/21 01:02 |
llm |
expert |
0m
Model:
Tokens:
input: 51298
output: 39
thoughts: 259
Thoughts: **My Initial Conundrum**
Okay, so I'm digging into this Wacom driver code, and I've hit a head-scratcher. Specifically, `wacom_wac->pen_input` is getting set to NULL if `wacom_setup_pen_input_capabilities` fails. Fair enough. I see that the function returns `-ENODEV` if the device doesn't have pen capabilities, which is checked with `!(features->device_type & WACOM_DEVICETYPE_PEN)`. Therefore, if the `device_type` mask *doesn't* include the pen bit, `pen_input` ends up being NULL. Makes perfect sense, so far.
But then... wait a minute! Looking at `wacom_bpt_irq`, I see a conditional check:
```c
if ((features->type == INTUOSHT2) &&
(features->device_type & WACOM_DEVICETYPE_PEN))
return wacom_intuos_irq(wacom);
```
This *explicitly* checks `features->device_type & WACOM_DEVICETYPE_PEN`! If that bit is TRUE, and given the context, then `pen_input` *shouldn't* be NULL. It's supposed to be initialized, right? So, why am I seeing this as NULL? Something isn't adding up.
Did something change? Is it possible that `features->device_type` is being modified *after* `wacom_setup_inputs` has run? Or is it possible that `wacom_setup_inputs` was never called? Time to go back and check `wacom_probe`.
|
| 65/2 |
2026/09/21 01:02 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2700 LineCount:50]
Results: map[Contents:2700: devres_release_group(dev, &remote->remotes[index]);
2701: remote->remotes[index].serial = 0;
2702: return error;
2703: }
2704:
2705: static int wacom_remote_attach_battery(struct wacom *wacom, int index)
2706: {
2707: struct wacom_remote *remote = wacom->remote;
2708: int error;
2709:
2710: if (!remote->remotes[index].registered)
2711: return 0;
2712:
2713: if (remote->remotes[index].battery.battery)
2714: return 0;
2715:
2716: if (!remote->remotes[index].active_time)
2717: return 0;
2718:
2719: if (wacom->led.groups[index].select == WACOM_STATUS_UNKNOWN)
2720: return 0;
2721:
2722: error = __wacom_initialize_battery(wacom,
2723: &wacom->remote->remotes[index].battery);
2724: if (error)
2725: return error;
2726:
2727: return 0;
2728: }
2729:
2730: static void wacom_remote_work(struct work_struct *work)
2731: {
2732: struct wacom *wacom = container_of(work, struct wacom, remote_work);
2733: struct wacom_remote *remote = wacom->remote;
2734: ktime_t kt = ktime_get();
2735: struct wacom_remote_work_data remote_work_data;
2736: unsigned long flags;
2737: unsigned int count;
2738: u32 work_serial;
2739: int i;
2740:
2741: spin_lock_irqsave(&remote->remote_lock, flags);
2742:
2743: count = kfifo_out(&remote->remote_fifo, &remote_work_data,
2744: sizeof(remote_work_data));
2745:
2746: if (count != sizeof(remote_work_data)) {
2747: hid_err(wacom->hdev,
2748: "workitem triggered without status available\n");
2749: spin_unlock_irqrestore(&remote->remote_lock, flags);
]
|
| 66/2 |
2026/09/21 01:02 |
llm |
expert |
0m
Model:
Tokens:
input: 52702
output: 38
thoughts: 10
Thoughts: Okay, here's my summary, framed in the first person, as if these are my immediate thoughts, knowing I'm discussing this with a fellow expert:
**Locating the Wacom Probe**
Alright, so I'm on the hunt for `wacom_probe`. I need to get my hands on it, understand what it's doing, and where it fits into the whole Wacom ecosystem. This isn't a casual search; I need to quickly and efficiently track it down. My immediate questions are: is this a kernel module, a user-space utility, or maybe even something embedded in a larger framework? The name suggests it's likely involved in device detection or initialization, but I need to confirm that.
If it's a kernel module, I'll start checking the usual suspects β the kernel source tree, relevant documentation directories, and looking for module aliases that might help me identify its purpose if the name isn't immediately obvious. I'll probably fire up `modinfo` and see what that turns up, maybe cross-reference its dependencies.
If it's user-space, the search becomes slightly broader. I'd check typical places like `/usr/bin`, `/usr/sbin`, maybe even look at packages like `xserver-xorg-input-wacom`, and related libraries. I'd definitely use `find` and `locate` with relevant keywords, and possibly delve into package management tools to see if it's part of a specific distribution or build. I'll need to look at any surrounding context too β is it called by a specific service, or a configuration file? The more context I have, the better my chances of zeroing in.
Ultimately, I need to understand its role and how it interacts with the rest of the Wacom stack, to determine its significance. So, let's dive in and get to work!
|
| 67/2 |
2026/09/21 01:02 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_sys.c Name:wacom_probe]
Results: map[SourceCode:2822: static int wacom_probe(struct hid_device *hdev,
2823: const struct hid_device_id *id)
2824: {
2825: struct wacom *wacom;
2826: struct wacom_wac *wacom_wac;
2827: struct wacom_features *features;
2828: int error;
2829:
2830: if (!id->driver_data)
2831: return -EINVAL;
2832:
2833: hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS;
2834:
2835: /* hid-core sets this quirk for the boot interface */
2836: hdev->quirks &= ~HID_QUIRK_NOGET;
2837:
2838: wacom = devm_kzalloc(&hdev->dev, sizeof(struct wacom), GFP_KERNEL);
2839: if (!wacom)
2840: return -ENOMEM;
2841:
2842: hid_set_drvdata(hdev, wacom);
2843: wacom->hdev = hdev;
2844:
2845: wacom_wac = &wacom->wacom_wac;
2846: wacom_wac->features = *((struct wacom_features *)id->driver_data);
2847: features = &wacom_wac->features;
2848:
2849: if (features->check_for_hid_type && features->hid_type != hdev->type)
2850: return -ENODEV;
2851:
2852: wacom_wac->hid_data.inputmode = -1;
2853: wacom_wac->hid_data.inputmode_field_index = -1;
2854: wacom_wac->mode_report = -1;
2855:
2856: if (hid_is_usb(hdev)) {
2857: struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
2858: struct usb_device *dev = interface_to_usbdev(intf);
2859:
2860: wacom->usbdev = dev;
2861: wacom->intf = intf;
2862: }
2863:
2864: mutex_init(&wacom->lock);
2865: INIT_DELAYED_WORK(&wacom->init_work, wacom_init_work);
2866: INIT_DELAYED_WORK(&wacom->aes_battery_work, wacom_aes_battery_handler);
2867: INIT_WORK(&wacom->wireless_work, wacom_wireless_work);
2868: INIT_WORK(&wacom->battery_work, wacom_battery_work);
2869: INIT_WORK(&wacom->remote_work, wacom_remote_work);
2870: INIT_WORK(&wacom->mode_change_work, wacom_mode_change_work);
2871: timer_setup(&wacom->idleprox_timer, &wacom_idleprox_timeout, TIMER_DEFERRABLE);
2872:
2873: /* ask for the report descriptor to be loaded by HID */
2874: error = hid_parse(hdev);
2875: if (error) {
2876: hid_err(hdev, "parse failed\n");
2877: return error;
2878: }
2879:
2880: if (features->type == BOOTLOADER) {
2881: hid_warn(hdev, "Using device in hidraw-only mode");
2882: return hid_hw_start(hdev, HID_CONNECT_HIDRAW);
2883: }
2884:
2885: error = wacom_parse_and_register(wacom, false);
2886: if (error)
2887: return error;
2888:
2889: if (hdev->bus == BUS_BLUETOOTH) {
2890: error = device_create_file(&hdev->dev, &dev_attr_speed);
2891: if (error)
2892: hid_warn(hdev,
2893: "can't create sysfs speed attribute err: %d\n",
2894: error);
2895: }
2896:
2897: wacom_wac->probe_complete = true;
2898: return 0;
2899: }
SourceFile:drivers/hid/wacom_sys.c]
|
| 68/2 |
2026/09/21 01:02 |
llm |
expert |
0m
Model:
Tokens:
input: 54447
output: 42
thoughts: 19
Thoughts: Here's a summary of my thought process, as requested:
**Diving into Wacom Device Initialization**
Okay, `wacom_parse_and_register` has been invoked. Let's dig in and see exactly what's happening. I know the Wacom driver pretty well, but it's always good to refresh my memory and verify the device parsing and registration are occurring as expected. It's the core of how new Wacom devices get integrated, so it's a critical point to scrutinize. I'll pay close attention to the data structures involved, the error handling, and how the device information is ultimately presented to the input subsystem. I expect to see the typical sequence: parsing the device description, creating internal device representations, registering the device with the input core, and potentially, setting up some initial configuration. Let's get to it.
|
| 69/2 |
2026/09/21 01:02 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_sys.c Name:wacom_parse_and_register]
Results: map[SourceCode:2370: static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
2371: {
2372: struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2373: struct wacom_features *features = &wacom_wac->features;
2374: struct hid_device *hdev = wacom->hdev;
2375: int error;
2376: unsigned int connect_mask = HID_CONNECT_HIDRAW;
2377:
2378: features->pktlen = wacom_compute_pktlen(hdev);
2379: if (!features->pktlen)
2380: return -ENODEV;
2381:
2382: if (!devres_open_group(&hdev->dev, wacom, GFP_KERNEL))
2383: return -ENOMEM;
2384:
2385: error = wacom_devm_kfifo_alloc(wacom);
2386: if (error)
2387: goto fail;
2388:
2389: wacom->resources = true;
2390:
2391: error = wacom_allocate_inputs(wacom);
2392: if (error)
2393: goto fail;
2394:
2395: /*
2396: * Bamboo Pad has a generic hid handling for the Pen, and we switch it
2397: * into debug mode for the touch part.
2398: * We ignore the other interfaces.
2399: */
2400: if (features->type == BAMBOO_PAD) {
2401: if (features->pktlen == WACOM_PKGLEN_PENABLED) {
2402: features->type = HID_GENERIC;
2403: } else if ((features->pktlen != WACOM_PKGLEN_BPAD_TOUCH) &&
2404: (features->pktlen != WACOM_PKGLEN_BPAD_TOUCH_USB)) {
2405: error = -ENODEV;
2406: goto fail;
2407: }
2408: }
2409:
2410: /* set the default size in case we do not get them from hid */
2411: wacom_set_default_phy(features);
2412:
2413: /* Retrieve the physical and logical size for touch devices */
2414: wacom_retrieve_hid_descriptor(hdev, features);
2415: wacom_setup_device_quirks(wacom);
2416:
2417: if (features->device_type == WACOM_DEVICETYPE_NONE &&
2418: features->type != WIRELESS) {
2419: error = features->type == HID_GENERIC ? -ENODEV : 0;
2420:
2421: dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.",
2422: hdev->name,
2423: error ? "Ignoring" : "Assuming pen");
2424:
2425: if (error)
2426: goto fail;
2427:
2428: features->device_type |= WACOM_DEVICETYPE_PEN;
2429: }
2430:
2431: wacom_calculate_res(features);
2432:
2433: wacom_update_name(wacom, wireless ? " (WL)" : "");
2434:
2435: /* pen only Bamboo neither support touch nor pad */
2436: if ((features->type == BAMBOO_PEN) &&
2437: ((features->device_type & WACOM_DEVICETYPE_TOUCH) ||
2438: (features->device_type & WACOM_DEVICETYPE_PAD))) {
2439: error = -ENODEV;
2440: goto fail;
2441: }
2442:
2443: error = wacom_add_shared_data(hdev);
2444: if (error)
2445: goto fail;
2446:
2447: error = wacom_setup_inputs(wacom);
2448: if (error)
2449: goto fail;
2450:
2451: if (features->type == HID_GENERIC)
2452: connect_mask |= HID_CONNECT_DRIVER;
2453:
2454: /* Regular HID work starts now */
2455: error = hid_hw_start(hdev, connect_mask);
2456: if (error) {
2457: hid_err(hdev, "hw start failed\n");
2458: goto fail;
2459: }
2460:
2461: error = wacom_register_inputs(wacom);
2462: if (error)
2463: goto fail_hw_stop;
2464:
2465: if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) {
2466: error = wacom_initialize_leds(wacom);
2467: if (error)
2468: goto fail_hw_stop;
2469:
2470: error = wacom_initialize_remotes(wacom);
2471: if (error)
2472: goto fail_hw_stop;
2473: }
2474:
2475: if (!wireless) {
2476: /* Note that if query fails it is not a hard failure */
2477: wacom_query_tablet_data(wacom);
2478: }
2479:
2480: /* touch only Bamboo doesn't support pen */
2481: if ((features->type == BAMBOO_TOUCH) &&
2482: (features->device_type & WACOM_DEVICETYPE_PEN)) {
2483: cancel_delayed_work_sync(&wacom->init_work);
2484: _wacom_query_tablet_data(wacom);
2485: error = -ENODEV;
2486: goto fail_hw_stop;
2487: }
2488:
2489: if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) {
2490: error = hid_hw_open(hdev);
2491: if (error) {
2492: hid_err(hdev, "hw open failed\n");
2493: goto fail_hw_stop;
2494: }
2495: }
2496:
2497: wacom_set_shared_values(wacom_wac);
2498: devres_close_group(&hdev->dev, wacom);
2499:
2500: return 0;
2501:
2502: fail_hw_stop:
2503: hid_hw_stop(hdev);
2504: fail:
2505: wacom_release_resources(wacom);
2506: return error;
2507: }
SourceFile:drivers/hid/wacom_sys.c]
|
| 70/2 |
2026/09/21 01:02 |
llm |
expert |
0m
Model:
Tokens:
input: 56732
output: 26
thoughts: 1105
Thoughts: **Analyzing the Wacom Driver Initialization and Interrupt Handling**
Okay, let's break this down. I'm looking at the `wacom_parse_and_register` function, and my immediate concern is the potential for a race condition or incorrect state within the pen input handling.
Initially, `wacom_setup_inputs` is called, and I see the crucial line where `wacom_wac->pen_input` *could* be set to `NULL` if `wacom_setup_pen_input_capabilities` returns an error, specifically `-ENODEV`. Then, `hid_hw_start` is called, which might trigger an interrupt. If an interrupt occurs, it calls `wacom_wac_irq`, and within that, `wacom_bpt_irq` is dispatched. The `wacom_bpt_irq` calls `wacom_intuos_irq` if `features->device_type & WACOM_DEVICETYPE_PEN` is true.
My thought is, *if* `features->device_type` indicates a pen device (i.e., this bit is set), then `wacom_setup_pen_input_capabilities` should *not* be returning an error. So, logically, `wacom_wac->pen_input` shouldn't be `NULL`. This suggests a potential inconsistency.
Let me double-check `wacom_setup_pen_input_capabilities`. Okay, I see that it explicitly checks `features->device_type & WACOM_DEVICETYPE_PEN` *at the beginning* and returns `-ENODEV` only if this check *fails*. Otherwise, it returns 0. So, the direct cause of `wacom_wac->pen_input` being `NULL` in the INTUOSHT2 case is not due to a fail in `wacom_setup_pen_input_capabilities` when `features->device_type & WACOM_DEVICETYPE_PEN` is set.
My next hunch is, perhaps, `wacom_allocate_inputs` is failing. However, it looks like if the allocations for pen, touch, or pad inputs fail, `wacom_parse_and_register` will return an error *before* getting to `hid_hw_start`. So, an allocation failure will not cause a `NULL` `pen_input`.
What about `wacom_setup_touch_input_capabilities` or `wacom_setup_pad_input_capabilities` failing and therefore the input being set to `NULL`? However, it looks like only the `touch_input` is freed and set to `NULL` if this setup fails. This also doesn't affect `pen_input`.
Finally, is it possible that `features->device_type` is modified *after* `wacom_setup_inputs` has run, creating a mismatch? This would be a crucial point to investigate. It seems that `features->device_type` must remain constant during the initialization and interrupt handling for this logic to be sound. I'll need to trace all modifications to `features->device_type` within the device initialization and interrupt handling code.
|
| 71/2 |
2026/09/21 01:03 |
tool |
codesearch-find-references |
0m
Args: map[Name:wacom_features::device_type]
Results: map[References:[map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:_wacom_query_tablet_data SourceFile:drivers/hid/wacom_sys.c SourceLine:696] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:_wacom_query_tablet_data SourceFile:drivers/hid/wacom_sys.c SourceLine:711] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_add_shared_data SourceFile:drivers/hid/wacom_sys.c SourceLine:918] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_add_shared_data SourceFile:drivers/hid/wacom_sys.c SourceLine:920] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_are_sibling SourceFile:drivers/hid/wacom_sys.c SourceLine:804] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_are_sibling SourceFile:drivers/hid/wacom_sys.c SourceLine:805] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_are_sibling SourceFile:drivers/hid/wacom_sys.c SourceLine:812] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_are_sibling SourceFile:drivers/hid/wacom_sys.c SourceLine:813] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_are_sibling SourceFile:drivers/hid/wacom_sys.c SourceLine:817] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_are_sibling SourceFile:drivers/hid/wacom_sys.c SourceLine:818] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_are_sibling SourceFile:drivers/hid/wacom_sys.c SourceLine:822] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_are_sibling SourceFile:drivers/hid/wacom_sys.c SourceLine:823] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_bpt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:3289] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_initialize_leds SourceFile:drivers/hid/wacom_sys.c SourceLine:1611] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_parse_and_register SourceFile:drivers/hid/wacom_sys.c SourceLine:2417] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_parse_and_register SourceFile:drivers/hid/wacom_sys.c SourceLine:2428] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_parse_and_register SourceFile:drivers/hid/wacom_sys.c SourceLine:2437] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_parse_and_register SourceFile:drivers/hid/wacom_sys.c SourceLine:2438] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_parse_and_register SourceFile:drivers/hid/wacom_sys.c SourceLine:2465] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_parse_and_register SourceFile:drivers/hid/wacom_sys.c SourceLine:2482] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_parse_and_register SourceFile:drivers/hid/wacom_sys.c SourceLine:2489] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_post_parse_hid SourceFile:drivers/hid/wacom_sys.c SourceLine:505] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_post_parse_hid SourceFile:drivers/hid/wacom_sys.c SourceLine:507] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_post_parse_hid SourceFile:drivers/hid/wacom_sys.c SourceLine:511] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_remove SourceFile:drivers/hid/wacom_sys.c SourceLine:2907] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_retrieve_hid_descriptor SourceFile:drivers/hid/wacom_sys.c SourceLine:748] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_retrieve_hid_descriptor SourceFile:drivers/hid/wacom_sys.c SourceLine:750] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_set_shared_values SourceFile:drivers/hid/wacom_sys.c SourceLine:2346] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3657] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3658] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3662] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3677] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3679] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3691] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3704] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3714] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3717] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3721] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3728] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3756] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3774] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3780] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_pad_input_capabilities SourceFile:drivers/hid/wacom_wac.c SourceLine:4245] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_pad_input_capabilities SourceFile:drivers/hid/wacom_wac.c SourceLine:4247] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_pen_input_capabilities SourceFile:drivers/hid/wacom_wac.c SourceLine:3806] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_pen_input_capabilities SourceFile:drivers/hid/wacom_wac.c SourceLine:3809] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_touch_input_capabilities SourceFile:drivers/hid/wacom_wac.c SourceLine:3971] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_touch_input_capabilities SourceFile:drivers/hid/wacom_wac.c SourceLine:3974] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_usage_mapping SourceFile:drivers/hid/wacom_sys.c SourceLine:454] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_usage_mapping SourceFile:drivers/hid/wacom_sys.c SourceLine:456] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2027] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2032] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2037] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2049] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2070] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2074] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2094] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2104] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2108] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2112] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2116] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2124] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pad_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2134] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_wac_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2937]] TruncatedOutput:false]
|
| 72/2 |
2026/09/21 01:03 |
llm |
expert |
0m
Model:
Tokens:
input: 62213
output: 44
thoughts: 247
Thoughts: **My Initial Thoughts on Wacom Device Type Handling**
Right, so `wacom_parse_and_register` is changing `features->device_type`. I see it checks if `device_type` is currently `WACOM_DEVICETYPE_NONE` and it's not a wireless device. In that case, and if it's not a generic HID, it sets the error or assumes a pen. Crucially, it then *adds* `WACOM_DEVICETYPE_PEN` to `features->device_type`.
Interesting! This happens *before* `wacom_setup_inputs` is called. So, the implication is that `features->device_type` is augmented with the `PEN` bit and *then* the input setup occurs.
Now, my key question is: is there any other place where the `WACOM_DEVICETYPE_PEN` is added *after* the input setup? We need to verify the timing and sequence to ensure this behavior is consistent. Let's dig into `wacom_setup_device_quirks` to see what else is happening. This is likely where any late modification might occur.
|
| 73/2 |
2026/09/21 01:03 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_wac.c Name:wacom_setup_device_quirks]
Results: map[SourceCode:3648: void wacom_setup_device_quirks(struct wacom *wacom)
3649: {
3650: struct wacom_wac *wacom_wac = &wacom->wacom_wac;
3651: struct wacom_features *features = &wacom->wacom_wac.features;
3652:
3653: /* The pen and pad share the same interface on most devices */
3654: if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
3655: features->type == DTUS ||
3656: (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
3657: if (features->device_type & WACOM_DEVICETYPE_PEN)
3658: features->device_type |= WACOM_DEVICETYPE_PAD;
3659: }
3660:
3661: /* touch device found but size is not defined. use default */
3662: if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
3663: features->x_max = 1023;
3664: features->y_max = 1023;
3665: }
3666:
3667: /*
3668: * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3669: * touch interface in its HID descriptor. If this is the touch
3670: * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3671: * tablet values.
3672: */
3673: if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
3674: (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
3675: if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3676: if (features->touch_max)
3677: features->device_type |= WACOM_DEVICETYPE_TOUCH;
3678: if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
3679: features->device_type |= WACOM_DEVICETYPE_PAD;
3680:
3681: if (features->type == INTUOSHT2) {
3682: features->x_max = features->x_max / 10;
3683: features->y_max = features->y_max / 10;
3684: }
3685: else {
3686: features->x_max = 4096;
3687: features->y_max = 4096;
3688: }
3689: }
3690: else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3691: features->device_type |= WACOM_DEVICETYPE_PAD;
3692: }
3693: }
3694:
3695: /*
3696: * Hack for the Bamboo One:
3697: * the device presents a PAD/Touch interface as most Bamboos and even
3698: * sends ghosts PAD data on it. However, later, we must disable this
3699: * ghost interface, and we can not detect it unless we set it here
3700: * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3701: */
3702: if (features->type == BAMBOO_PEN &&
3703: features->pktlen == WACOM_PKGLEN_BBTOUCH3)
3704: features->device_type |= WACOM_DEVICETYPE_PAD;
3705:
3706: /*
3707: * Raw Wacom-mode pen and touch events both come from interface
3708: * 0, whose HID descriptor has an application usage of 0xFF0D
3709: * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
3710: * out through the HID_GENERIC device created for interface 1,
3711: * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
3712: */
3713: if (features->type == BAMBOO_PAD)
3714: features->device_type = WACOM_DEVICETYPE_TOUCH;
3715:
3716: if (features->type == REMOTE)
3717: features->device_type = WACOM_DEVICETYPE_PAD;
3718:
3719: if (features->type == INTUOSP2_BT ||
3720: features->type == INTUOSP2S_BT) {
3721: features->device_type |= WACOM_DEVICETYPE_PEN |
3722: WACOM_DEVICETYPE_PAD |
3723: WACOM_DEVICETYPE_TOUCH;
3724: features->quirks |= WACOM_QUIRK_BATTERY;
3725: }
3726:
3727: if (features->type == INTUOSHT3_BT) {
3728: features->device_type |= WACOM_DEVICETYPE_PEN |
3729: WACOM_DEVICETYPE_PAD;
3730: features->quirks |= WACOM_QUIRK_BATTERY;
3731: }
3732:
3733: switch (features->type) {
3734: case PL:
3735: case DTU:
3736: case DTUS:
3737: case DTUSX:
3738: case WACOM_21UX2:
3739: case WACOM_22HD:
3740: case DTK:
3741: case WACOM_24HD:
3742: case WACOM_27QHD:
3743: case CINTIQ_HYBRID:
3744: case CINTIQ_COMPANION_2:
3745: case CINTIQ:
3746: case WACOM_BEE:
3747: case WACOM_13HD:
3748: case WACOM_24HDT:
3749: case WACOM_27QHDT:
3750: case TABLETPC:
3751: case TABLETPCE:
3752: case TABLETPC2FG:
3753: case MTSCREEN:
3754: case MTTPC:
3755: case MTTPC_B:
3756: features->device_type |= WACOM_DEVICETYPE_DIRECT;
3757: break;
3758: }
3759:
3760: if (wacom->hdev->bus == BUS_BLUETOOTH)
3761: features->quirks |= WACOM_QUIRK_BATTERY;
3762:
3763: /* quirk for bamboo touch with 2 low res touches */
3764: if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) &&
3765: features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3766: features->x_max <<= 5;
3767: features->y_max <<= 5;
3768: features->x_fuzz <<= 5;
3769: features->y_fuzz <<= 5;
3770: features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
3771: }
3772:
3773: if (features->type == WIRELESS) {
3774: if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
3775: features->quirks |= WACOM_QUIRK_BATTERY;
3776: }
3777: }
3778:
3779: if (features->type == REMOTE)
3780: features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
3781:
3782: /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3783: * of things it shouldn't. Lets fix up the damage...
3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
SourceFile:drivers/hid/wacom_wac.c]
|
| 74/2 |
2026/09/21 01:03 |
llm |
expert |
0m
Model:
Tokens:
input: 65513
output: 27
thoughts: 919
Thoughts: **Debugging the Wacom Driver: A Deep Dive into Pen Input**
Okay, let's break this down. It looks like `wacom_setup_device_quirks` gets called *before* `wacom_setup_inputs`. That's important. I'm checking `wacom_parse_and_register`, and the flow seems pretty clear: `wacom_setup_device_quirks` sets up the initial device characteristics. Then, if the `device_type` is unknown, and it's not wireless, there's some error handling. If there's an issue, we return an error. Otherwise, we assume it's a pen and set the `device_type` accordingly. I can calculate the resolution and update the device name. Then there are some checks for pens that don't support touch or pad inputs and errors that get handled appropriately. After all that is set, we run `wacom_setup_inputs`.
So, `features->device_type` should be fully initialized *before* `wacom_setup_inputs`. If the `device_type` includes the `WACOM_DEVICETYPE_PEN` flag, the `wacom_setup_pen_input_capabilities` function shouldn't return `-ENODEV`. Therefore, `pen_input` shouldn't be set to `NULL`. I need to be absolutely sure about this; I checked and double checked `wacom_setup_pen_input_capabilities`, and it *only* returns `-ENODEV` or 0.
So, `pen_input` *should* be `NULL` only when `!(features->device_type & WACOM_DEVICETYPE_PEN)`. Now, let's consider the `wacom_bpt_irq` function. If `features->device_type & WACOM_DEVICETYPE_PEN` is FALSE, it doesn't even call `wacom_intuos_irq`. Therefore, `wacom_intuos_irq` is only *ever* called if `features->device_type & WACOM_DEVICETYPE_PEN` is TRUE.
This seems paradoxical. The code suggests that if the device is identified as a pen, `pen_input` should *not* be `NULL`, and the correct interrupt handler should be called. Yet, somehow, in the situation I'm looking at, `pen_input` *is* `NULL`. I need to figure out how this is happening. The key is in where `pen_input` is getting set to `NULL` to find out what's going on. Is there any other place where `pen_input` is being set to `NULL`? I need to check the entire codebase.
|
| 75/2 |
2026/09/21 01:03 |
tool |
codesearch-find-references |
0m
Args: map[Name:wacom_wac::pen_input]
Results: map[References:[map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_allocate_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2112] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_allocate_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2115] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_allocate_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2120] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_bpt_pen SourceFile:drivers/hid/wacom_wac.c SourceLine:3212] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_dtu_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:263] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_dtus_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:293] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_exit_report SourceFile:drivers/hid/wacom_wac.c SourceLine:736] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_force_proxout SourceFile:drivers/hid/wacom_wac.c SourceLine:43] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_graphire_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:345] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1215] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1224] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1242] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_bt_process_data SourceFile:drivers/hid/wacom_wac.c SourceLine:1201] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_general SourceFile:drivers/hid/wacom_wac.c SourceLine:853] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_inout SourceFile:drivers/hid/wacom_wac.c SourceLine:777] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1025] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_pro2_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1548] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_pro2_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1556] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_pro2_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1561] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_pro2_bt_pen SourceFile:drivers/hid/wacom_wac.c SourceLine:1279] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_penpartner_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:129] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_pl_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:174] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_ptu_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:234] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_register_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2173] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_register_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2200] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_release_resources SourceFile:drivers/hid/wacom_sys.c SourceLine:2339] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_set_barrel_switch3_usage SourceFile:drivers/hid/wacom_wac.c SourceLine:2322] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_basic_pro_pen SourceFile:drivers/hid/wacom_wac.c SourceLine:3596] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_cintiq SourceFile:drivers/hid/wacom_wac.c SourceLine:3610] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2133] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2144] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_intuos SourceFile:drivers/hid/wacom_wac.c SourceLine:3629] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_tpc_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1799] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_tpc_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1800] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_tpc_pen SourceFile:drivers/hid/wacom_wac.c SourceLine:1768] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_collection SourceFile:drivers/hid/wacom_wac.c SourceLine:3018] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_event SourceFile:drivers/hid/wacom_wac.c SourceLine:2966] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:3585] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:3586] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pen_event SourceFile:drivers/hid/wacom_wac.c SourceLine:2429] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pen_report SourceFile:drivers/hid/wacom_wac.c SourceLine:2586] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pen_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2341] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_report SourceFile:drivers/hid/wacom_wac.c SourceLine:3056]] TruncatedOutput:false]
|
| 76/2 |
2026/09/21 01:03 |
llm |
expert |
0m
Model:
Tokens:
input: 72697
output: 39
thoughts: 122
Thoughts: **Investigating the Input Device Setup**
Okay, hold on a second... `wacom_setup_inputs` is setting the input device pointers to `NULL`. That's not right. Where else could these values possibly be set? Let me scan through the code... Nope, there are only a few places where these input structures are touched. Looks like the writes are limited to: `wacom_allocate_inputs` on line 2112, `wacom_setup_inputs` on line 2144, `wacom_register_inputs` on line 2200, and finally `wacom_release_resources` on line 2339. The issue must be in one of those functions.
Let's dive into `wacom_register_inputs` at line 2200. I need to understand what's happening there.
|
| 77/2 |
2026/09/21 01:03 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2170 LineCount:50]
Results: map[Contents:2170: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2171: int error = 0;
2172:
2173: pen_input_dev = wacom_wac->pen_input;
2174: touch_input_dev = wacom_wac->touch_input;
2175: pad_input_dev = wacom_wac->pad_input;
2176:
2177: if (pen_input_dev) {
2178: error = input_register_device(pen_input_dev);
2179: if (error)
2180: goto fail;
2181: }
2182:
2183: if (touch_input_dev) {
2184: error = input_register_device(touch_input_dev);
2185: if (error)
2186: goto fail;
2187: }
2188:
2189: if (pad_input_dev) {
2190: error = input_register_device(pad_input_dev);
2191: if (error)
2192: goto fail;
2193: }
2194:
2195: return 0;
2196:
2197: fail:
2198: wacom_wac->pad_input = NULL;
2199: wacom_wac->touch_input = NULL;
2200: wacom_wac->pen_input = NULL;
2201: return error;
2202: }
2203:
2204: /*
2205: * Not all devices report physical dimensions from HID.
2206: * Compute the default from hardcoded logical dimension
2207: * and resolution before driver overwrites them.
2208: */
2209: static void wacom_set_default_phy(struct wacom_features *features)
2210: {
2211: if (features->x_resolution) {
2212: features->x_phy = (features->x_max * 100) /
2213: features->x_resolution;
2214: features->y_phy = (features->y_max * 100) /
2215: features->y_resolution;
2216: }
2217: }
2218:
2219: static void wacom_calculate_res(struct wacom_features *features)
]
|
| 78/2 |
2026/09/21 01:03 |
llm |
expert-compressor |
0m
Model:
Reply: ### Investigation Overview & Current State
The investigation focuses on a Linux kernel crash report triggered by syzkaller via `/dev/uhid`:
- **Crash Type**: KASAN null-pointer dereference (`Oops: general protection fault, probably for non-canonical address 0xdffffc0000000065`).
- **Target Location**: `wacom_intuos_irq+0x62b/0x3430` at `drivers/hid/wacom_wac.c:1036`.
- **Faulting Address / Dereference**: Dereferencing `input->dev.parent` when `input` (`wacom->pen_input`) is `NULL`. Specifically:
- `input` (`pen_input`) is NULL (0x0).
- Offset of `dev` in `struct input_dev`: 744 (0x2e8).
- Offset of `parent` in `struct device`: 64 (0x40).
- Total offset: `0x2e8 + 0x40 = 0x328`.
- KASAN checked shadow memory for range `[0x0000000000000328 - 0x000000000000032f]`. Shadow computation: `0x328 >> 3 + 0xdffffc0000000000 = 0xdffffc0000000065`, triggering GPF on non-canonical shadow access.
---
### Root Cause & Vulnerable Code Analysis
#### 1. Vulnerable Code Snippet
In `drivers/hid/wacom_wac.c`:
```c
static int wacom_intuos_irq(struct wacom_wac *wacom)
{
unsigned char *data = wacom->data;
struct input_dev *input = wacom->pen_input;
int result;
if (data[0] != WACOM_REPORT_PENABLED &&
data[0] != WACOM_REPORT_INTUOS_ID1 &&
data[0] != WACOM_REPORT_INTUOS_ID2 &&
data[0] != WACOM_REPORT_INTUOSPAD &&
data[0] != WACOM_REPORT_INTUOS_PEN &&
data[0] != WACOM_REPORT_CINTIQ &&
data[0] != WACOM_REPORT_CINTIQPAD &&
data[0] != WACOM_REPORT_INTUOS5PAD) {
dev_dbg(input->dev.parent,
"%s: received unknown report #%d\n", __func__, data[0]);
return 0;
}
...
```
Notice that `dev_dbg` accesses `input->dev.parent`. However, there is no check ensuring `input != NULL`.
#### 2. Call Chain Leading to Crash
From syzkaller call trace:
```
entry_SYSCALL_64_after_hwframe
ksys_write
vfs_write
uhid_char_write (/dev/uhid)
uhid_dev_input2
__hid_input_report
wacom_raw_event (drivers/hid/wacom_sys.c:182)
wacom_wac_irq (drivers/hid/wacom_wac.c:3560)
wacom_bpt_irq (drivers/hid/wacom_wac.c:3290)
wacom_intuos_irq (drivers/hid/wacom_wac.c:1036)
```
In `wacom_wac.c`:
```c
static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
{
struct wacom_features *features = &wacom->features;
if ((features->type == INTUOSHT2) &&
(features->device_type & WACOM_DEVICETYPE_PEN))
return wacom_intuos_irq(wacom);
...
```
#### 3. How `wacom->pen_input` can be NULL
In `wacom_setup_inputs()` (`drivers/hid/wacom_sys.c`):
```c
static int wacom_setup_inputs(struct wacom *wacom)
{
...
error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
if (error) {
/* no pen in use on this interface */
input_free_device(pen_input_dev);
wacom_wac->pen_input = NULL;
pen_input_dev = NULL;
}
```
And in `wacom_setup_pen_input_capabilities`:
```c
int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac)
{
struct wacom_features *features = &wacom_wac->features;
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
return -ENODEV;
...
```
Still needed to inspect: How does `pen_input` become NULL when `features->type == INTUOSHT2` and `features->device_type & WACOM_DEVICETYPE_PEN`?
Possibilities:
- `wacom_parse_and_register()` or a quirk function resets or modifies `pen_input` or `device_type`.
- An interface or report descriptor quirk or failure during registration.
- A device with multiple interfaces where `pen_input` failed to register or was freed.
- Or simply `features->device_type` is modified after `wacom_setup_inputs()`.
---
### Approaches and Findings
1. **Static code inspection of `wacom_intuos_irq`**:
- Identified that `input` is loaded directly from `wacom->pen_input`.
- Line 1036 dereferences `input->dev.parent`.
- If `input` is NULL, offset 0x328 is read.
2. **KASAN vs Production Behavior Investigation**:
- Analyzed `dev_dbg` implementation in `include/linux/dev_printk.h` and `include/linux/dynamic_debug.h`:
- Under `CONFIG_DYNAMIC_DEBUG`, `dev_dbg` calls `dynamic_dev_dbg`, which evaluates `dev` conditionally inside `if (DYNAMIC_DEBUG_BRANCH(id))`.
- In production builds without dynamic debug (or when `DEBUG` is not set), `dev_dbg` expands to `dev_no_printk()`, which evaluates expressions inside `if (0)`.
- However, under production builds WITH `CONFIG_DYNAMIC_DEBUG=y` (standard on Debian/Ubuntu/Fedora/RHEL/etc.), if dynamic debug is enabled for that statement, or under configurations where `DEBUG` or dynamic debug is active, dereferencing `input->dev.parent` occurs.
- Even further: what happens if dynamic debug is NOT enabled or after the `if` check? Look at lines 1042-1054:
```c
result = wacom_intuos_pad(wacom);
...
result = wacom_intuos_inout(wacom);
...
result = wacom_intuos_general(wacom);
```
If an incoming report matches one of the expected reports (e.g. `WACOM_REPORT_PENABLED`, `WACOM_REPORT_INTUOS_PEN`, etc.), `wacom_intuos_general(wacom)` is called. In `wacom_intuos_general()`:
Line 853 reads `wacom->pen_input`. If `wacom->pen_input` is NULL, does it also dereference it unconditionally?
3. **Repetitive Tool Calls Noted**:
- Multiple greps were performed on `include/linux/dev_printk.h` searching for variations of `dev_dbg` / `dev_no_printk`. Avoid re-grepping `dev_printk.h`.
---
### Active Lines of Investigation / Next Steps
1. Check `wacom_parse_and_register()` and where `features->device_type` is set/modified in `drivers/hid/wacom_sys.c`.
2. Check how `wacom->pen_input` ends up NULL when `wacom_intuos_irq()` is called:
- Examine `drivers/hid/wacom_sys.c:2885` (`wacom_parse_and_register`).
- Check what `INTUOSHT2` device ID triggers this and how `/dev/uhid` creates it.
3. Check subsequent code in `wacom_intuos_general()` / `wacom_intuos_inout()` / `wacom_intuos_pad()`:
- Does normal event handling also dereference `pen_input`?
4. Determine Reachability / Accessibility:
- Triggered via `uhid_char_write` -> `/dev/uhid`.
- Permissions of `/dev/uhid`: typically root only (crw------- root:root or system group on Android). Not accessible to unprivileged users unless specifically configured.
- Peripheral trigger: Can a malicious USB device (or Bluetooth HID) presenting a Wacom VID/PID and matching descriptors trigger this? Yes, HID drivers are directly triggered when external USB peripherals are plugged in.
5. Determine Impact:
- Read of `input->dev.parent` at offset `0x328` from NULL.
- Causes page fault / kernel oops (DoS). Not arbitrary memory write or controlled execution hijack. Exploitable for DoS (system crash/reboot).
---
### Critical File Paths and References
- `drivers/hid/wacom_wac.c`: `wacom_intuos_irq` (line 1022), `wacom_bpt_irq` (line 3284), `wacom_wac_irq` (line 3560).
- `drivers/hid/wacom_sys.c`: `wacom_allocate_inputs` (line 2108), `wacom_setup_inputs` (line 2127), `wacom_setup_pen_input_capabilities` (line 3801 in `wacom_wac.c`), `wacom_probe` (line 2822).
- `include/linux/dev_printk.h`: `dev_dbg` macros.
- `include/linux/dynamic_debug.h`: `dynamic_dev_dbg` definitions.
Tokens:
input: 44314
output: 2486
thoughts: 0
|
| 79/2 |
2026/09/21 01:03 |
llm |
expert |
0m
Model:
Tokens:
input: 28579
output: 39
thoughts: 0
|
| 80/2 |
2026/09/21 01:03 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2120 LineCount:50]
Results: map[Contents:2120: wacom_wac->pen_input->name = wacom_wac->pen_name;
2121: wacom_wac->touch_input->name = wacom_wac->touch_name;
2122: wacom_wac->pad_input->name = wacom_wac->pad_name;
2123:
2124: return 0;
2125: }
2126:
2127: static int wacom_setup_inputs(struct wacom *wacom)
2128: {
2129: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
2130: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2131: int error = 0;
2132:
2133: pen_input_dev = wacom_wac->pen_input;
2134: touch_input_dev = wacom_wac->touch_input;
2135: pad_input_dev = wacom_wac->pad_input;
2136:
2137: if (!pen_input_dev || !touch_input_dev || !pad_input_dev)
2138: return -EINVAL;
2139:
2140: error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
2141: if (error) {
2142: /* no pen in use on this interface */
2143: input_free_device(pen_input_dev);
2144: wacom_wac->pen_input = NULL;
2145: pen_input_dev = NULL;
2146: }
2147:
2148: error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac);
2149: if (error) {
2150: /* no touch in use on this interface */
2151: input_free_device(touch_input_dev);
2152: wacom_wac->touch_input = NULL;
2153: touch_input_dev = NULL;
2154: }
2155:
2156: error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
2157: if (error) {
2158: /* no pad events using this interface */
2159: input_free_device(pad_input_dev);
2160: wacom_wac->pad_input = NULL;
2161: pad_input_dev = NULL;
2162: }
2163:
2164: return 0;
2165: }
2166:
2167: static int wacom_register_inputs(struct wacom *wacom)
2168: {
2169: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
]
|
| 81/2 |
2026/09/21 01:03 |
llm |
expert |
0m
Model:
Tokens:
input: 29460
output: 40
thoughts: 0
|
| 82/2 |
2026/09/21 01:04 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3800 LineCount:50]
Results: map[Contents:3800:
3801: int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3802: struct wacom_wac *wacom_wac)
3803: {
3804: struct wacom_features *features = &wacom_wac->features;
3805:
3806: if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3807: return -ENODEV;
3808:
3809: if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3810: __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3811: else
3812: __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3813:
3814: if (features->type == HID_GENERIC)
3815: /* setup has already been done */
3816: return 0;
3817:
3818: input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3819: __set_bit(BTN_TOUCH, input_dev->keybit);
3820: __set_bit(ABS_MISC, input_dev->absbit);
3821:
3822: input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3823: features->x_max - features->offset_right,
3824: features->x_fuzz, 0);
3825: input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3826: features->y_max - features->offset_bottom,
3827: features->y_fuzz, 0);
3828: input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3829: features->pressure_max, features->pressure_fuzz, 0);
3830:
3831: /* penabled devices have fixed resolution for each model */
3832: input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3833: input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3834:
3835: switch (features->type) {
3836: case GRAPHIRE_BT:
3837: __clear_bit(ABS_MISC, input_dev->absbit);
3838: fallthrough;
3839:
3840: case WACOM_MO:
3841: case WACOM_G4:
3842: input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3843: features->distance_max,
3844: features->distance_fuzz, 0);
3845: fallthrough;
3846:
3847: case GRAPHIRE:
3848: input_set_capability(input_dev, EV_REL, REL_WHEEL);
3849:
]
|
| 83/2 |
2026/09/21 01:04 |
llm |
expert |
0m
Model:
Tokens:
input: 30380
output: 40
thoughts: 0
|
| 84/2 |
2026/09/21 01:04 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:1020 LineCount:50]
Results: map[Contents:1020: }
1021:
1022: static int wacom_intuos_irq(struct wacom_wac *wacom)
1023: {
1024: unsigned char *data = wacom->data;
1025: struct input_dev *input = wacom->pen_input;
1026: int result;
1027:
1028: if (data[0] != WACOM_REPORT_PENABLED &&
1029: data[0] != WACOM_REPORT_INTUOS_ID1 &&
1030: data[0] != WACOM_REPORT_INTUOS_ID2 &&
1031: data[0] != WACOM_REPORT_INTUOSPAD &&
1032: data[0] != WACOM_REPORT_INTUOS_PEN &&
1033: data[0] != WACOM_REPORT_CINTIQ &&
1034: data[0] != WACOM_REPORT_CINTIQPAD &&
1035: data[0] != WACOM_REPORT_INTUOS5PAD) {
1036: dev_dbg(input->dev.parent,
1037: "%s: received unknown report #%d\n", __func__, data[0]);
1038: return 0;
1039: }
1040:
1041: /* process pad events */
1042: result = wacom_intuos_pad(wacom);
1043: if (result)
1044: return result;
1045:
1046: /* process in/out prox events */
1047: result = wacom_intuos_inout(wacom);
1048: if (result)
1049: return result - 1;
1050:
1051: /* process general packets */
1052: result = wacom_intuos_general(wacom);
1053: if (result)
1054: return result - 1;
1055:
1056: return 0;
1057: }
1058:
1059: static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
1060: {
1061: unsigned char *data = wacom_wac->data;
1062: struct input_dev *input;
1063: struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1064: struct wacom_remote *remote = wacom->remote;
1065: int bat_charging, bat_percent, touch_ring_mode;
1066: __u32 serial;
1067: int i, index = -1;
1068: unsigned long flags;
1069:
]
|
| 85/2 |
2026/09/21 01:04 |
llm |
expert |
0m
Model:
Tokens:
input: 31214
output: 39
thoughts: 0
|
| 86/2 |
2026/09/21 01:04 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:840 LineCount:50]
Results: map[Contents: 840: {
841: return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1);
842: }
843:
844: static inline bool delay_pen_events(struct wacom_wac *wacom)
845: {
846: return (wacom->shared->touch_down && touch_arbitration);
847: }
848:
849: static int wacom_intuos_general(struct wacom_wac *wacom)
850: {
851: struct wacom_features *features = &wacom->features;
852: unsigned char *data = wacom->data;
853: struct input_dev *input = wacom->pen_input;
854: int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
855: unsigned char type = (data[1] >> 1) & 0x0F;
856: unsigned int x, y, distance, t;
857:
858: if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
859: data[0] != WACOM_REPORT_INTUOS_PEN)
860: return 0;
861:
862: if (delay_pen_events(wacom))
863: return 1;
864:
865: /* don't report events if we don't know the tool ID */
866: if (!wacom->id[idx]) {
867: /* but reschedule a read of the current tool */
868: wacom_intuos_schedule_prox_event(wacom);
869: return 1;
870: }
871:
872: /*
873: * don't report events for invalid data
874: */
875: /* older I4 styli don't work with new Cintiqs */
876: if ((!((wacom->id[idx] >> 16) & 0x01) &&
877: (features->type == WACOM_21UX2)) ||
878: /* Only large Intuos support Lense Cursor */
879: (wacom->tool[idx] == BTN_TOOL_LENS &&
880: (features->type == INTUOS3 ||
881: features->type == INTUOS3S ||
882: features->type == INTUOS4 ||
883: features->type == INTUOS4S ||
884: features->type == INTUOS5 ||
885: features->type == INTUOS5S ||
886: features->type == INTUOSPM ||
887: features->type == INTUOSPS)) ||
888: /* Cintiq doesn't send data when RDY bit isn't set */
889: (features->type == CINTIQ && !(data[1] & 0x40)))
]
|
| 87/2 |
2026/09/21 01:04 |
llm |
expert |
0m
Model:
Tokens:
input: 32127
output: 39
thoughts: 0
|
| 88/2 |
2026/09/21 01:04 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:890 LineCount:50]
Results: map[Contents: 890: return 1;
891:
892: x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
893: y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
894: distance = data[9] >> 2;
895: if (features->type < INTUOS3S) {
896: x >>= 1;
897: y >>= 1;
898: distance >>= 1;
899: }
900: if (features->type == INTUOSHT2)
901: distance = features->distance_max - distance;
902: input_report_abs(input, ABS_X, x);
903: input_report_abs(input, ABS_Y, y);
904: input_report_abs(input, ABS_DISTANCE, distance);
905:
906: switch (type) {
907: case 0x00:
908: case 0x01:
909: case 0x02:
910: case 0x03:
911: /* general pen packet */
912: t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1);
913: if (features->pressure_max < 2047)
914: t >>= 1;
915: input_report_abs(input, ABS_PRESSURE, t);
916: if (features->type != INTUOSHT2) {
917: input_report_abs(input, ABS_TILT_X,
918: (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
919: input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
920: }
921: input_report_key(input, BTN_STYLUS, data[1] & 2);
922: input_report_key(input, BTN_STYLUS2, data[1] & 4);
923: input_report_key(input, BTN_TOUCH, t > 10);
924: break;
925:
926: case 0x0a:
927: /* airbrush second packet */
928: input_report_abs(input, ABS_WHEEL,
929: (data[6] << 2) | ((data[7] >> 6) & 3));
930: input_report_abs(input, ABS_TILT_X,
931: (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
932: input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
933: break;
934:
935: case 0x05:
936: /* Rotation packet */
937: if (features->type >= INTUOS3S) {
938: /* I3 marker pen rotation */
939: t = (data[6] << 3) | ((data[7] >> 5) & 7);
]
|
| 89/2 |
2026/09/21 01:04 |
llm |
expert |
0m
Model:
Tokens:
input: 33166
output: 39
thoughts: 0
|
| 90/2 |
2026/09/21 01:04 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:770 LineCount:50]
Results: map[Contents: 770: wacom->id[idx] = 0;
771: }
772:
773: static int wacom_intuos_inout(struct wacom_wac *wacom)
774: {
775: struct wacom_features *features = &wacom->features;
776: unsigned char *data = wacom->data;
777: struct input_dev *input = wacom->pen_input;
778: int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
779:
780: if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
781: ((data[1] & 0xfe) == 0x20) || /* in range */
782: ((data[1] & 0xfe) == 0x80))) /* out prox */
783: return 0;
784:
785: /* Enter report */
786: if ((data[1] & 0xfc) == 0xc0) {
787: /* serial number of the tool */
788: wacom->serial[idx] = ((__u64)(data[3] & 0x0f) << 28) +
789: (data[4] << 20) + (data[5] << 12) +
790: (data[6] << 4) + (data[7] >> 4);
791:
792: wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
793: ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8);
794:
795: wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]);
796:
797: wacom->shared->stylus_in_proximity = true;
798: return 1;
799: }
800:
801: /* in Range */
802: if ((data[1] & 0xfe) == 0x20) {
803: if (features->type != INTUOSHT2)
804: wacom->shared->stylus_in_proximity = true;
805:
806: /* in Range while exiting */
807: if (wacom->reporting_data) {
808: input_report_key(input, BTN_TOUCH, 0);
809: input_report_abs(input, ABS_PRESSURE, 0);
810: input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
811: return 2;
812: }
813: return 1;
814: }
815:
816: /* Exit report */
817: if ((data[1] & 0xfe) == 0x80) {
818: wacom->shared->stylus_in_proximity = false;
819: wacom->reporting_data = false;
]
|
| 91/2 |
2026/09/21 01:04 |
llm |
expert |
0m
Model:
Tokens:
input: 34132
output: 40
thoughts: 0
|
| 92/2 |
2026/09/21 01:04 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3280 LineCount:50]
Results: map[Contents:3280:
3281: return 1;
3282: }
3283:
3284: static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
3285: {
3286: struct wacom_features *features = &wacom->features;
3287:
3288: if ((features->type == INTUOSHT2) &&
3289: (features->device_type & WACOM_DEVICETYPE_PEN))
3290: return wacom_intuos_irq(wacom);
3291: else if (len == WACOM_PKGLEN_BBTOUCH)
3292: return wacom_bpt_touch(wacom);
3293: else if (len == WACOM_PKGLEN_BBTOUCH3)
3294: return wacom_bpt3_touch(wacom);
3295: else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
3296: return wacom_bpt_pen(wacom);
3297:
3298: return 0;
3299: }
3300:
3301: static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
3302: unsigned char *data)
3303: {
3304: unsigned char prefix;
3305:
3306: /*
3307: * We need to reroute the event from the debug interface to the
3308: * pen interface.
3309: * We need to add the report ID to the actual pen report, so we
3310: * temporary overwrite the first byte to prevent having to kzalloc/kfree
3311: * and memcpy the report.
3312: */
3313: prefix = data[0];
3314: data[0] = WACOM_REPORT_BPAD_PEN;
3315:
3316: /*
3317: * actually reroute the event.
3318: * No need to check if wacom->shared->pen is valid, hid_input_report()
3319: * will check for us.
3320: */
3321: hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
3322: WACOM_PKGLEN_PENABLED, 1);
3323:
3324: data[0] = prefix;
3325: }
3326:
3327: static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
3328: unsigned char *data)
3329: {
]
|
| 93/2 |
2026/09/21 01:04 |
llm |
expert |
0m
Model:
Tokens:
input: 34946
output: 39
thoughts: 0
|
| 94/2 |
2026/09/21 01:04 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2370 LineCount:50]
Results: map[Contents:2370: static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
2371: {
2372: struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2373: struct wacom_features *features = &wacom_wac->features;
2374: struct hid_device *hdev = wacom->hdev;
2375: int error;
2376: unsigned int connect_mask = HID_CONNECT_HIDRAW;
2377:
2378: features->pktlen = wacom_compute_pktlen(hdev);
2379: if (!features->pktlen)
2380: return -ENODEV;
2381:
2382: if (!devres_open_group(&hdev->dev, wacom, GFP_KERNEL))
2383: return -ENOMEM;
2384:
2385: error = wacom_devm_kfifo_alloc(wacom);
2386: if (error)
2387: goto fail;
2388:
2389: wacom->resources = true;
2390:
2391: error = wacom_allocate_inputs(wacom);
2392: if (error)
2393: goto fail;
2394:
2395: /*
2396: * Bamboo Pad has a generic hid handling for the Pen, and we switch it
2397: * into debug mode for the touch part.
2398: * We ignore the other interfaces.
2399: */
2400: if (features->type == BAMBOO_PAD) {
2401: if (features->pktlen == WACOM_PKGLEN_PENABLED) {
2402: features->type = HID_GENERIC;
2403: } else if ((features->pktlen != WACOM_PKGLEN_BPAD_TOUCH) &&
2404: (features->pktlen != WACOM_PKGLEN_BPAD_TOUCH_USB)) {
2405: error = -ENODEV;
2406: goto fail;
2407: }
2408: }
2409:
2410: /* set the default size in case we do not get them from hid */
2411: wacom_set_default_phy(features);
2412:
2413: /* Retrieve the physical and logical size for touch devices */
2414: wacom_retrieve_hid_descriptor(hdev, features);
2415: wacom_setup_device_quirks(wacom);
2416:
2417: if (features->device_type == WACOM_DEVICETYPE_NONE &&
2418: features->type != WIRELESS) {
2419: error = features->type == HID_GENERIC ? -ENODEV : 0;
]
|
| 95/2 |
2026/09/21 01:04 |
llm |
expert |
0m
Model:
Tokens:
input: 35785
output: 39
thoughts: 0
|
| 96/2 |
2026/09/21 01:05 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2420 LineCount:50]
Results: map[Contents:2420:
2421: dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.",
2422: hdev->name,
2423: error ? "Ignoring" : "Assuming pen");
2424:
2425: if (error)
2426: goto fail;
2427:
2428: features->device_type |= WACOM_DEVICETYPE_PEN;
2429: }
2430:
2431: wacom_calculate_res(features);
2432:
2433: wacom_update_name(wacom, wireless ? " (WL)" : "");
2434:
2435: /* pen only Bamboo neither support touch nor pad */
2436: if ((features->type == BAMBOO_PEN) &&
2437: ((features->device_type & WACOM_DEVICETYPE_TOUCH) ||
2438: (features->device_type & WACOM_DEVICETYPE_PAD))) {
2439: error = -ENODEV;
2440: goto fail;
2441: }
2442:
2443: error = wacom_add_shared_data(hdev);
2444: if (error)
2445: goto fail;
2446:
2447: error = wacom_setup_inputs(wacom);
2448: if (error)
2449: goto fail;
2450:
2451: if (features->type == HID_GENERIC)
2452: connect_mask |= HID_CONNECT_DRIVER;
2453:
2454: /* Regular HID work starts now */
2455: error = hid_hw_start(hdev, connect_mask);
2456: if (error) {
2457: hid_err(hdev, "hw start failed\n");
2458: goto fail;
2459: }
2460:
2461: error = wacom_register_inputs(wacom);
2462: if (error)
2463: goto fail_hw_stop;
2464:
2465: if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) {
2466: error = wacom_initialize_leds(wacom);
2467: if (error)
2468: goto fail_hw_stop;
2469:
]
|
| 97/2 |
2026/09/21 01:05 |
llm |
expert |
0m
Model:
Tokens:
input: 36527
output: 40
thoughts: 0
|
| 98/2 |
2026/09/21 01:05 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_sys.c Name:wacom_allocate_inputs]
Results: map[SourceCode:2108: static int wacom_allocate_inputs(struct wacom *wacom)
2109: {
2110: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2111:
2112: wacom_wac->pen_input = wacom_allocate_input(wacom);
2113: wacom_wac->touch_input = wacom_allocate_input(wacom);
2114: wacom_wac->pad_input = wacom_allocate_input(wacom);
2115: if (!wacom_wac->pen_input ||
2116: !wacom_wac->touch_input ||
2117: !wacom_wac->pad_input)
2118: return -ENOMEM;
2119:
2120: wacom_wac->pen_input->name = wacom_wac->pen_name;
2121: wacom_wac->touch_input->name = wacom_wac->touch_name;
2122: wacom_wac->pad_input->name = wacom_wac->pad_name;
2123:
2124: return 0;
2125: }
SourceFile:drivers/hid/wacom_sys.c]
|
| 99/2 |
2026/09/21 01:05 |
llm |
expert |
0m
Model:
Tokens:
input: 36939
output: 40
thoughts: 0
|
| 100/2 |
2026/09/21 01:05 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_sys.c Name:wacom_allocate_input]
Results: map[SourceCode:2083: static struct input_dev *wacom_allocate_input(struct wacom *wacom)
2084: {
2085: struct input_dev *input_dev;
2086: struct hid_device *hdev = wacom->hdev;
2087: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2088:
2089: input_dev = devm_input_allocate_device(&hdev->dev);
2090: if (!input_dev)
2091: return NULL;
2092:
2093: input_dev->name = wacom_wac->features.name;
2094: input_dev->phys = hdev->phys;
2095: input_dev->dev.parent = &hdev->dev;
2096: input_dev->open = wacom_open;
2097: input_dev->close = wacom_close;
2098: input_dev->uniq = hdev->uniq;
2099: input_dev->id.bustype = hdev->bus;
2100: input_dev->id.vendor = hdev->vendor;
2101: input_dev->id.product = wacom_wac->pid ? wacom_wac->pid : hdev->product;
2102: input_dev->id.version = hdev->version;
2103: input_set_drvdata(input_dev, wacom);
2104:
2105: return input_dev;
2106: }
SourceFile:drivers/hid/wacom_sys.c]
|
| 101/2 |
2026/09/21 01:05 |
llm |
expert |
0m
Model:
Tokens:
input: 37438
output: 369
thoughts: 0
|
| 102/2 |
2026/09/21 01:05 |
tool |
codeexpert |
5m
Args: map[Question:In `drivers/hid/wacom_wac.c`, `wacom_intuos_irq()` is called from `wacom_bpt_irq()` when `features->type == INTUOSHT2` and `features->device_type & WACOM_DEVICETYPE_PEN`.
In `wacom_intuos_irq()`, `wacom->pen_input` is dereferenced.
However, in `wacom_setup_inputs()`, `wacom->pen_input` can be set to NULL if `wacom_setup_pen_input_capabilities()` returns an error.
`wacom_setup_pen_input_capabilities()` returns `-ENODEV` if `!(features->device_type & WACOM_DEVICETYPE_PEN)`.
But since `wacom_bpt_irq()` checks for `features->device_type & WACOM_DEVICETYPE_PEN`, it seems `pen_input` shouldn't be NULL for this reason.
Are there any other ways `wacom->pen_input` can be NULL when `wacom_intuos_irq()` is called?
For example, could `wacom_setup_pen_input_capabilities()` return an error for another reason?
Or could `wacom->pen_input` be freed/set to NULL somewhere else after `wacom_setup_inputs()`?
Or could `features->device_type` be modified after `wacom_setup_inputs()`?
Or could `wacom_bpt_irq()` be called before `wacom_setup_inputs()` completes?]
Results: map[Answer:Based on kernel source code analysis of `drivers/hid/wacom_sys.c` and `drivers/hid/wacom_wac.c`, here are the findings regarding the questions:
1. **Could `wacom_setup_pen_input_capabilities()` return an error for another reason?**
- **No.** An inspection of `wacom_setup_pen_input_capabilities()` (lines 3801β3964) shows that it has only a single error exit point at line 3806:
```c
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
return -ENODEV;
```
All subsequent paths (including the `INTUOSHT2` case, which calls `wacom_setup_basic_pro_pen()` returning `void`) only set capability bits on the input device and conclude with `return 0;`. There are no memory allocations or other fallible operations.
2. **Where else can `wacom->pen_input` be freed or set to NULL?**
Every write to `pen_input` across `drivers/hid/` was examined:
- **Input registration failure (`wacom_register_inputs()` in `wacom_sys.c:2200`):**
`wacom_register_inputs()` registers `pen_input`, `touch_input`, and `pad_input` sequentially. If `pen_input` is registered successfully but registering `touch_input` or `pad_input` fails with an error, the code jumps to `fail:`, setting:
```c
wacom_wac->pad_input = NULL;
wacom_wac->touch_input = NULL;
wacom_wac->pen_input = NULL;
```
Because `hid_hw_start()` was already called earlier in `wacom_parse_and_register()`, this occurs while the hardware interface is started, before `hid_hw_stop()` is called in the unwind path.
- **Resource release / Wireless disconnect (`wacom_release_resources()` in `wacom_sys.c:2339`):**
`wacom_release_resources()` sets `pen_input = NULL` (and releases the devres group). This function is called:
- On failure cleanup paths in `wacom_parse_and_register()`.
- In `wacom_wireless_work()` (`wacom_sys.c:2533`): when a wireless receiver reports that a tablet disconnected (`wacom_wac->pid == 0`), `wacom_release_resources(wacom1)` is called for the stylus interface, setting `wacom1->wacom_wac.pen_input = NULL;`.
3. **Could `features->device_type` be modified after `wacom_setup_inputs()`?**
- In regular probe operation, `device_type` is determined prior to `wacom_setup_inputs()` and is not modified afterwards.
- The only dynamic modifications to `features` occur during mode switching (`wacom_mode_change_work()`) and wireless tablet connect/disconnect (`wacom_wireless_work()`), both of which re-parse and re-register interfaces rather than mutating `device_type` in-place on an active interface.
4. **Could `wacom_bpt_irq()` be called before `wacom_setup_inputs()` completes?**
- For a single interface during probe, `wacom_setup_inputs()` runs before `hid_hw_start()`. Raw input reports are only dispatched after hardware start and open, so `wacom_bpt_irq()` will not be called before `wacom_setup_inputs()` completes on that interface.
- However, after `hid_hw_start()` is called, if `wacom_register_inputs()` fails or during wireless disconnect cleanup in `wacom_wireless_work()`, `pen_input` can be NULL while reports might still arrive.
- Additionally, in other call paths leading to `wacom_intuos_irq()` (such as `wacom_wac_irq()` directly for `CINTIQ_COMPANION_2` and `INTUOS` models), there is no check for `WACOM_DEVICETYPE_PEN` prior to calling `wacom_intuos_irq()`, which can lead to dereferencing `pen_input == NULL` if an unexpected report is delivered to a touch- or pad-only interface.
(Caveat / unverified: The exact concurrency and locking behavior between USB URB completion in `wacom_raw_event()` and asynchronous work in `wacom_wireless_work()` was not fully traced due to tool limits.)]
|
| 103/3 |
2026/09/21 01:05 |
agent |
codeexpert |
5m
Model:
Results: map[Answer:Based on kernel source code analysis of `drivers/hid/wacom_sys.c` and `drivers/hid/wacom_wac.c`, here are the findings regarding the questions:
1. **Could `wacom_setup_pen_input_capabilities()` return an error for another reason?**
- **No.** An inspection of `wacom_setup_pen_input_capabilities()` (lines 3801β3964) shows that it has only a single error exit point at line 3806:
```c
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
return -ENODEV;
```
All subsequent paths (including the `INTUOSHT2` case, which calls `wacom_setup_basic_pro_pen()` returning `void`) only set capability bits on the input device and conclude with `return 0;`. There are no memory allocations or other fallible operations.
2. **Where else can `wacom->pen_input` be freed or set to NULL?**
Every write to `pen_input` across `drivers/hid/` was examined:
- **Input registration failure (`wacom_register_inputs()` in `wacom_sys.c:2200`):**
`wacom_register_inputs()` registers `pen_input`, `touch_input`, and `pad_input` sequentially. If `pen_input` is registered successfully but registering `touch_input` or `pad_input` fails with an error, the code jumps to `fail:`, setting:
```c
wacom_wac->pad_input = NULL;
wacom_wac->touch_input = NULL;
wacom_wac->pen_input = NULL;
```
Because `hid_hw_start()` was already called earlier in `wacom_parse_and_register()`, this occurs while the hardware interface is started, before `hid_hw_stop()` is called in the unwind path.
- **Resource release / Wireless disconnect (`wacom_release_resources()` in `wacom_sys.c:2339`):**
`wacom_release_resources()` sets `pen_input = NULL` (and releases the devres group). This function is called:
- On failure cleanup paths in `wacom_parse_and_register()`.
- In `wacom_wireless_work()` (`wacom_sys.c:2533`): when a wireless receiver reports that a tablet disconnected (`wacom_wac->pid == 0`), `wacom_release_resources(wacom1)` is called for the stylus interface, setting `wacom1->wacom_wac.pen_input = NULL;`.
3. **Could `features->device_type` be modified after `wacom_setup_inputs()`?**
- In regular probe operation, `device_type` is determined prior to `wacom_setup_inputs()` and is not modified afterwards.
- The only dynamic modifications to `features` occur during mode switching (`wacom_mode_change_work()`) and wireless tablet connect/disconnect (`wacom_wireless_work()`), both of which re-parse and re-register interfaces rather than mutating `device_type` in-place on an active interface.
4. **Could `wacom_bpt_irq()` be called before `wacom_setup_inputs()` completes?**
- For a single interface during probe, `wacom_setup_inputs()` runs before `hid_hw_start()`. Raw input reports are only dispatched after hardware start and open, so `wacom_bpt_irq()` will not be called before `wacom_setup_inputs()` completes on that interface.
- However, after `hid_hw_start()` is called, if `wacom_register_inputs()` fails or during wireless disconnect cleanup in `wacom_wireless_work()`, `pen_input` can be NULL while reports might still arrive.
- Additionally, in other call paths leading to `wacom_intuos_irq()` (such as `wacom_wac_irq()` directly for `CINTIQ_COMPANION_2` and `INTUOS` models), there is no check for `WACOM_DEVICETYPE_PEN` prior to calling `wacom_intuos_irq()`, which can lead to dereferencing `pen_input == NULL` if an unexpected report is delivered to a touch- or pad-only interface.
(Caveat / unverified: The exact concurrency and locking behavior between USB URB completion in `wacom_raw_event()` and asynchronous work in `wacom_wireless_work()` was not fully traced due to tool limits.)]
Instruction:
You are a capable Linux kernel developer tasked with researching complex questions
about kernel source code. You will be given a concrete question, and need to provide
a concrete answer.
Research the question using targeted, efficient tool calls. Don't make assumptions,
or rely on your previous knowledge about the kernel source code, use available tools
to access the actual source code. Keep your tool calls focused and limited to the
scope of the question. Do not explore tangential code paths or perform unbounded searches.
Use all available sources of information:
- kernel source code
- documentation in the Documentation dir in the source tree
- git commits descriptions, git blame
Do not guess file names or file paths and attempt to read them without
verifying their existence first using content search or directory listing tools.
If a file, symbol, or directory is not found via content search (grepper) or
directory listing (codesearch-dir-index), treat it as completely absent.
Do not attempt to guess alternative names, extensions, or directories.
Tool Selection Guidelines:
1. For C functions, structs, and variables: Prefer codesearch-definition-source
or codesearch-struct-layout FIRST to retrieve clean, exact definitions
without line-number guessing.
2. If symbol lookup fails (e.g., preprocessor macros, macro-generated code, or
disabled #ifdef branches), fall back to read-file or grepper.
3. For file headers, #include directives, preprocessor macro definitions, and
non-C files (Kconfig, Makefiles, docs): Use read-file or grepper directly.
4. Be concise and targeted. Answer the question as directly and concisely as possible
once you have located the relevant code or definitions. If a symbol or function cannot
be found after targeted searches, conclude with the best available information rather
than continuing repetitive searches.
Do NOT use git-log to search for the presence or existence of files in the
repository. git-log is only for tracing commit history of files that are
already present in the current checkout. If a file does not exist in the
current checkout, it cannot be used for reproduction.
Avoid running broad git-log queries (such as searches on the entire repo)
without a specific 'PathPrefix' to restrict the scope, as these are very
expensive and will time out.
If a git-log tool call times out, do not retry the query with the same broad
scope. You must specify a tighter, narrower 'PathPrefix' for subsequent queries.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: In `drivers/hid/wacom_wac.c`, `wacom_intuos_irq()` is called from `wacom_bpt_irq()` when `features->type == INTUOSHT2` and `features->device_type & WACOM_DEVICETYPE_PEN`.
In `wacom_intuos_irq()`, `wacom->pen_input` is dereferenced.
However, in `wacom_setup_inputs()`, `wacom->pen_input` can be set to NULL if `wacom_setup_pen_input_capabilities()` returns an error.
`wacom_setup_pen_input_capabilities()` returns `-ENODEV` if `!(features->device_type & WACOM_DEVICETYPE_PEN)`.
But since `wacom_bpt_irq()` checks for `features->device_type & WACOM_DEVICETYPE_PEN`, it seems `pen_input` shouldn't be NULL for this reason.
Are there any other ways `wacom->pen_input` can be NULL when `wacom_intuos_irq()` is called?
For example, could `wacom_setup_pen_input_capabilities()` return an error for another reason?
Or could `wacom->pen_input` be freed/set to NULL somewhere else after `wacom_setup_inputs()`?
Or could `features->device_type` be modified after `wacom_setup_inputs()`?
Or could `wacom_bpt_irq()` be called before `wacom_setup_inputs()` completes?
|
| 104/4 |
2026/09/21 01:05 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 4501
output: 124
thoughts: 450
Thoughts: **Digging into a Wacom Driver Bug**
Okay, so I've got this very specific issue in `drivers/hid/wacom_wac.c` that's got me scratching my head. The user is on to something β there's a potential NULL pointer dereference in `wacom_intuos_irq()`. Specifically, the code dereferences `wacom->pen_input`, but it's possible that this pointer might be NULL under certain circumstances.
The user has laid out the core logic: `wacom_intuos_irq()` gets called from `wacom_bpt_irq()` when we're dealing with an INTUOSHT2 device and a pen. The issue is that `wacom->pen_input` *could* be NULL after `wacom_setup_inputs()` runs. The user points out a few potential paths to this:
* `wacom_setup_pen_input_capabilities()` returning an error. They also noted the obvious one: this function *shouldn't* error out due to the `WACOM_DEVICETYPE_PEN` check that's done by `wacom_bpt_irq()`. But they're right to ask, are there other ways this function could fail?
* `wacom->pen_input` getting freed or set to NULL somewhere *else* after `wacom_setup_inputs()` has completed. This is a crucial area to investigate.
* The `features->device_type` being modified *after* `wacom_setup_inputs()`. This seems less likely, but we need to rule it out.
* `wacom_bpt_irq()` being called *before* `wacom_setup_inputs()` is completely finished. This would be a classic initialization problem.
Now, it's time to dive into the code. I'm going to start searching for all these functions: `wacom_intuos_irq`, `wacom_bpt_irq`, `wacom_setup_inputs`, and `wacom_setup_pen_input_capabilities`, plus any uses of or assignments to `wacom->pen_input` to trace this through. We're getting to the bottom of this.
|
| 105/4 |
2026/09/21 01:06 |
tool |
grepper |
0m
Args: map[Expression:wacom_setup_pen_input_capabilities PathPrefix:drivers/hid]
Results: map[Output:drivers/hid/wacom.h=232=void wacom_setup_device_quirks(struct wacom *wacom);
drivers/hid/wacom.h:233:int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
drivers/hid/wacom.h-234- struct wacom_wac *wacom_wac);
--
drivers/hid/wacom_sys.c=2127=static int wacom_setup_inputs(struct wacom *wacom)
--
drivers/hid/wacom_sys.c-2139-
drivers/hid/wacom_sys.c:2140: error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
drivers/hid/wacom_sys.c-2141- if (error) {
--
drivers/hid/wacom_wac.c=3648=void wacom_setup_device_quirks(struct wacom *wacom)
--
drivers/hid/wacom_wac.c-3800-
drivers/hid/wacom_wac.c:3801:int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
drivers/hid/wacom_wac.c-3802- struct wacom_wac *wacom_wac)
]
|
| 106/4 |
2026/09/21 01:06 |
tool |
grepper |
0m
Args: map[Expression:wacom_bpt_irq PathPrefix:drivers/hid]
Results: map[Output:drivers/hid/wacom_wac.c=3209=static int wacom_bpt_pen(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-3283-
drivers/hid/wacom_wac.c:3284:static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
drivers/hid/wacom_wac.c-3285-{
--
drivers/hid/wacom_wac.c=3461=void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
--
drivers/hid/wacom_wac.c-3559- else
drivers/hid/wacom_wac.c:3560: sync = wacom_bpt_irq(wacom_wac, len);
drivers/hid/wacom_wac.c-3561- break;
]
|
| 107/4 |
2026/09/21 01:06 |
tool |
grepper |
0m
Args: map[Expression:wacom_setup_inputs PathPrefix:drivers/hid]
Results: map[Output:drivers/hid/wacom_sys.c=2108=static int wacom_allocate_inputs(struct wacom *wacom)
--
drivers/hid/wacom_sys.c-2126-
drivers/hid/wacom_sys.c:2127:static int wacom_setup_inputs(struct wacom *wacom)
drivers/hid/wacom_sys.c-2128-{
--
drivers/hid/wacom_sys.c=2370=static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
--
drivers/hid/wacom_sys.c-2446-
drivers/hid/wacom_sys.c:2447: error = wacom_setup_inputs(wacom);
drivers/hid/wacom_sys.c-2448- if (error)
]
|
| 108/4 |
2026/09/21 01:06 |
tool |
grepper |
0m
Args: map[Expression:wacom_intuos_irq PathPrefix:drivers/hid]
Results: map[Output:drivers/hid/wacom.h-57- * - Fixed a Graphire bug
drivers/hid/wacom.h:58: * - Merged wacom_intuos3_irq into wacom_intuos_irq
drivers/hid/wacom.h-59- * v1.44 (pc) - Added support for Graphire4, Cintiq 710, Intuos3 6x11, etc.
--
drivers/hid/wacom_wac.c=849=static int wacom_intuos_general(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-1021-
drivers/hid/wacom_wac.c:1022:static int wacom_intuos_irq(struct wacom_wac *wacom)
drivers/hid/wacom_wac.c-1023-{
--
drivers/hid/wacom_wac.c=1192=static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
--
drivers/hid/wacom_wac.c-1197- wacom->data = data;
drivers/hid/wacom_wac.c:1198: wacom_intuos_irq(wacom);
drivers/hid/wacom_wac.c-1199- wacom->data = saved_data;
--
drivers/hid/wacom_wac.c=3284=static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
--
drivers/hid/wacom_wac.c-3289- (features->device_type & WACOM_DEVICETYPE_PEN))
drivers/hid/wacom_wac.c:3290: return wacom_intuos_irq(wacom);
drivers/hid/wacom_wac.c-3291- else if (len == WACOM_PKGLEN_BBTOUCH)
--
drivers/hid/wacom_wac.c=3461=void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
--
drivers/hid/wacom_wac.c-3510- case CINTIQ_COMPANION_2:
drivers/hid/wacom_wac.c:3511: sync = wacom_intuos_irq(wacom_wac);
drivers/hid/wacom_wac.c-3512- break;
--
drivers/hid/wacom_wac.c-3533- else
drivers/hid/wacom_wac.c:3534: sync = wacom_intuos_irq(wacom_wac);
drivers/hid/wacom_wac.c-3535- break;
]
|
| 109/4 |
2026/09/21 01:06 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 7140
output: 39
thoughts: 83
Thoughts: Here's my thought process, as I analyze this code snippet:
**Diving Deep into the Wacom Driver**
Okay, so I need to get a handle on how this Wacom driver is setting up its input devices. My first instinct is to zero in on the core initialization functions. I'm thinking, let's start by digging into `wacom_setup_inputs` and `wacom_setup_pen_input_capabilities` β those sound like likely candidates for the initial device configuration. And since interrupts are fundamental to how these devices work, I'll also bring `wacom_bpt_irq` and `wacom_intuos_irq` into the picture. They're probably dealing with the hardware interrupts.
To efficiently examine these functions, I'll use a `read-file` command to load up the `wacom_sys.c` source file, probably found in `drivers/hid/`. That should give me the context I need to understand what's happening within `wacom_setup_inputs`. I need to understand how the devices are set up. From there, I can analyze the interrupt routines, and how they interact with the hardware.
|
| 110/4 |
2026/09/21 01:06 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2100 LineCount:80]
Results: map[Contents:2100: input_dev->id.vendor = hdev->vendor;
2101: input_dev->id.product = wacom_wac->pid ? wacom_wac->pid : hdev->product;
2102: input_dev->id.version = hdev->version;
2103: input_set_drvdata(input_dev, wacom);
2104:
2105: return input_dev;
2106: }
2107:
2108: static int wacom_allocate_inputs(struct wacom *wacom)
2109: {
2110: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2111:
2112: wacom_wac->pen_input = wacom_allocate_input(wacom);
2113: wacom_wac->touch_input = wacom_allocate_input(wacom);
2114: wacom_wac->pad_input = wacom_allocate_input(wacom);
2115: if (!wacom_wac->pen_input ||
2116: !wacom_wac->touch_input ||
2117: !wacom_wac->pad_input)
2118: return -ENOMEM;
2119:
2120: wacom_wac->pen_input->name = wacom_wac->pen_name;
2121: wacom_wac->touch_input->name = wacom_wac->touch_name;
2122: wacom_wac->pad_input->name = wacom_wac->pad_name;
2123:
2124: return 0;
2125: }
2126:
2127: static int wacom_setup_inputs(struct wacom *wacom)
2128: {
2129: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
2130: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2131: int error = 0;
2132:
2133: pen_input_dev = wacom_wac->pen_input;
2134: touch_input_dev = wacom_wac->touch_input;
2135: pad_input_dev = wacom_wac->pad_input;
2136:
2137: if (!pen_input_dev || !touch_input_dev || !pad_input_dev)
2138: return -EINVAL;
2139:
2140: error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
2141: if (error) {
2142: /* no pen in use on this interface */
2143: input_free_device(pen_input_dev);
2144: wacom_wac->pen_input = NULL;
2145: pen_input_dev = NULL;
2146: }
2147:
2148: error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac);
2149: if (error) {
2150: /* no touch in use on this interface */
2151: input_free_device(touch_input_dev);
2152: wacom_wac->touch_input = NULL;
2153: touch_input_dev = NULL;
2154: }
2155:
2156: error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
2157: if (error) {
2158: /* no pad events using this interface */
2159: input_free_device(pad_input_dev);
2160: wacom_wac->pad_input = NULL;
2161: pad_input_dev = NULL;
2162: }
2163:
2164: return 0;
2165: }
2166:
2167: static int wacom_register_inputs(struct wacom *wacom)
2168: {
2169: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
2170: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2171: int error = 0;
2172:
2173: pen_input_dev = wacom_wac->pen_input;
2174: touch_input_dev = wacom_wac->touch_input;
2175: pad_input_dev = wacom_wac->pad_input;
2176:
2177: if (pen_input_dev) {
2178: error = input_register_device(pen_input_dev);
2179: if (error)
]
|
| 111/4 |
2026/09/21 01:06 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 8888
output: 40
thoughts: 33
Thoughts: Okay, here's my interpretation of that thought process, as if it were my own:
**Diving into the Wacom Driver's Pen Input**
Right, let's drill down into this Wacom driver situation a bit further. I need to understand how this pen input is *really* handled, so, I should check out the `wacom_setup_pen_input_capabilities()` function. That looks like a good starting point to delve into the core of how the driver figures out what the pen is capable of in the first place. That function, within the `drivers/hid/wacom_wac.c` file, should hold some vital clues, allowing me to understand how these devices are initialized and the capabilities reported. I expect to find some interesting code in there.
|
| 112/4 |
2026/09/21 01:06 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3800 LineCount:80]
Results: map[Contents:3800:
3801: int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3802: struct wacom_wac *wacom_wac)
3803: {
3804: struct wacom_features *features = &wacom_wac->features;
3805:
3806: if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3807: return -ENODEV;
3808:
3809: if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3810: __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3811: else
3812: __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3813:
3814: if (features->type == HID_GENERIC)
3815: /* setup has already been done */
3816: return 0;
3817:
3818: input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3819: __set_bit(BTN_TOUCH, input_dev->keybit);
3820: __set_bit(ABS_MISC, input_dev->absbit);
3821:
3822: input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3823: features->x_max - features->offset_right,
3824: features->x_fuzz, 0);
3825: input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3826: features->y_max - features->offset_bottom,
3827: features->y_fuzz, 0);
3828: input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3829: features->pressure_max, features->pressure_fuzz, 0);
3830:
3831: /* penabled devices have fixed resolution for each model */
3832: input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3833: input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3834:
3835: switch (features->type) {
3836: case GRAPHIRE_BT:
3837: __clear_bit(ABS_MISC, input_dev->absbit);
3838: fallthrough;
3839:
3840: case WACOM_MO:
3841: case WACOM_G4:
3842: input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3843: features->distance_max,
3844: features->distance_fuzz, 0);
3845: fallthrough;
3846:
3847: case GRAPHIRE:
3848: input_set_capability(input_dev, EV_REL, REL_WHEEL);
3849:
3850: __set_bit(BTN_LEFT, input_dev->keybit);
3851: __set_bit(BTN_RIGHT, input_dev->keybit);
3852: __set_bit(BTN_MIDDLE, input_dev->keybit);
3853:
3854: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3855: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3856: __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3857: __set_bit(BTN_STYLUS, input_dev->keybit);
3858: __set_bit(BTN_STYLUS2, input_dev->keybit);
3859: break;
3860:
3861: case WACOM_27QHD:
3862: case WACOM_24HD:
3863: case DTK:
3864: case WACOM_22HD:
3865: case WACOM_21UX2:
3866: case WACOM_BEE:
3867: case CINTIQ:
3868: case WACOM_13HD:
3869: case CINTIQ_HYBRID:
3870: case CINTIQ_COMPANION_2:
3871: input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3872: input_abs_set_res(input_dev, ABS_Z, 287);
3873: wacom_setup_cintiq(wacom_wac);
3874: break;
3875:
3876: case INTUOS3:
3877: case INTUOS3L:
3878: case INTUOS3S:
3879: case INTUOS4:
]
|
| 113/4 |
2026/09/21 01:06 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 10532
output: 40
thoughts: 28
Thoughts: Here's your summary:
**Digging into `wacom_setup_pen_input_capabilities()`**
Alright, let's see what this `wacom_setup_pen_input_capabilities()` function is *really* doing. I want to understand its error handling and control flow. My immediate goal is to understand if there's any scenario where it might return an error that hasn't been properly dealt with upstream. Let's trace its execution and pay close attention to the return statements. I need to make sure this function behaves correctly in all expected scenarios. Time to dive in and get this nailed down.
|
| 114/4 |
2026/09/21 01:06 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3880 LineCount:70]
Results: map[Contents:3880: case INTUOS4WL:
3881: case INTUOS4L:
3882: case INTUOS4S:
3883: input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3884: input_abs_set_res(input_dev, ABS_Z, 287);
3885: fallthrough;
3886:
3887: case INTUOS:
3888: wacom_setup_intuos(wacom_wac);
3889: break;
3890:
3891: case INTUOS5:
3892: case INTUOS5L:
3893: case INTUOSPM:
3894: case INTUOSPL:
3895: case INTUOS5S:
3896: case INTUOSPS:
3897: case INTUOSP2_BT:
3898: case INTUOSP2S_BT:
3899: input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3900: features->distance_max,
3901: features->distance_fuzz, 0);
3902:
3903: input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3904: input_abs_set_res(input_dev, ABS_Z, 287);
3905:
3906: wacom_setup_intuos(wacom_wac);
3907: break;
3908:
3909: case WACOM_24HDT:
3910: case WACOM_27QHDT:
3911: case MTSCREEN:
3912: case MTTPC:
3913: case MTTPC_B:
3914: case TABLETPC2FG:
3915: case TABLETPC:
3916: case TABLETPCE:
3917: __clear_bit(ABS_MISC, input_dev->absbit);
3918: fallthrough;
3919:
3920: case DTUS:
3921: case DTUSX:
3922: case PL:
3923: case DTU:
3924: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3925: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3926: __set_bit(BTN_STYLUS, input_dev->keybit);
3927: __set_bit(BTN_STYLUS2, input_dev->keybit);
3928: break;
3929:
3930: case PTU:
3931: __set_bit(BTN_STYLUS2, input_dev->keybit);
3932: fallthrough;
3933:
3934: case PENPARTNER:
3935: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3936: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3937: __set_bit(BTN_STYLUS, input_dev->keybit);
3938: break;
3939:
3940: case INTUOSHT:
3941: case BAMBOO_PT:
3942: case BAMBOO_PEN:
3943: case INTUOSHT2:
3944: case INTUOSHT3_BT:
3945: if (features->type == INTUOSHT2 ||
3946: features->type == INTUOSHT3_BT) {
3947: wacom_setup_basic_pro_pen(wacom_wac);
3948: } else {
3949: __clear_bit(ABS_MISC, input_dev->absbit);
]
|
| 115/4 |
2026/09/21 01:06 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 11845
output: 40
thoughts: 18
Thoughts: Okay, here's the summary, rendered in the first person, assuming the user is an expert and incorporating a conversational tone:
**Onward to Line 3950!**
Alright, let's keep this ball rolling. I'm hitting the next chunk β lines 3950 through 4000. Considering my experience with this material, I'm expecting a continuation of [mention the relevant topic or sub-topic from the previous section, if any]. I'll be keeping an eye out for any subtle shifts in argumentation or any new perspectives that are being introduced. I'm particularly interested in seeing how the author handles [mention a specific aspect or potential challenge related to the text, if applicable]. I'm primed to identify anything groundbreaking, but also to scrutinize any potential weaknesses in the logic or evidence. Let's see what gems these lines hold!
|
| 116/4 |
2026/09/21 01:06 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3950 LineCount:50]
Results: map[Contents:3950: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3951: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3952: __set_bit(BTN_STYLUS, input_dev->keybit);
3953: __set_bit(BTN_STYLUS2, input_dev->keybit);
3954: input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3955: features->distance_max,
3956: features->distance_fuzz, 0);
3957: }
3958: break;
3959: case BAMBOO_PAD:
3960: __clear_bit(ABS_MISC, input_dev->absbit);
3961: break;
3962: }
3963: return 0;
3964: }
3965:
3966: int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
3967: struct wacom_wac *wacom_wac)
3968: {
3969: struct wacom_features *features = &wacom_wac->features;
3970:
3971: if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
3972: return -ENODEV;
3973:
3974: if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3975: __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3976: else
3977: __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3978:
3979: if (features->type == HID_GENERIC)
3980: /* setup has already been done */
3981: return 0;
3982:
3983: input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3984: __set_bit(BTN_TOUCH, input_dev->keybit);
3985:
3986: if (features->touch_max == 1) {
3987: input_set_abs_params(input_dev, ABS_X, 0,
3988: features->x_max, features->x_fuzz, 0);
3989: input_set_abs_params(input_dev, ABS_Y, 0,
3990: features->y_max, features->y_fuzz, 0);
3991: input_abs_set_res(input_dev, ABS_X,
3992: features->x_resolution);
3993: input_abs_set_res(input_dev, ABS_Y,
3994: features->y_resolution);
3995: }
3996: else if (features->touch_max > 1) {
3997: input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
3998: features->x_max, features->x_fuzz, 0);
3999: input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
]
|
| 117/4 |
2026/09/21 01:06 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 12999
output: 33
thoughts: 147
Thoughts: **Analyzing the Wacom Pen Input Capabilities**
Okay, let's dissect this `wacom_setup_pen_input_capabilities()` function. From what I'm seeing, the only spot where it actually throws an error β and specifically, an `-ENODEV` error β is right here:
```c
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
return -ENODEV;
```
That makes sense, if it's not a pen, it's not going to work. But what's interesting is, looking at the bigger picture, *all* other paths through this function seem to return 0 or are void. Even functions like `wacom_setup_basic_pro_pen()` and `wacom_setup_intuos` don't seem to have any explicit error handling! That feels⦠uncharacteristic, doesn't it? As an expert in this, that looks like a potential area for subtle bugs if something goes wrong later. I think checking `wacom_setup_basic_pro_pen()` more closely is a good idea. Let's see what's happening there.
|
| 118/4 |
2026/09/21 01:06 |
tool |
grepper |
0m
Args: map[Expression:wacom_setup_basic_pro_pen PathPrefix:drivers/hid]
Results: map[Output:drivers/hid/wacom_wac.c=3461=void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
--
drivers/hid/wacom_wac.c-3593-
drivers/hid/wacom_wac.c:3594:static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
drivers/hid/wacom_wac.c-3595-{
--
drivers/hid/wacom_wac.c=3608=static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
--
drivers/hid/wacom_wac.c-3612-
drivers/hid/wacom_wac.c:3613: wacom_setup_basic_pro_pen(wacom_wac);
drivers/hid/wacom_wac.c-3614-
--
drivers/hid/wacom_wac.c=3801=int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
--
drivers/hid/wacom_wac.c-3946- features->type == INTUOSHT3_BT) {
drivers/hid/wacom_wac.c:3947: wacom_setup_basic_pro_pen(wacom_wac);
drivers/hid/wacom_wac.c-3948- } else {
]
|
| 119/4 |
2026/09/21 01:06 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 13818
output: 33
thoughts: 89
Thoughts: **Analyzing the Wacom Pen Setup**
Okay, so `wacom_setup_basic_pro_pen()` is a void function. Thatβs good to know, that it doesn't return anything that I need to capture. Now, I need to get a really solid grasp on *everything* that happens from the point this function is called, right through to the end. I'm going to look at the whole lifecycle, the call paths, the critical references. I'm especially interested in how `pen_input` is handled β where is it used, how is it passed around? And I need to understand the role of `features->device_type` because that probably dictates a lot of the behavior. I also need to track the significance of the interrupt handlers: `wacom_intuos_irq` and `wacom_bpt_irq`. The overall starting point is `wacom_probe`, of course.
So, first things first, I'm going to find *every single* instance where `pen_input` is accessed. That's the key starting point to understand this entire control flow. I need to know where it's created, modified, used, and, eventually, destroyed. Then I can start to connect the dots.
|
| 120/4 |
2026/09/21 01:07 |
tool |
codesearch-find-references |
0m
Args: map[IncludeSnippetLines:5 Name:wacom_wac::pen_input]
Results: map[References:[map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_allocate_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2112 SourceSnippet:2108: static int wacom_allocate_inputs(struct wacom *wacom)
2109: {
2110: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2111:
2112: wacom_wac->pen_input = wacom_allocate_input(wacom);
2113: wacom_wac->touch_input = wacom_allocate_input(wacom);
2114: wacom_wac->pad_input = wacom_allocate_input(wacom);
2115: if (!wacom_wac->pen_input ||
2116: !wacom_wac->touch_input ||
2117: !wacom_wac->pad_input)
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_allocate_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2115 SourceSnippet:2110: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2111:
2112: wacom_wac->pen_input = wacom_allocate_input(wacom);
2113: wacom_wac->touch_input = wacom_allocate_input(wacom);
2114: wacom_wac->pad_input = wacom_allocate_input(wacom);
2115: if (!wacom_wac->pen_input ||
2116: !wacom_wac->touch_input ||
2117: !wacom_wac->pad_input)
2118: return -ENOMEM;
2119:
2120: wacom_wac->pen_input->name = wacom_wac->pen_name;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_allocate_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2120 SourceSnippet:2115: if (!wacom_wac->pen_input ||
2116: !wacom_wac->touch_input ||
2117: !wacom_wac->pad_input)
2118: return -ENOMEM;
2119:
2120: wacom_wac->pen_input->name = wacom_wac->pen_name;
2121: wacom_wac->touch_input->name = wacom_wac->touch_name;
2122: wacom_wac->pad_input->name = wacom_wac->pad_name;
2123:
2124: return 0;
2125: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_bpt_pen SourceFile:drivers/hid/wacom_wac.c SourceLine:3212 SourceSnippet:3209: static int wacom_bpt_pen(struct wacom_wac *wacom)
3210: {
3211: struct wacom_features *features = &wacom->features;
3212: struct input_dev *input = wacom->pen_input;
3213: unsigned char *data = wacom->data;
3214: int x = 0, y = 0, p = 0, d = 0;
3215: bool pen = false, btn1 = false, btn2 = false;
3216: bool range, prox, rdy;
3217:
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_dtu_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:263 SourceSnippet: 260: static int wacom_dtu_irq(struct wacom_wac *wacom)
261: {
262: unsigned char *data = wacom->data;
263: struct input_dev *input = wacom->pen_input;
264: int prox = data[1] & 0x20;
265:
266: dev_dbg(input->dev.parent,
267: "%s: received report #%d", __func__, data[0]);
268:
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_dtus_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:293 SourceSnippet: 290: static int wacom_dtus_irq(struct wacom_wac *wacom)
291: {
292: unsigned char *data = wacom->data;
293: struct input_dev *input = wacom->pen_input;
294: unsigned short prox, pressure = 0;
295:
296: if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
297: dev_dbg(input->dev.parent,
298: "%s: received unknown report #%d", __func__, data[0]);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_exit_report SourceFile:drivers/hid/wacom_wac.c SourceLine:736 SourceSnippet: 734: static void wacom_exit_report(struct wacom_wac *wacom)
735: {
736: struct input_dev *input = wacom->pen_input;
737: struct wacom_features *features = &wacom->features;
738: unsigned char *data = wacom->data;
739: int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
740:
741: /*
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_force_proxout SourceFile:drivers/hid/wacom_wac.c SourceLine:43 SourceSnippet: 41: static void wacom_force_proxout(struct wacom_wac *wacom_wac)
42: {
43: struct input_dev *input = wacom_wac->pen_input;
44:
45: wacom_wac->shared->stylus_in_proximity = 0;
46:
47: input_report_key(input, BTN_TOUCH, 0);
48: input_report_key(input, BTN_STYLUS, 0);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_graphire_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:345 SourceSnippet: 341: static int wacom_graphire_irq(struct wacom_wac *wacom)
342: {
343: struct wacom_features *features = &wacom->features;
344: unsigned char *data = wacom->data;
345: struct input_dev *input = wacom->pen_input;
346: struct input_dev *pad_input = wacom->pad_input;
347: int battery_capacity, ps_connected;
348: int prox;
349: int rw = 0;
350: int retval = 0;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1215 SourceSnippet:1210: unsigned power_raw, battery_capacity, bat_charging, ps_connected;
1211:
1212: switch (data[0]) {
1213: case 0x04:
1214: if (len < 32) {
1215: dev_warn(wacom->pen_input->dev.parent,
1216: "Report 0x04 too short: %zu bytes\n", len);
1217: break;
1218: }
1219: wacom_intuos_bt_process_data(wacom, data + i);
1220: i += 10;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1224 SourceSnippet:1219: wacom_intuos_bt_process_data(wacom, data + i);
1220: i += 10;
1221: fallthrough;
1222: case 0x03:
1223: if (i == 1 && len < 22) {
1224: dev_warn(wacom->pen_input->dev.parent,
1225: "Report 0x03 too short: %zu bytes\n", len);
1226: break;
1227: }
1228: wacom_intuos_bt_process_data(wacom, data + i);
1229: i += 10;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1242 SourceSnippet:1237: battery_capacity, bat_charging,
1238: battery_capacity || bat_charging,
1239: ps_connected);
1240: break;
1241: default:
1242: dev_dbg(wacom->pen_input->dev.parent,
1243: "Unknown report: %d,%d size:%zu\n",
1244: data[0], data[1], len);
1245: break;
1246: }
1247:
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_bt_process_data SourceFile:drivers/hid/wacom_wac.c SourceLine:1201 SourceSnippet:1196:
1197: wacom->data = data;
1198: wacom_intuos_irq(wacom);
1199: wacom->data = saved_data;
1200:
1201: input_sync(wacom->pen_input);
1202: if (wacom->pad_input)
1203: input_sync(wacom->pad_input);
1204: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_general SourceFile:drivers/hid/wacom_wac.c SourceLine:853 SourceSnippet: 849: static int wacom_intuos_general(struct wacom_wac *wacom)
850: {
851: struct wacom_features *features = &wacom->features;
852: unsigned char *data = wacom->data;
853: struct input_dev *input = wacom->pen_input;
854: int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
855: unsigned char type = (data[1] >> 1) & 0x0F;
856: unsigned int x, y, distance, t;
857:
858: if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_inout SourceFile:drivers/hid/wacom_wac.c SourceLine:777 SourceSnippet: 773: static int wacom_intuos_inout(struct wacom_wac *wacom)
774: {
775: struct wacom_features *features = &wacom->features;
776: unsigned char *data = wacom->data;
777: struct input_dev *input = wacom->pen_input;
778: int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
779:
780: if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
781: ((data[1] & 0xfe) == 0x20) || /* in range */
782: ((data[1] & 0xfe) == 0x80))) /* out prox */
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1025 SourceSnippet:1022: static int wacom_intuos_irq(struct wacom_wac *wacom)
1023: {
1024: unsigned char *data = wacom->data;
1025: struct input_dev *input = wacom->pen_input;
1026: int result;
1027:
1028: if (data[0] != WACOM_REPORT_PENABLED &&
1029: data[0] != WACOM_REPORT_INTUOS_ID1 &&
1030: data[0] != WACOM_REPORT_INTUOS_ID2 &&
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_pro2_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1548 SourceSnippet:1543: static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
1544: {
1545: unsigned char *data = wacom->data;
1546:
1547: if (data[0] != 0x80 && data[0] != 0x81) {
1548: dev_dbg(wacom->pen_input->dev.parent,
1549: "%s: received unknown report #%d\n", __func__, data[0]);
1550: return 0;
1551: }
1552:
1553: if (wacom->features.type == INTUOSP2_BT ||
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_pro2_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1556 SourceSnippet:1551: }
1552:
1553: if (wacom->features.type == INTUOSP2_BT ||
1554: wacom->features.type == INTUOSP2S_BT) {
1555: if (len < 286) {
1556: dev_warn(wacom->pen_input->dev.parent,
1557: "Pro2 BT report too short: %zu bytes\n", len);
1558: return 0;
1559: }
1560: } else if (len < 46) {
1561: dev_warn(wacom->pen_input->dev.parent,
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_pro2_bt_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1561 SourceSnippet:1556: dev_warn(wacom->pen_input->dev.parent,
1557: "Pro2 BT report too short: %zu bytes\n", len);
1558: return 0;
1559: }
1560: } else if (len < 46) {
1561: dev_warn(wacom->pen_input->dev.parent,
1562: "Pro2 BT report too short: %zu bytes\n", len);
1563: return 0;
1564: }
1565:
1566: wacom_intuos_pro2_bt_pen(wacom);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_intuos_pro2_bt_pen SourceFile:drivers/hid/wacom_wac.c SourceLine:1279 SourceSnippet:1275: static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1276: {
1277: int pen_frame_len, pen_frames;
1278:
1279: struct input_dev *pen_input = wacom->pen_input;
1280: unsigned char *data = wacom->data;
1281: int number_of_valid_frames = 0;
1282: ktime_t time_interval = 15000000;
1283: ktime_t time_packet_received = ktime_get();
1284: int i;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_penpartner_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:129 SourceSnippet: 126: static int wacom_penpartner_irq(struct wacom_wac *wacom)
127: {
128: unsigned char *data = wacom->data;
129: struct input_dev *input = wacom->pen_input;
130:
131: switch (data[0]) {
132: case 1:
133: if (data[5] & 0x80) {
134: wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_pl_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:174 SourceSnippet: 170: static int wacom_pl_irq(struct wacom_wac *wacom)
171: {
172: struct wacom_features *features = &wacom->features;
173: unsigned char *data = wacom->data;
174: struct input_dev *input = wacom->pen_input;
175: int prox, pressure;
176:
177: if (data[0] != WACOM_REPORT_PENABLED) {
178: dev_dbg(input->dev.parent,
179: "%s: received unknown report #%d\n", __func__, data[0]);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_ptu_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:234 SourceSnippet: 231: static int wacom_ptu_irq(struct wacom_wac *wacom)
232: {
233: unsigned char *data = wacom->data;
234: struct input_dev *input = wacom->pen_input;
235:
236: if (data[0] != WACOM_REPORT_PENABLED) {
237: dev_dbg(input->dev.parent,
238: "%s: received unknown report #%d\n", __func__, data[0]);
239: return 0;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_register_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2173 SourceSnippet:2168: {
2169: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
2170: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2171: int error = 0;
2172:
2173: pen_input_dev = wacom_wac->pen_input;
2174: touch_input_dev = wacom_wac->touch_input;
2175: pad_input_dev = wacom_wac->pad_input;
2176:
2177: if (pen_input_dev) {
2178: error = input_register_device(pen_input_dev);
] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_register_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2200 SourceSnippet:2195: return 0;
2196:
2197: fail:
2198: wacom_wac->pad_input = NULL;
2199: wacom_wac->touch_input = NULL;
2200: wacom_wac->pen_input = NULL;
2201: return error;
2202: }
] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_release_resources SourceFile:drivers/hid/wacom_sys.c SourceLine:2339 SourceSnippet:2334:
2335: devres_release_group(&hdev->dev, wacom);
2336:
2337: wacom->resources = false;
2338:
2339: wacom->wacom_wac.pen_input = NULL;
2340: wacom->wacom_wac.touch_input = NULL;
2341: wacom->wacom_wac.pad_input = NULL;
2342: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_set_barrel_switch3_usage SourceFile:drivers/hid/wacom_wac.c SourceLine:2322 SourceSnippet:2320: static void wacom_set_barrel_switch3_usage(struct wacom_wac *wacom_wac)
2321: {
2322: struct input_dev *input = wacom_wac->pen_input;
2323: struct wacom_features *features = &wacom_wac->features;
2324:
2325: if (!(features->quirks & WACOM_QUIRK_AESPEN) &&
2326: wacom_wac->hid_data.barrelswitch &&
2327: wacom_wac->hid_data.barrelswitch2 &&
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_basic_pro_pen SourceFile:drivers/hid/wacom_wac.c SourceLine:3596 SourceSnippet:3594: static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
3595: {
3596: struct input_dev *input_dev = wacom_wac->pen_input;
3597:
3598: input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
3599:
3600: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3601: __set_bit(BTN_STYLUS, input_dev->keybit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_cintiq SourceFile:drivers/hid/wacom_wac.c SourceLine:3610 SourceSnippet:3608: static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
3609: {
3610: struct input_dev *input_dev = wacom_wac->pen_input;
3611: struct wacom_features *features = &wacom_wac->features;
3612:
3613: wacom_setup_basic_pro_pen(wacom_wac);
3614:
3615: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787 SourceSnippet:3782: /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3783: * of things it shouldn't. Lets fix up the damage...
3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787 SourceSnippet:3782: /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3783: * of things it shouldn't. Lets fix up the damage...
3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787 SourceSnippet:3782: /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3783: * of things it shouldn't. Lets fix up the damage...
3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787 SourceSnippet:3782: /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3783: * of things it shouldn't. Lets fix up the damage...
3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3787 SourceSnippet:3782: /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3783: * of things it shouldn't. Lets fix up the damage...
3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788 SourceSnippet:3783: * of things it shouldn't. Lets fix up the damage...
3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788 SourceSnippet:3783: * of things it shouldn't. Lets fix up the damage...
3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788 SourceSnippet:3783: * of things it shouldn't. Lets fix up the damage...
3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788 SourceSnippet:3783: * of things it shouldn't. Lets fix up the damage...
3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3788 SourceSnippet:3783: * of things it shouldn't. Lets fix up the damage...
3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789 SourceSnippet:3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789 SourceSnippet:3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789 SourceSnippet:3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789 SourceSnippet:3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3789 SourceSnippet:3784: */
3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790 SourceSnippet:3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790 SourceSnippet:3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790 SourceSnippet:3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790 SourceSnippet:3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3790 SourceSnippet:3785: if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791 SourceSnippet:3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791 SourceSnippet:3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791 SourceSnippet:3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791 SourceSnippet:3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3791 SourceSnippet:3786: features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792 SourceSnippet:3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792 SourceSnippet:3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792 SourceSnippet:3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792 SourceSnippet:3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3792 SourceSnippet:3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793 SourceSnippet:3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793 SourceSnippet:3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793 SourceSnippet:3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793 SourceSnippet:3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3793 SourceSnippet:3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794 SourceSnippet:3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794 SourceSnippet:3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794 SourceSnippet:3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794 SourceSnippet:3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3794 SourceSnippet:3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795 SourceSnippet:3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795 SourceSnippet:3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795 SourceSnippet:3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795 SourceSnippet:3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3795 SourceSnippet:3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796 SourceSnippet:3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796 SourceSnippet:3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796 SourceSnippet:3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796 SourceSnippet:3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3796 SourceSnippet:3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797 SourceSnippet:3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797 SourceSnippet:3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797 SourceSnippet:3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797 SourceSnippet:3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_device_quirks SourceFile:drivers/hid/wacom_wac.c SourceLine:3797 SourceSnippet:3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3798: }
3799: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2133 SourceSnippet:2128: {
2129: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
2130: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2131: int error = 0;
2132:
2133: pen_input_dev = wacom_wac->pen_input;
2134: touch_input_dev = wacom_wac->touch_input;
2135: pad_input_dev = wacom_wac->pad_input;
2136:
2137: if (!pen_input_dev || !touch_input_dev || !pad_input_dev)
2138: return -EINVAL;
] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:wacom_setup_inputs SourceFile:drivers/hid/wacom_sys.c SourceLine:2144 SourceSnippet:2139:
2140: error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
2141: if (error) {
2142: /* no pen in use on this interface */
2143: input_free_device(pen_input_dev);
2144: wacom_wac->pen_input = NULL;
2145: pen_input_dev = NULL;
2146: }
2147:
2148: error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac);
2149: if (error) {
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_setup_intuos SourceFile:drivers/hid/wacom_wac.c SourceLine:3629 SourceSnippet:3627: static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
3628: {
3629: struct input_dev *input_dev = wacom_wac->pen_input;
3630:
3631: input_set_capability(input_dev, EV_REL, REL_WHEEL);
3632:
3633: wacom_setup_cintiq(wacom_wac);
3634:
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_tpc_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1799 SourceSnippet:1795: static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1796: {
1797: unsigned char *data = wacom->data;
1798:
1799: if (wacom->pen_input) {
1800: dev_dbg(wacom->pen_input->dev.parent,
1801: "%s: received report #%d\n", __func__, data[0]);
1802:
1803: if (len == WACOM_PKGLEN_PENABLED ||
1804: data[0] == WACOM_REPORT_PENABLED)
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_tpc_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:1800 SourceSnippet:1795: static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1796: {
1797: unsigned char *data = wacom->data;
1798:
1799: if (wacom->pen_input) {
1800: dev_dbg(wacom->pen_input->dev.parent,
1801: "%s: received report #%d\n", __func__, data[0]);
1802:
1803: if (len == WACOM_PKGLEN_PENABLED ||
1804: data[0] == WACOM_REPORT_PENABLED)
1805: return wacom_tpc_pen(wacom);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_tpc_pen SourceFile:drivers/hid/wacom_wac.c SourceLine:1768 SourceSnippet:1765: static int wacom_tpc_pen(struct wacom_wac *wacom)
1766: {
1767: unsigned char *data = wacom->data;
1768: struct input_dev *input = wacom->pen_input;
1769: bool prox = data[1] & 0x20;
1770:
1771: if (!wacom->shared->stylus_in_proximity) /* first in prox */
1772: /* Going into proximity select tool */
1773: wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_collection SourceFile:drivers/hid/wacom_wac.c SourceLine:3018 SourceSnippet:3013: if (report->type != HID_INPUT_REPORT)
3014: return -1;
3015:
3016: if (WACOM_PAD_FIELD(field))
3017: return 0;
3018: else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
3019: wacom_wac_pen_report(hdev, report);
3020: else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
3021: wacom_wac_finger_report(hdev, report);
3022:
3023: return 0;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_event SourceFile:drivers/hid/wacom_wac.c SourceLine:2966 SourceSnippet:2961: /* usage tests must precede field tests */
2962: if (WACOM_BATTERY_USAGE(usage))
2963: wacom_wac_battery_event(hdev, field, usage, value);
2964: else if (WACOM_PAD_FIELD(field))
2965: wacom_wac_pad_event(hdev, field, usage, value);
2966: else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2967: wacom_wac_pen_event(hdev, field, usage, value);
2968: else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2969: wacom_wac_finger_event(hdev, field, usage, value);
2970: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:3585 SourceSnippet:3580: sync = false;
3581: break;
3582: }
3583:
3584: if (sync) {
3585: if (wacom_wac->pen_input)
3586: input_sync(wacom_wac->pen_input);
3587: if (wacom_wac->touch_input)
3588: input_sync(wacom_wac->touch_input);
3589: if (wacom_wac->pad_input)
3590: input_sync(wacom_wac->pad_input);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_irq SourceFile:drivers/hid/wacom_wac.c SourceLine:3586 SourceSnippet:3581: break;
3582: }
3583:
3584: if (sync) {
3585: if (wacom_wac->pen_input)
3586: input_sync(wacom_wac->pen_input);
3587: if (wacom_wac->touch_input)
3588: input_sync(wacom_wac->touch_input);
3589: if (wacom_wac->pad_input)
3590: input_sync(wacom_wac->pad_input);
3591: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pen_event SourceFile:drivers/hid/wacom_wac.c SourceLine:2429 SourceSnippet:2424: struct hid_usage *usage, __s32 value)
2425: {
2426: struct wacom *wacom = hid_get_drvdata(hdev);
2427: struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2428: struct wacom_features *features = &wacom_wac->features;
2429: struct input_dev *input = wacom_wac->pen_input;
2430: unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2431:
2432: if (wacom_wac->is_invalid_bt_frame)
2433: return;
2434:
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pen_report SourceFile:drivers/hid/wacom_wac.c SourceLine:2586 SourceSnippet:2581: static void wacom_wac_pen_report(struct hid_device *hdev,
2582: struct hid_report *report)
2583: {
2584: struct wacom *wacom = hid_get_drvdata(hdev);
2585: struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2586: struct input_dev *input = wacom_wac->pen_input;
2587: bool range = wacom_wac->hid_data.inrange_state;
2588: bool sense = wacom_wac->hid_data.sense_state;
2589: bool entering_range = !wacom_wac->tool[0] && range;
2590:
2591: if (wacom_wac->is_invalid_bt_frame)
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_pen_usage_mapping SourceFile:drivers/hid/wacom_wac.c SourceLine:2341 SourceSnippet:2336: struct hid_field *field, struct hid_usage *usage)
2337: {
2338: struct wacom *wacom = hid_get_drvdata(hdev);
2339: struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2340: struct wacom_features *features = &wacom_wac->features;
2341: struct input_dev *input = wacom_wac->pen_input;
2342: unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2343:
2344: switch (equivalent_usage) {
2345: case HID_GD_X:
2346: wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:wacom_wac_report SourceFile:drivers/hid/wacom_wac.c SourceLine:3056 SourceSnippet:3051:
3052: wacom_wac_battery_pre_report(hdev, report);
3053:
3054: if (pad_in_hid_field && wacom_wac->pad_input)
3055: wacom_wac_pad_pre_report(hdev, report);
3056: if (pen_in_hid_field && wacom_wac->pen_input)
3057: wacom_wac_pen_pre_report(hdev, report);
3058: if (finger_in_hid_field && wacom_wac->touch_input)
3059: wacom_wac_finger_pre_report(hdev, report);
3060:
3061: for (r = 0; r < report->maxfield; r++) {
]] TruncatedOutput:false]
|
| 121/4 |
2026/09/21 01:07 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 44399
output: 40
thoughts: 741
Thoughts: **Analyzing Potential Null Pointer Dereference in Wacom Driver**
Okay, so the user is concerned about a possible null pointer dereference in the Wacom driver, specifically within `wacom_intuos_irq()`. I see that `wacom->pen_input` is being dereferenced there. The question boils down to *when* and *why* could this pointer be unexpectedly NULL. I've noted down all the places in the code where `wacom_wac->pen_input` is written to.
First, `wacom_allocate_inputs()` sets the initial allocation. Then, `wacom_setup_inputs()` is responsible for setting up the pen input's capabilities. It's in this function that a potential problem *could* arise. If `wacom_setup_pen_input_capabilities()` fails, `pen_input_dev` is freed and `wacom_wac->pen_input` is set to NULL. However, the user points out that the calling function, `wacom_bpt_irq()`, checks if the device is of pen type, so a failure due to a missing pen shouldn't happen, right? The user is suggesting that there might be another reason for the failure of `wacom_setup_pen_input_capabilities()`.
Further, `wacom_register_inputs()` explicitly NULLs out this pointer upon failure (in `fail:`). Finally, `wacom_release_resources()` also does a cleanup setting all input pointers to NULL, which could be relevant if it's called prematurely.
The user has presented a very well-thought-out set of questions. They're correctly identifying the potential race conditions and other scenarios where `wacom->pen_input` could be unexpectedly NULL. I need to investigate the other possible error conditions for `wacom_setup_pen_input_capabilities()` and identify other paths through the code where `wacom->pen_input` could be nullified after it's been initialized in `wacom_setup_inputs()`. I'll need to scrutinize the calling context of `wacom_bpt_irq()` and `wacom_intuos_irq()` to be sure that the pre-conditions are met and that these functions don't run out of order. Let's start by digging into `wacom_bpt_irq()`, `wacom_intuos_irq()` and checking driver flow. I'm going to look at lines 3280-3320 in `drivers/hid/wacom_wac.c` to see if I can find the answer.
|
| 122/4 |
2026/09/21 01:07 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3280 LineCount:40]
Results: map[Contents:3280:
3281: return 1;
3282: }
3283:
3284: static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
3285: {
3286: struct wacom_features *features = &wacom->features;
3287:
3288: if ((features->type == INTUOSHT2) &&
3289: (features->device_type & WACOM_DEVICETYPE_PEN))
3290: return wacom_intuos_irq(wacom);
3291: else if (len == WACOM_PKGLEN_BBTOUCH)
3292: return wacom_bpt_touch(wacom);
3293: else if (len == WACOM_PKGLEN_BBTOUCH3)
3294: return wacom_bpt3_touch(wacom);
3295: else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
3296: return wacom_bpt_pen(wacom);
3297:
3298: return 0;
3299: }
3300:
3301: static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
3302: unsigned char *data)
3303: {
3304: unsigned char prefix;
3305:
3306: /*
3307: * We need to reroute the event from the debug interface to the
3308: * pen interface.
3309: * We need to add the report ID to the actual pen report, so we
3310: * temporary overwrite the first byte to prevent having to kzalloc/kfree
3311: * and memcpy the report.
3312: */
3313: prefix = data[0];
3314: data[0] = WACOM_REPORT_BPAD_PEN;
3315:
3316: /*
3317: * actually reroute the event.
3318: * No need to check if wacom->shared->pen is valid, hid_input_report()
3319: * will check for us.
]
|
| 123/4 |
2026/09/21 01:07 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 46374
output: 40
thoughts: 28
Thoughts: Here's a summary of my thought process, as requested:
**Diving Deeper into the Wacom Driver**
Okay, so we've been examining the Wacom driver code, and now I need to shift my focus to a specific area to understand a potential interaction point or issue. My brain is telling me to dig into the `wacom_intuos_irq()` function, specifically between lines 1020 and 1060. That section likely handles interrupt processing for the Intuos line, which is a key area for input responsiveness and, potentially, where latency or data corruption problems could manifest. I need to understand what's happening within that code block: data parsing, buffer handling, possibly interrupt acknowledge routines β all of it. I want to see if any obvious bottlenecks or incorrect assumptions are present. Time to get down into the weeds of the interrupt handler and see what the Wacom dev team cooked up. Let's see if we can find some interesting tidbits.
|
| 124/4 |
2026/09/21 01:07 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:1020 LineCount:40]
Results: map[Contents:1020: }
1021:
1022: static int wacom_intuos_irq(struct wacom_wac *wacom)
1023: {
1024: unsigned char *data = wacom->data;
1025: struct input_dev *input = wacom->pen_input;
1026: int result;
1027:
1028: if (data[0] != WACOM_REPORT_PENABLED &&
1029: data[0] != WACOM_REPORT_INTUOS_ID1 &&
1030: data[0] != WACOM_REPORT_INTUOS_ID2 &&
1031: data[0] != WACOM_REPORT_INTUOSPAD &&
1032: data[0] != WACOM_REPORT_INTUOS_PEN &&
1033: data[0] != WACOM_REPORT_CINTIQ &&
1034: data[0] != WACOM_REPORT_CINTIQPAD &&
1035: data[0] != WACOM_REPORT_INTUOS5PAD) {
1036: dev_dbg(input->dev.parent,
1037: "%s: received unknown report #%d\n", __func__, data[0]);
1038: return 0;
1039: }
1040:
1041: /* process pad events */
1042: result = wacom_intuos_pad(wacom);
1043: if (result)
1044: return result;
1045:
1046: /* process in/out prox events */
1047: result = wacom_intuos_inout(wacom);
1048: if (result)
1049: return result - 1;
1050:
1051: /* process general packets */
1052: result = wacom_intuos_general(wacom);
1053: if (result)
1054: return result - 1;
1055:
1056: return 0;
1057: }
1058:
1059: static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
]
|
| 125/4 |
2026/09/21 01:07 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 47280
output: 42
thoughts: 140
Thoughts: **My Initial Thoughts on the Wacom Driver Code**
Okay, let's dissect this. I'm looking at `wacom_intuos_irq()` and immediately see: `struct input_dev *input = wacom->pen_input;`. Good, standard pointer assignment to an input device. Then, the conditional check for an unknown report: `if data[0] != WACOM_REPORT_...`, and the debug message: `dev_dbg(input->dev.parent, "%s: received unknown report #%d\n", __func__, data[0]);`. Wait a second... `input->dev.parent`... that's a direct dereference of `input`. No null check! That could be a problem if `pen_input` *isn't* properly initialized or goes awry. Gotta make a note to check that.
Now, I'm shifting focus to `wacom_intuos_pad()`. Is it using `pad_input` or `pen_input`? It's important to understand this because this is where the pad input processing is handled. The potential for the same null dereference vulnerability exists, depending on the implementation. Let's dig deeper and see what's actually happening in `wacom_intuos_pad()`. I need to understand its relationship to `pen_input`. This could be a critical area to examine for possible vulnerabilities if this code isn't implemented correctly.
|
| 126/4 |
2026/09/21 01:07 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_wac.c Name:wacom_intuos_pad]
Results: map[SourceCode: 513: static int wacom_intuos_pad(struct wacom_wac *wacom)
514: {
515: struct wacom_features *features = &wacom->features;
516: unsigned char *data = wacom->data;
517: struct input_dev *input = wacom->pad_input;
518: int i;
519: int buttons = 0, nbuttons = features->numbered_buttons;
520: int keys = 0, nkeys = 0;
521: int ring1 = 0, ring2 = 0;
522: int strip1 = 0, strip2 = 0;
523: bool prox = false;
524: bool wrench = false, keyboard = false, mute_touch = false, menu = false,
525: info = false;
526:
527: /* pad packets. Works as a second tool and is always in prox */
528: if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
529: data[0] == WACOM_REPORT_CINTIQPAD))
530: return 0;
531:
532: if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
533: buttons = (data[3] << 1) | (data[2] & 0x01);
534: ring1 = data[1];
535: } else if (features->type == DTK) {
536: buttons = data[6];
537: } else if (features->type == WACOM_13HD) {
538: buttons = (data[4] << 1) | (data[3] & 0x01);
539: } else if (features->type == WACOM_24HD) {
540: buttons = (data[8] << 8) | data[6];
541: ring1 = data[1];
542: ring2 = data[2];
543:
544: /*
545: * Three "buttons" are available on the 24HD which are
546: * physically implemented as a touchstrip. Each button
547: * is approximately 3 bits wide with a 2 bit spacing.
548: * The raw touchstrip bits are stored at:
549: * ((data[3] & 0x1f) << 8) | data[4])
550: */
551: nkeys = 3;
552: keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
553: ((data[4] & 0xE0) ? 1<<1 : 0) |
554: ((data[4] & 0x07) ? 1<<0 : 0);
555: keyboard = !!(data[4] & 0xE0);
556: info = !!(data[3] & 0x1C);
557:
558: if (features->oPid) {
559: mute_touch = !!(data[4] & 0x07);
560: if (mute_touch)
561: wacom->shared->is_touch_on =
562: !wacom->shared->is_touch_on;
563: } else {
564: wrench = !!(data[4] & 0x07);
565: }
566: } else if (features->type == WACOM_27QHD) {
567: nkeys = 3;
568: keys = data[2] & 0x07;
569:
570: wrench = !!(data[2] & 0x01);
571: keyboard = !!(data[2] & 0x02);
572:
573: if (features->oPid) {
574: mute_touch = !!(data[2] & 0x04);
575: if (mute_touch)
576: wacom->shared->is_touch_on =
577: !wacom->shared->is_touch_on;
578: } else {
579: menu = !!(data[2] & 0x04);
580: }
581: input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
582: input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
583: input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
584: } else if (features->type == CINTIQ_HYBRID) {
585: /*
586: * Do not send hardware buttons under Android. They
587: * are already sent to the system through GPIO (and
588: * have different meaning).
589: *
590: * d-pad right -> data[4] & 0x10
591: * d-pad up -> data[4] & 0x20
592: * d-pad left -> data[4] & 0x40
593: * d-pad down -> data[4] & 0x80
594: * d-pad center -> data[3] & 0x01
595: */
596: buttons = (data[4] << 1) | (data[3] & 0x01);
597: } else if (features->type == CINTIQ_COMPANION_2) {
598: /* d-pad right -> data[2] & 0x10
599: * d-pad up -> data[2] & 0x20
600: * d-pad left -> data[2] & 0x40
601: * d-pad down -> data[2] & 0x80
602: * d-pad center -> data[1] & 0x01
603: */
604: buttons = ((data[2] >> 4) << 7) |
605: ((data[1] & 0x04) << 4) |
606: ((data[2] & 0x0F) << 2) |
607: (data[1] & 0x03);
608: } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
609: /*
610: * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
611: * addition to the mechanical switch. Switch data is
612: * stored in data[4], capacitive data in data[5].
613: *
614: * Touch ring mode switch (data[3]) has no capacitive sensor
615: */
616: buttons = (data[4] << 1) | (data[3] & 0x01);
617: ring1 = data[2];
618: } else {
619: if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
620: buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) |
621: (data[6] << 1) | (data[5] & 0x01);
622:
623: if (features->type == WACOM_22HD) {
624: nkeys = 3;
625: keys = data[9] & 0x07;
626:
627: info = !!(data[9] & 0x01);
628: wrench = !!(data[9] & 0x02);
629: }
630: } else {
631: buttons = ((data[6] & 0x10) << 5) |
632: ((data[5] & 0x10) << 4) |
633: ((data[6] & 0x0F) << 4) |
634: (data[5] & 0x0F);
635: }
636: strip1 = ((data[1] & 0x1f) << 8) | data[2];
637: strip2 = ((data[3] & 0x1f) << 8) | data[4];
638: }
639:
640: prox = (buttons & ~(~0U << nbuttons)) | (keys & ~(~0U << nkeys)) |
641: (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2;
642:
643: wacom_report_numbered_buttons(input, nbuttons, buttons);
644:
645: for (i = 0; i < nkeys; i++)
646: input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
647:
648: input_report_key(input, KEY_BUTTONCONFIG, wrench);
649: input_report_key(input, KEY_ONSCREEN_KEYBOARD, keyboard);
650: input_report_key(input, KEY_CONTROLPANEL, menu);
651: input_report_key(input, KEY_INFO, info);
652:
653: if (wacom->shared && wacom->shared->touch_input) {
654: input_report_switch(wacom->shared->touch_input,
655: SW_MUTE_DEVICE,
656: !wacom->shared->is_touch_on);
657: input_sync(wacom->shared->touch_input);
658: }
659:
660: input_report_abs(input, ABS_RX, strip1);
661: input_report_abs(input, ABS_RY, strip2);
662:
663: input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0);
664: input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0);
665:
666: input_report_key(input, wacom->tool[1], prox ? 1 : 0);
667: input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
668:
669: input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
670:
671: return 1;
672: }
SourceFile:drivers/hid/wacom_wac.c]
|
| 127/4 |
2026/09/21 01:07 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 50896
output: 29
thoughts: 1397
Thoughts: **Deep Dive into Wacom Driver Logic**
Okay, here's the breakdown of my thinking as I delve into this Wacom driver issue. First, I'm zeroing in on the problematic scenario: a NULL `wacom->pen_input` within `wacom_intuos_irq()`. The code snippet highlights that if the received report's first byte is unknown, it logs a debug message and returns. My immediate questions are: Why is `wacom->pen_input` possibly NULL at this point? And is there a bigger problem?
My initial instinct is to consider the data flow and potential race conditions. I see that `wacom_intuos_irq()`, `wacom_intuos_inout()`, and `wacom_intuos_general()` all access the `data` buffer and the `pen_input` device, along with the `features` struct. These are all passed as arguments to each respective function. Therefore, there can't be a race condition, or memory corruption.
I am now thinking about how the `features->device_type` is determined, and when it is set. The questions are:
* Where does `features->device_type` come from? Where and when is it set?
* Could `features->device_type` be modified *after* `wacom_setup_inputs()`?
* Could `wacom_bpt_irq()` be called *before* `wacom_setup_inputs()` completes?
* Could `wacom_setup_pen_input_capabilities()` return an error for another reason?
* Could `wacom->pen_input` be freed/set to NULL somewhere else after `wacom_setup_inputs()`?
* Are there ANY other ways `wacom->pen_input` can be NULL when `wacom_intuos_irq()` is called?
Let's start by methodically addressing these concerns.
First, the user asks about the function `wacom_setup_pen_input_capabilities()`:
"Could `wacom_setup_pen_input_capabilities()` return an error for another reason?"
I'm going to exhaustively examine that function. I'm focusing on potential error paths. Let's look at the implementation:
I read through the code in `wacom_setup_pen_input_capabilities()` to see if there is any other error that can cause a non-zero return value:
```c
int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac)
{
struct wacom_features *features = &wacom_wac->features;
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
return -ENODEV;
if (features->device_type & WACOM_DEVICETYPE_DIRECT)
__set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
else
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
if (features->type == HID_GENERIC)
/* setup has already been done */
return 0;
input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
__set_bit(BTN_TOUCH, input_dev->keybit);
__set_bit(ABS_MISC, input_dev->absbit);
input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
features->x_max - features->offset_right,
features->x_fuzz, 0);
input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
features->y_max - features->offset_bottom,
features->y_fuzz, 0);
input_set_abs_params(input_dev, ABS_PRESSURE, 0,
features->pressure_max, features->pressure_fuzz, 0);
/* penabled devices have fixed resolution for each model */
input_abs_set_res(input_dev, ABS_X, features->x_resolution);
input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
switch (features->type) {
```
I see that it checks `if (!(features->device_type & WACOM_DEVICETYPE_PEN
|
| 128/4 |
2026/09/21 01:07 |
tool |
grepper |
0m
Args: map[Expression:wacom_setup_inputs PathPrefix:drivers/hid]
Results: map[Output:drivers/hid/wacom_sys.c=2108=static int wacom_allocate_inputs(struct wacom *wacom)
--
drivers/hid/wacom_sys.c-2126-
drivers/hid/wacom_sys.c:2127:static int wacom_setup_inputs(struct wacom *wacom)
drivers/hid/wacom_sys.c-2128-{
--
drivers/hid/wacom_sys.c=2370=static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
--
drivers/hid/wacom_sys.c-2446-
drivers/hid/wacom_sys.c:2447: error = wacom_setup_inputs(wacom);
drivers/hid/wacom_sys.c-2448- if (error)
]
|
| 129/4 |
2026/09/21 01:07 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 53572
output: 39
thoughts: 29
Thoughts: Okay, let's dive into this Wacom driver initialization. I need to get a handle on how this thing gets off the ground.
**Diving into the Wacom Driver Initialization**
Right, so I'm going to start by tracing the initialization of this Wacom driver, specifically focusing on `wacom_parse_and_register()` and `wacom_probe()`. The goal is to get a solid understanding of the entire initialization sequence from the driver's perspective. I need to identify exactly *how* the driver is being bound to the device, the data it's pulling from the device, and the key steps involved in registering itself with the input subsystem. I'm looking for the critical points: what's the driver looking for in the hardware, how it's configuring itself, and what it's telling the kernel about its capabilities. Knowing this, I should be able to identify any points for optimization or potential areas that might be causing specific issues down the line with the tablet. I need to be able to map this against my understanding of the relevant protocols and kernel subsystems. I want to see if they are doing anything clever, or potentially inefficient.
|
| 130/4 |
2026/09/21 01:07 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2440 LineCount:80]
Results: map[Contents:2440: goto fail;
2441: }
2442:
2443: error = wacom_add_shared_data(hdev);
2444: if (error)
2445: goto fail;
2446:
2447: error = wacom_setup_inputs(wacom);
2448: if (error)
2449: goto fail;
2450:
2451: if (features->type == HID_GENERIC)
2452: connect_mask |= HID_CONNECT_DRIVER;
2453:
2454: /* Regular HID work starts now */
2455: error = hid_hw_start(hdev, connect_mask);
2456: if (error) {
2457: hid_err(hdev, "hw start failed\n");
2458: goto fail;
2459: }
2460:
2461: error = wacom_register_inputs(wacom);
2462: if (error)
2463: goto fail_hw_stop;
2464:
2465: if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) {
2466: error = wacom_initialize_leds(wacom);
2467: if (error)
2468: goto fail_hw_stop;
2469:
2470: error = wacom_initialize_remotes(wacom);
2471: if (error)
2472: goto fail_hw_stop;
2473: }
2474:
2475: if (!wireless) {
2476: /* Note that if query fails it is not a hard failure */
2477: wacom_query_tablet_data(wacom);
2478: }
2479:
2480: /* touch only Bamboo doesn't support pen */
2481: if ((features->type == BAMBOO_TOUCH) &&
2482: (features->device_type & WACOM_DEVICETYPE_PEN)) {
2483: cancel_delayed_work_sync(&wacom->init_work);
2484: _wacom_query_tablet_data(wacom);
2485: error = -ENODEV;
2486: goto fail_hw_stop;
2487: }
2488:
2489: if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) {
2490: error = hid_hw_open(hdev);
2491: if (error) {
2492: hid_err(hdev, "hw open failed\n");
2493: goto fail_hw_stop;
2494: }
2495: }
2496:
2497: wacom_set_shared_values(wacom_wac);
2498: devres_close_group(&hdev->dev, wacom);
2499:
2500: return 0;
2501:
2502: fail_hw_stop:
2503: hid_hw_stop(hdev);
2504: fail:
2505: wacom_release_resources(wacom);
2506: return error;
2507: }
2508:
2509: static void wacom_wireless_work(struct work_struct *work)
2510: {
2511: struct wacom *wacom = container_of(work, struct wacom, wireless_work);
2512: struct usb_device *usbdev = wacom->usbdev;
2513: struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2514: struct hid_device *hdev1, *hdev2;
2515: struct wacom *wacom1, *wacom2;
2516: struct wacom_wac *wacom_wac1, *wacom_wac2;
2517: int error;
2518:
2519: /*
]
|
| 131/4 |
2026/09/21 01:07 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 55036
output: 31
thoughts: 727
Thoughts: **Analyzing the Wacom Input Registration Flow**
Okay, let's dive into this `wacom_parse_and_register()` function. I need to understand the device registration sequence, especially how it handles failures. My first thought is to zero in on how errors are managed after a failed `wacom_register_inputs(wacom)` call. It looks like a failure there goes to `fail_hw_stop`, which calls `hid_hw_stop(hdev)` and then to `fail:`, which calls `wacom_release_resources(wacom)` and returns the error code. Good, that's clean.
Now, let's zoom in on `wacom_register_inputs(wacom)`. I see that it tries to register input devices: pen, touch, and pad. Each one has its own `input_dev` and a failure during the `input_register_device()` call for any of them triggers a `goto fail`. On `fail`, the input devices are set to NULL before returning the error. Okay, seems standard.
Now, back to the larger context. In `wacom_parse_and_register`, the order matters: first `hid_hw_start(hdev, connect_mask)` then `wacom_register_inputs(wacom)`. `hid_hw_start` is called before the input devices are registered. That's a key point. This raises a question. Does `hid_hw_start` *start* receiving reports or could an IRQ / raw_event come in? Also, does it open the device? My concern here is what happens if `wacom_register_inputs` fails after `hid_hw_start` has done something. What actually opens the HID device? I need to understand what functions might be called from an interrupt or raw event context. I should check how and when `wacom_raw_event` and `hid_hw_open` are called! I will search for callers of `wacom_bpt_irq` and `wacom_wac_irq` to see what is running.
|
| 132/4 |
2026/09/21 01:07 |
tool |
grepper |
0m
Args: map[Expression:wacom_wac_irq PathPrefix:drivers/hid]
Results: map[Output:drivers/hid/wacom.h=229=extern const struct hid_device_id wacom_ids[];
drivers/hid/wacom.h-230-
drivers/hid/wacom.h:231:void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
drivers/hid/wacom.h-232-void wacom_setup_device_quirks(struct wacom *wacom);
--
drivers/hid/wacom_sys.c=169=static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
--
drivers/hid/wacom_sys.c-181-
drivers/hid/wacom_sys.c:182: wacom_wac_irq(&wacom->wacom_wac, size);
drivers/hid/wacom_sys.c-183-
--
drivers/hid/wacom_wac.c=3427=static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
--
drivers/hid/wacom_wac.c-3460-
drivers/hid/wacom_wac.c:3461:void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
drivers/hid/wacom_wac.c-3462-{
]
|
| 133/4 |
2026/09/21 01:07 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 56619
output: 38
thoughts: 26
Thoughts: Okay, here we go...
**Diving into the Wacom Driver**
Alright, time to crack open `drivers/hid/wacom_sys.c` and have a look at the `wacom_raw_event` function. I'm keen to see how they're handling the raw input data coming from the Wacom devices. I'm especially interested in how they process the different event types - pressure, tilt, proximity, button presses, the works. I want to see how they're doing the initial decoding and formatting of the data before passing it up the input event chain. I'll be looking for any potential optimizations, error handling, and perhaps some interesting techniques they use to account for the nuances of different Wacom models. This is where the rubber meets the road, where the raw sensor data gets translated into something usable by the rest of the system, and that's always interesting to dissect. Let's get to it!
|
| 134/4 |
2026/09/21 01:08 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:165 LineCount:40]
Results: map[Contents: 165:
166: return insert && !flush;
167: }
168:
169: static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
170: u8 *raw_data, int size)
171: {
172: struct wacom *wacom = hid_get_drvdata(hdev);
173:
174: if (wacom->wacom_wac.features.type == BOOTLOADER)
175: return 0;
176:
177: if (wacom_wac_pen_serial_enforce(hdev, report, raw_data, size))
178: return -1;
179:
180: wacom->wacom_wac.data = raw_data;
181:
182: wacom_wac_irq(&wacom->wacom_wac, size);
183:
184: return 0;
185: }
186:
187: static int wacom_open(struct input_dev *dev)
188: {
189: struct wacom *wacom = input_get_drvdata(dev);
190:
191: return hid_hw_open(wacom->hdev);
192: }
193:
194: static void wacom_close(struct input_dev *dev)
195: {
196: struct wacom *wacom = input_get_drvdata(dev);
197:
198: /*
199: * wacom->hdev should never be null, but surprisingly, I had the case
200: * once while unplugging the Wacom Wireless Receiver.
201: */
202: if (wacom->hdev)
203: hid_hw_close(wacom->hdev);
204: }
]
|
| 135/4 |
2026/09/21 01:08 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 57456
output: 41
thoughts: 90
Thoughts: Here's my thought process, as I delve into this code:
**Analyzing the Wacom Interrupt Handling**
Okay, so I'm looking into how Wacom tablets handle interrupt events. First, the `wacom_raw_event` function seems to be the entry point. It appears to call `wacom_wac_irq` with the `wacom->wacom_wac` data structure and a size parameter. Got it, that's the starting point.
Now, I need to understand what `wacom_wac_irq` *actually* does. So, I need to head over to `drivers/hid/wacom_wac.c` and hunt for that function. It looks like the relevant code will be around line 3461. Let's see what's happening in there. Time to dig in!
|
| 136/4 |
2026/09/21 01:08 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3460 LineCount:100]
Results: map[Contents:3460:
3461: void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
3462: {
3463: bool sync;
3464:
3465: switch (wacom_wac->features.type) {
3466: case PENPARTNER:
3467: sync = wacom_penpartner_irq(wacom_wac);
3468: break;
3469:
3470: case PL:
3471: sync = wacom_pl_irq(wacom_wac);
3472: break;
3473:
3474: case WACOM_G4:
3475: case GRAPHIRE:
3476: case GRAPHIRE_BT:
3477: case WACOM_MO:
3478: sync = wacom_graphire_irq(wacom_wac);
3479: break;
3480:
3481: case PTU:
3482: sync = wacom_ptu_irq(wacom_wac);
3483: break;
3484:
3485: case DTU:
3486: sync = wacom_dtu_irq(wacom_wac);
3487: break;
3488:
3489: case DTUS:
3490: case DTUSX:
3491: sync = wacom_dtus_irq(wacom_wac);
3492: break;
3493:
3494: case INTUOS:
3495: case INTUOS3S:
3496: case INTUOS3:
3497: case INTUOS3L:
3498: case INTUOS4S:
3499: case INTUOS4:
3500: case INTUOS4L:
3501: case CINTIQ:
3502: case WACOM_BEE:
3503: case WACOM_13HD:
3504: case WACOM_21UX2:
3505: case WACOM_22HD:
3506: case WACOM_24HD:
3507: case WACOM_27QHD:
3508: case DTK:
3509: case CINTIQ_HYBRID:
3510: case CINTIQ_COMPANION_2:
3511: sync = wacom_intuos_irq(wacom_wac);
3512: break;
3513:
3514: case INTUOS4WL:
3515: sync = wacom_intuos_bt_irq(wacom_wac, len);
3516: break;
3517:
3518: case WACOM_24HDT:
3519: case WACOM_27QHDT:
3520: sync = wacom_24hdt_irq(wacom_wac);
3521: break;
3522:
3523: case INTUOS5S:
3524: case INTUOS5:
3525: case INTUOS5L:
3526: case INTUOSPS:
3527: case INTUOSPM:
3528: case INTUOSPL:
3529: if (len == WACOM_PKGLEN_BBTOUCH3)
3530: sync = wacom_bpt3_touch(wacom_wac);
3531: else if (wacom_wac->data[0] == WACOM_REPORT_USB)
3532: sync = wacom_status_irq(wacom_wac, len);
3533: else
3534: sync = wacom_intuos_irq(wacom_wac);
3535: break;
3536:
3537: case INTUOSP2_BT:
3538: case INTUOSP2S_BT:
3539: case INTUOSHT3_BT:
3540: sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
3541: break;
3542:
3543: case TABLETPC:
3544: case TABLETPCE:
3545: case TABLETPC2FG:
3546: case MTSCREEN:
3547: case MTTPC:
3548: case MTTPC_B:
3549: sync = wacom_tpc_irq(wacom_wac, len);
3550: break;
3551:
3552: case BAMBOO_PT:
3553: case BAMBOO_PEN:
3554: case BAMBOO_TOUCH:
3555: case INTUOSHT:
3556: case INTUOSHT2:
3557: if (wacom_wac->data[0] == WACOM_REPORT_USB)
3558: sync = wacom_status_irq(wacom_wac, len);
3559: else
]
|
| 137/4 |
2026/09/21 01:08 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 59213
output: 39
thoughts: 1435
Thoughts: **Deep Dive into Potential Wacom Driver Issues**
Okay, let's break this down. My initial thought process is centered around troubleshooting a potential issue, likely a NULL pointer dereference, within the Wacom driver. I'm presented with a scenario where I need to understand why the `pen_input` might be NULL in a raw event handler.
First, I examine the interrupt handling logic (specifically the cases for various Wacom device types like `BAMBOO_PT`, `INTUOSHT`). I see the `wacom_bpt_irq()` function, and within it, the conditional check for `INTUOSHT2` devices with pen capabilities that leads to `wacom_intuos_irq()`. This suggests the path of the execution, from the interrupt handler.
Then, I'm going through the questions about the `pen_input` pointer being NULL. The first hypothesis is, "could `wacom_setup_pen_input_capabilities()` return an error for another reason?" I methodically check the code, specifically line 3806, where the function returns `-ENODEV` if `!(features->device_type & WACOM_DEVICETYPE_PEN)`. This clarifies that this function *only* returns an error if a pen isn't present, which is expected.
Next, I delve into the more complex question: "Or could `wacom->pen_input` be freed/set to NULL somewhere else after `wacom_setup_inputs()`?" This is where the detective work begins. I track down *all* write operations to `wacom_wac->pen_input`, noting that it's initialized in `wacom_allocate_inputs()`, potentially set in `wacom_setup_inputs()` with `wacom_setup_pen_input_capabilities()`, and possibly modified in `wacom_register_inputs()`.
The key here is `wacom_register_inputs()`. I see that if the registration of either touch or pad input devices fails, the driver sets `wacom_wac->pen_input = NULL` *and* returns an error. My expert intuition kicks in: a registration failure of one input device could lead to a NULL `pen_input`. This prompts the crucial question: Does the probe continue to receive events after failure? I need to know the control flow to identify where the events come in, to understand the failure conditions.
I then check where `wacom_register_inputs()` is called: in `wacom_parse_and_register()`. The implication is if `wacom_register_inputs()` fails, the probe fails. This is good to know, but doesn't solve the problem, yet. I also see that `wacom_release_resources()` *also* sets the pen input to NULL.
Now, my mind shifts to timing: can an interrupt (or a raw event) be received after `wacom_release_resources()` is called? Could there be a race condition where the probe fails after an input device has sent data? Or even an allocation failure *before* the setup phase?
I then re-examine the `wacom_setup_inputs()` function. This function returns an error if any input device is NULL. The check suggests a NULL input before it's set. This prompts me to consider scenarios related to `hid_hw_start` since events are tied to hardware initialisation. I realize I need to check the exact order of calls, especially regarding `hid_hw_start` calls, to correlate initialisation, events, and potential failures. This requires going back to the beginning of the `wacom_parse_and_register()` function.
|
| 138/4 |
2026/09/21 01:08 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2370 LineCount:80]
Results: map[Contents:2370: static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
2371: {
2372: struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2373: struct wacom_features *features = &wacom_wac->features;
2374: struct hid_device *hdev = wacom->hdev;
2375: int error;
2376: unsigned int connect_mask = HID_CONNECT_HIDRAW;
2377:
2378: features->pktlen = wacom_compute_pktlen(hdev);
2379: if (!features->pktlen)
2380: return -ENODEV;
2381:
2382: if (!devres_open_group(&hdev->dev, wacom, GFP_KERNEL))
2383: return -ENOMEM;
2384:
2385: error = wacom_devm_kfifo_alloc(wacom);
2386: if (error)
2387: goto fail;
2388:
2389: wacom->resources = true;
2390:
2391: error = wacom_allocate_inputs(wacom);
2392: if (error)
2393: goto fail;
2394:
2395: /*
2396: * Bamboo Pad has a generic hid handling for the Pen, and we switch it
2397: * into debug mode for the touch part.
2398: * We ignore the other interfaces.
2399: */
2400: if (features->type == BAMBOO_PAD) {
2401: if (features->pktlen == WACOM_PKGLEN_PENABLED) {
2402: features->type = HID_GENERIC;
2403: } else if ((features->pktlen != WACOM_PKGLEN_BPAD_TOUCH) &&
2404: (features->pktlen != WACOM_PKGLEN_BPAD_TOUCH_USB)) {
2405: error = -ENODEV;
2406: goto fail;
2407: }
2408: }
2409:
2410: /* set the default size in case we do not get them from hid */
2411: wacom_set_default_phy(features);
2412:
2413: /* Retrieve the physical and logical size for touch devices */
2414: wacom_retrieve_hid_descriptor(hdev, features);
2415: wacom_setup_device_quirks(wacom);
2416:
2417: if (features->device_type == WACOM_DEVICETYPE_NONE &&
2418: features->type != WIRELESS) {
2419: error = features->type == HID_GENERIC ? -ENODEV : 0;
2420:
2421: dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.",
2422: hdev->name,
2423: error ? "Ignoring" : "Assuming pen");
2424:
2425: if (error)
2426: goto fail;
2427:
2428: features->device_type |= WACOM_DEVICETYPE_PEN;
2429: }
2430:
2431: wacom_calculate_res(features);
2432:
2433: wacom_update_name(wacom, wireless ? " (WL)" : "");
2434:
2435: /* pen only Bamboo neither support touch nor pad */
2436: if ((features->type == BAMBOO_PEN) &&
2437: ((features->device_type & WACOM_DEVICETYPE_TOUCH) ||
2438: (features->device_type & WACOM_DEVICETYPE_PAD))) {
2439: error = -ENODEV;
2440: goto fail;
2441: }
2442:
2443: error = wacom_add_shared_data(hdev);
2444: if (error)
2445: goto fail;
2446:
2447: error = wacom_setup_inputs(wacom);
2448: if (error)
2449: goto fail;
]
|
| 139/4 |
2026/09/21 01:08 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 62683
output: 32
thoughts: 35
Thoughts: **Tracing the Execution Path**
Okay, hold on a second. I need to understand the control flow here. Specifically, I'm trying to pinpoint where the function `wacom_parse_and_register` is being invoked. That's the key to understanding how this particular subsystem is initialized and integrated. My immediate next step is to perform a thorough check. I'll need to meticulously examine all instances in the codebase where `wacom_parse_and_register` is called. That should give me the complete picture I'm looking for.
|
| 140/4 |
2026/09/21 01:08 |
tool |
codesearch-find-references |
0m
Args: map[IncludeSnippetLines:5 Name:wacom_parse_and_register]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:wacom_mode_change_work SourceFile:drivers/hid/wacom_sys.c SourceLine:2808 SourceSnippet:2803: wacom2->wacom_wac.has_mode_change = true;
2804: wacom2->wacom_wac.is_direct_mode = is_direct;
2805: }
2806:
2807: if (wacom1) {
2808: error = wacom_parse_and_register(wacom1, false);
2809: if (error)
2810: return;
2811: }
2812:
2813: if (wacom2) {
] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:wacom_mode_change_work SourceFile:drivers/hid/wacom_sys.c SourceLine:2814 SourceSnippet:2809: if (error)
2810: return;
2811: }
2812:
2813: if (wacom2) {
2814: error = wacom_parse_and_register(wacom2, false);
2815: if (error)
2816: return;
2817: }
2818:
2819: return;
] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:wacom_probe SourceFile:drivers/hid/wacom_sys.c SourceLine:2885 SourceSnippet:2880: if (features->type == BOOTLOADER) {
2881: hid_warn(hdev, "Using device in hidraw-only mode");
2882: return hid_hw_start(hdev, HID_CONNECT_HIDRAW);
2883: }
2884:
2885: error = wacom_parse_and_register(wacom, false);
2886: if (error)
2887: return error;
2888:
2889: if (hdev->bus == BUS_BLUETOOTH) {
2890: error = device_create_file(&hdev->dev, &dev_attr_speed);
] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:wacom_wireless_work SourceFile:drivers/hid/wacom_sys.c SourceLine:2567 SourceSnippet:2562: wacom_wac1->features =
2563: *((struct wacom_features *)id->driver_data);
2564:
2565: wacom_wac1->pid = wacom_wac->pid;
2566: hid_hw_stop(hdev1);
2567: error = wacom_parse_and_register(wacom1, true);
2568: if (error)
2569: goto fail;
2570:
2571: /* Touch interface */
2572: if (wacom_wac1->features.touch_max ||
] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:wacom_wireless_work SourceFile:drivers/hid/wacom_sys.c SourceLine:2579 SourceSnippet:2574: wacom_wac1->features.type <= BAMBOO_PT)) {
2575: wacom_wac2->features =
2576: *((struct wacom_features *)id->driver_data);
2577: wacom_wac2->pid = wacom_wac->pid;
2578: hid_hw_stop(hdev2);
2579: error = wacom_parse_and_register(wacom2, true);
2580: if (error)
2581: goto fail;
2582: }
2583:
2584: if (strscpy(wacom_wac->name, wacom_wac1->name,
]] TruncatedOutput:false]
|
| 141/4 |
2026/09/21 01:08 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 64002
output: 26
thoughts: 971
Thoughts: **Analyzing the Call Paths to `wacom_intuos_irq()` and Potential Null Pointer Dereference**
Okay, let's break this down systematically. My objective is to understand how `wacom_intuos_irq()` is called and, crucially, to identify potential scenarios that could lead to a null pointer dereference on `wacom->pen_input`. The prompt specifically highlights a conditional call within `wacom_bpt_irq()` that seems concerning.
First, I need to map out every location where `wacom_intuos_irq()` is invoked. The initial grep revealed three instances: within `wacom_intuos_bt_process_data()` (indirectly through `wacom_intuos_bt_irq()`), directly in `wacom_bpt_irq()`, and multiple times inside `wacom_wac_irq()`.
The critical point raised is that `wacom_intuos_irq()` is called from `wacom_bpt_irq()` under these conditions: `features->type == INTUOSHT2` and `features->device_type & WACOM_DEVICETYPE_PEN`. This is immediately concerning because `wacom->pen_input` is dereferenced in `wacom_intuos_irq()`. `wacom->pen_input` *can* be set to `NULL` if `wacom_setup_pen_input_capabilities()` returns an error, which happens if `!(features->device_type & WACOM_DEVICETYPE_PEN)`. However, the conditional check within `wacom_bpt_irq()` for `WACOM_DEVICETYPE_PEN` *should* prevent this, at least in theory.
This necessitates more rigorous investigation. My next step is to methodically investigate potential causes for the null pointer. It appears I need to investigate a series of questions:
1. **Are there other ways** `wacom_setup_pen_input_capabilities()` could return an error besides `!(features->device_type & WACOM_DEVICETYPE_PEN)`? I need to check the function's implementation thoroughly for other error conditions.
2. **Is there a possibility that** `wacom->pen_input` is freed or set to `NULL` *after* `wacom_setup_inputs()` is completed? I will need to search the code for any instances where this happens and determine the conditions under which it could occur.
3. **Could** `features->device_type` be modified *after* `wacom_setup_inputs()`? This seems unlikely, but I have to rule it out. If `features->device_type` were changed *after* initialization, it could lead to unexpected behavior. To check this, I will need to search the source for all writes to `device_type`.
4. **Is it possible that** `wacom_bpt_irq()` is called *before* `wacom_setup_inputs()` has fully completed? This would be a race condition, and it's a critical point to consider. I will need to understand the device initialization sequence.
I'll start by checking all writes to `device_type` within the relevant directory.
|
| 142/4 |
2026/09/21 01:08 |
tool |
grepper |
0m
Args: map[Expression:device_type PathPrefix:drivers/hid]
Results: map[Output:
Full output is too long, showing 500 out of 580 lines.
Use more precise expression if possible.
drivers/hid/hid-lenovo-go.c=99=struct command_report {
--
drivers/hid/hid-lenovo-go.c-103- u8 sub_cmd;
drivers/hid/hid-lenovo-go.c:104: u8 device_type;
drivers/hid/hid-lenovo-go.c-105- u8 data[59];
--
drivers/hid/hid-lenovo-go.c=230=static const char *const rumble_mode_text[] = {
--
drivers/hid/hid-lenovo-go.c-243-
drivers/hid/hid-lenovo-go.c:244:enum cal_device_type {
drivers/hid/hid-lenovo-go.c-245- CALDEV_GYROSCOPE = 0x01,
--
drivers/hid/hid-lenovo-go.c=334=static int hid_go_version_event(struct command_report *cmd_rep)
--
drivers/hid/hid-lenovo-go.c-337- case PRODUCT_VERSION:
drivers/hid/hid-lenovo-go.c:338: switch (cmd_rep->device_type) {
drivers/hid/hid-lenovo-go.c-339- case USB_MCU:
--
drivers/hid/hid-lenovo-go.c-358- case PROTOCOL_VERSION:
drivers/hid/hid-lenovo-go.c:359: switch (cmd_rep->device_type) {
drivers/hid/hid-lenovo-go.c-360- case USB_MCU:
--
drivers/hid/hid-lenovo-go.c-379- case FIRMWARE_VERSION:
drivers/hid/hid-lenovo-go.c:380: switch (cmd_rep->device_type) {
drivers/hid/hid-lenovo-go.c-381- case USB_MCU:
--
drivers/hid/hid-lenovo-go.c-400- case HARDWARE_VERSION:
drivers/hid/hid-lenovo-go.c:401: switch (cmd_rep->device_type) {
drivers/hid/hid-lenovo-go.c-402- case USB_MCU:
--
drivers/hid/hid-lenovo-go.c-421- case HARDWARE_GENERATION:
drivers/hid/hid-lenovo-go.c:422: switch (cmd_rep->device_type) {
drivers/hid/hid-lenovo-go.c-423- case USB_MCU:
--
drivers/hid/hid-lenovo-go.c=443=static int hid_go_feature_status_event(struct command_report *cmd_rep)
--
drivers/hid/hid-lenovo-go.c-448- case FEATURE_IMU_ENABLE:
drivers/hid/hid-lenovo-go.c:449: switch (cmd_rep->device_type) {
drivers/hid/hid-lenovo-go.c-450- case LEFT_CONTROLLER:
--
drivers/hid/hid-lenovo-go.c-459- case FEATURE_IMU_BYPASS:
drivers/hid/hid-lenovo-go.c:460: switch (cmd_rep->device_type) {
drivers/hid/hid-lenovo-go.c-461- case LEFT_CONTROLLER:
--
drivers/hid/hid-lenovo-go.c-474- case FEATURE_AUTO_SLEEP_TIME:
drivers/hid/hid-lenovo-go.c:475: switch (cmd_rep->device_type) {
drivers/hid/hid-lenovo-go.c-476- case LEFT_CONTROLLER:
--
drivers/hid/hid-lenovo-go.c=500=static int hid_go_motor_event(struct command_report *cmd_rep)
--
drivers/hid/hid-lenovo-go.c-508- case VIBRATION_NOTIFY_ENABLE:
drivers/hid/hid-lenovo-go.c:509: switch (cmd_rep->device_type) {
drivers/hid/hid-lenovo-go.c-510- case LEFT_CONTROLLER:
--
drivers/hid/hid-lenovo-go.c-520- case RUMBLE_MODE:
drivers/hid/hid-lenovo-go.c:521: switch (cmd_rep->device_type) {
drivers/hid/hid-lenovo-go.c-522- case LEFT_CONTROLLER:
--
drivers/hid/hid-lenovo-go.c=578=static int hid_go_device_status_event(struct command_report *cmd_rep)
drivers/hid/hid-lenovo-go.c-579-{
drivers/hid/hid-lenovo-go.c:580: switch (cmd_rep->device_type) {
drivers/hid/hid-lenovo-go.c-581- case LEFT_CONTROLLER:
--
drivers/hid/hid-lenovo-go.c=761=static ssize_t version_show(struct device *dev, struct device_attribute *attr,
drivers/hid/hid-lenovo-go.c-762- char *buf, enum version_data_index index,
drivers/hid/hid-lenovo-go.c:763: enum dev_type device_type)
drivers/hid/hid-lenovo-go.c-764-{
--
drivers/hid/hid-lenovo-go.c-768- ret = mcu_property_out(drvdata.hdev, MCU_CONFIG_DATA, GET_VERSION_DATA,
drivers/hid/hid-lenovo-go.c:769: index, device_type, NULL, 0);
drivers/hid/hid-lenovo-go.c-770- if (ret)
--
drivers/hid/hid-lenovo-go.c-774- case PRODUCT_VERSION:
drivers/hid/hid-lenovo-go.c:775: switch (device_type) {
drivers/hid/hid-lenovo-go.c-776- case USB_MCU:
--
drivers/hid/hid-lenovo-go.c-796- case PROTOCOL_VERSION:
drivers/hid/hid-lenovo-go.c:797: switch (device_type) {
drivers/hid/hid-lenovo-go.c-798- case USB_MCU:
--
drivers/hid/hid-lenovo-go.c-818- case FIRMWARE_VERSION:
drivers/hid/hid-lenovo-go.c:819: switch (device_type) {
drivers/hid/hid-lenovo-go.c-820- case USB_MCU:
--
drivers/hid/hid-lenovo-go.c-840- case HARDWARE_VERSION:
drivers/hid/hid-lenovo-go.c:841: switch (device_type) {
drivers/hid/hid-lenovo-go.c-842- case USB_MCU:
--
drivers/hid/hid-lenovo-go.c-862- case HARDWARE_GENERATION:
drivers/hid/hid-lenovo-go.c:863: switch (device_type) {
drivers/hid/hid-lenovo-go.c-864- case USB_MCU:
--
drivers/hid/hid-lenovo-go.c=889=static ssize_t feature_status_store(struct device *dev,
--
drivers/hid/hid-lenovo-go.c-892- enum feature_status_index index,
drivers/hid/hid-lenovo-go.c:893: enum dev_type device_type)
drivers/hid/hid-lenovo-go.c-894-{
--
drivers/hid/hid-lenovo-go.c-933- ret = mcu_property_out(drvdata.hdev, MCU_CONFIG_DATA,
drivers/hid/hid-lenovo-go.c:934: SET_FEATURE_STATUS, index, device_type, &val,
drivers/hid/hid-lenovo-go.c-935- size);
--
drivers/hid/hid-lenovo-go.c=942=static ssize_t feature_status_show(struct device *dev,
--
drivers/hid/hid-lenovo-go.c-944- enum feature_status_index index,
drivers/hid/hid-lenovo-go.c:945: enum dev_type device_type)
drivers/hid/hid-lenovo-go.c-946-{
--
drivers/hid/hid-lenovo-go.c-951- ret = mcu_property_out(drvdata.hdev, MCU_CONFIG_DATA,
drivers/hid/hid-lenovo-go.c:952: GET_FEATURE_STATUS, index, device_type, NULL, 0);
drivers/hid/hid-lenovo-go.c-953- if (ret)
--
drivers/hid/hid-lenovo-go.c-957- case FEATURE_IMU_ENABLE:
drivers/hid/hid-lenovo-go.c:958: switch (device_type) {
drivers/hid/hid-lenovo-go.c-959- case LEFT_CONTROLLER:
--
drivers/hid/hid-lenovo-go.c-973- case FEATURE_IMU_BYPASS:
drivers/hid/hid-lenovo-go.c:974: switch (device_type) {
drivers/hid/hid-lenovo-go.c-975- case LEFT_CONTROLLER:
--
drivers/hid/hid-lenovo-go.c-1003- case FEATURE_AUTO_SLEEP_TIME:
drivers/hid/hid-lenovo-go.c:1004: switch (device_type) {
drivers/hid/hid-lenovo-go.c-1005- case LEFT_CONTROLLER:
--
drivers/hid/hid-lenovo-go.c=1078=static ssize_t motor_config_store(struct device *dev,
--
drivers/hid/hid-lenovo-go.c-1081- enum motor_cfg_index index,
drivers/hid/hid-lenovo-go.c:1082: enum dev_type device_type)
drivers/hid/hid-lenovo-go.c-1083-{
--
drivers/hid/hid-lenovo-go.c-1119- ret = mcu_property_out(drvdata.hdev, MCU_CONFIG_DATA, SET_MOTOR_CFG,
drivers/hid/hid-lenovo-go.c:1120: index, device_type, &val, size);
drivers/hid/hid-lenovo-go.c-1121- if (ret < 0)
--
drivers/hid/hid-lenovo-go.c=1127=static ssize_t motor_config_show(struct device *dev,
--
drivers/hid/hid-lenovo-go.c-1129- enum motor_cfg_index index,
drivers/hid/hid-lenovo-go.c:1130: enum dev_type device_type)
drivers/hid/hid-lenovo-go.c-1131-{
--
drivers/hid/hid-lenovo-go.c-1136- ret = mcu_property_out(drvdata.hdev, MCU_CONFIG_DATA, GET_MOTOR_CFG,
drivers/hid/hid-lenovo-go.c:1137: index, device_type, NULL, 0);
drivers/hid/hid-lenovo-go.c-1138- if (ret)
--
drivers/hid/hid-lenovo-go.c-1151- case VIBRATION_NOTIFY_ENABLE:
drivers/hid/hid-lenovo-go.c:1152: switch (device_type) {
drivers/hid/hid-lenovo-go.c-1153- case LEFT_CONTROLLER:
--
drivers/hid/hid-lenovo-go.c-1167- case RUMBLE_MODE:
drivers/hid/hid-lenovo-go.c:1168: switch (device_type) {
drivers/hid/hid-lenovo-go.c-1169- case LEFT_CONTROLLER:
--
drivers/hid/hid-lenovo-go.c=1286=static ssize_t device_status_show(struct device *dev,
--
drivers/hid/hid-lenovo-go.c-1288- enum device_status_index index,
drivers/hid/hid-lenovo-go.c:1289: enum dev_type device_type,
drivers/hid/hid-lenovo-go.c:1290: enum cal_device_type cal_type)
drivers/hid/hid-lenovo-go.c-1291-{
--
drivers/hid/hid-lenovo-go.c-1295- case GET_CAL_STATUS:
drivers/hid/hid-lenovo-go.c:1296: switch (device_type) {
drivers/hid/hid-lenovo-go.c-1297- case LEFT_CONTROLLER:
--
drivers/hid/hid-lenovo-go.c=1341=static ssize_t calibrate_config_store(struct device *dev,
--
drivers/hid/hid-lenovo-go.c-1343- const char *buf, u8 cmd, u8 sub_cmd,
drivers/hid/hid-lenovo-go.c:1344: size_t count, enum dev_type device_type)
drivers/hid/hid-lenovo-go.c-1345-{
--
drivers/hid/hid-lenovo-go.c-1358- ret = mcu_property_out(drvdata.hdev, MCU_CONFIG_DATA, cmd, sub_cmd,
drivers/hid/hid-lenovo-go.c:1359: device_type, &val, size);
drivers/hid/hid-lenovo-go.c-1360- if (ret < 0)
--
drivers/hid/hid-logitech-dj.c=171=struct dj_workitem {
--
drivers/hid/hid-logitech-dj.c-173- u8 device_index;
drivers/hid/hid-logitech-dj.c:174: u8 device_type;
drivers/hid/hid-logitech-dj.c-175- u8 quad_id_msb;
--
drivers/hid/hid-logitech-dj.c=790=static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
--
drivers/hid/hid-logitech-dj.c-824- workitem->quad_id_lsb;
drivers/hid/hid-logitech-dj.c:825: if (workitem->device_type) {
drivers/hid/hid-logitech-dj.c-826- const char *type_str = "Device";
drivers/hid/hid-logitech-dj.c-827-
drivers/hid/hid-logitech-dj.c:828: switch (workitem->device_type) {
drivers/hid/hid-logitech-dj.c-829- case 0x01: type_str = "Keyboard"; break;
--
drivers/hid/hid-logitech-dj.c=967=static void logi_dj_recv_queue_notification(struct dj_receiver_dev *djrcv_dev,
--
drivers/hid/hid-logitech-dj.c-1006- * Some quad/bluetooth keyboards have a builtin touchpad in this case we see
drivers/hid/hid-logitech-dj.c:1007: * only 1 paired device with a device_type of REPORT_TYPE_KEYBOARD. For the
drivers/hid/hid-logitech-dj.c-1008- * touchpad to work we must also forward mouse input reports to the dj_hiddev
drivers/hid/hid-logitech-dj.c-1009- * created for the keyboard (instead of forwarding them to a second paired
drivers/hid/hid-logitech-dj.c:1010: * device with a device_type of REPORT_TYPE_MOUSE as we normally would).
drivers/hid/hid-logitech-dj.c-1011- *
--
drivers/hid/hid-logitech-dj.c=1025=static void logi_hidpp_dev_conn_notif_equad(struct hid_device *hdev,
--
drivers/hid/hid-logitech-dj.c-1032- workitem->type = WORKITEM_TYPE_PAIRED;
drivers/hid/hid-logitech-dj.c:1033: workitem->device_type = hidpp_report->params[HIDPP_PARAM_DEVICE_INFO] &
drivers/hid/hid-logitech-dj.c-1034- HIDPP_DEVICE_TYPE_MASK;
--
drivers/hid/hid-logitech-dj.c-1036- workitem->quad_id_lsb = hidpp_report->params[HIDPP_PARAM_EQUAD_LSB];
drivers/hid/hid-logitech-dj.c:1037: switch (workitem->device_type) {
drivers/hid/hid-logitech-dj.c-1038- case REPORT_TYPE_KEYBOARD:
--
drivers/hid/hid-logitech-dj.c=1059=static void logi_hidpp_dev_conn_notif_27mhz(struct hid_device *hdev,
--
drivers/hid/hid-logitech-dj.c-1067- case 2: /* Index 2 is always a mouse */
drivers/hid/hid-logitech-dj.c:1068: workitem->device_type = HIDPP_DEVICE_TYPE_MOUSE;
drivers/hid/hid-logitech-dj.c-1069- workitem->reports_supported |= STD_MOUSE | HIDPP;
--
drivers/hid/hid-logitech-dj.c-1079- case 4: /* Index 4 is used for an optional separate numpad */
drivers/hid/hid-logitech-dj.c:1080: workitem->device_type = HIDPP_DEVICE_TYPE_KEYBOARD;
drivers/hid/hid-logitech-dj.c-1081- workitem->reports_supported |= STD_KEYBOARD | MULTIMEDIA |
--
drivers/hid/hid-logitech-dj.c=1090=static void logi_hidpp_recv_queue_notif(struct hid_device *hdev,
--
drivers/hid/hid-logitech-dj.c-1094- struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
drivers/hid/hid-logitech-dj.c:1095: const char *device_type = "UNKNOWN";
drivers/hid/hid-logitech-dj.c-1096- struct dj_workitem workitem = {
--
drivers/hid/hid-logitech-dj.c-1102- case 0x01:
drivers/hid/hid-logitech-dj.c:1103: device_type = "Bluetooth";
drivers/hid/hid-logitech-dj.c-1104- /* Bluetooth connect packet contents is the same as (e)QUAD */
--
drivers/hid/hid-logitech-dj.c-1113- case 0x02:
drivers/hid/hid-logitech-dj.c:1114: device_type = "27 Mhz";
drivers/hid/hid-logitech-dj.c-1115- logi_hidpp_dev_conn_notif_27mhz(hdev, hidpp_report, &workitem);
--
drivers/hid/hid-logitech-dj.c-1117- case 0x03:
drivers/hid/hid-logitech-dj.c:1118: device_type = "QUAD or eQUAD";
drivers/hid/hid-logitech-dj.c-1119- logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
--
drivers/hid/hid-logitech-dj.c-1121- case 0x04:
drivers/hid/hid-logitech-dj.c:1122: device_type = "eQUAD step 4 DJ";
drivers/hid/hid-logitech-dj.c-1123- logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
--
drivers/hid/hid-logitech-dj.c-1125- case 0x05:
drivers/hid/hid-logitech-dj.c:1126: device_type = "DFU Lite";
drivers/hid/hid-logitech-dj.c-1127- break;
drivers/hid/hid-logitech-dj.c-1128- case 0x06:
drivers/hid/hid-logitech-dj.c:1129: device_type = "eQUAD step 4 Lite";
drivers/hid/hid-logitech-dj.c-1130- logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
--
drivers/hid/hid-logitech-dj.c-1132- case 0x07:
drivers/hid/hid-logitech-dj.c:1133: device_type = "eQUAD step 4 Gaming";
drivers/hid/hid-logitech-dj.c-1134- logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
--
drivers/hid/hid-logitech-dj.c-1137- case 0x08:
drivers/hid/hid-logitech-dj.c:1138: device_type = "eQUAD step 4 for gamepads";
drivers/hid/hid-logitech-dj.c-1139- break;
drivers/hid/hid-logitech-dj.c-1140- case 0x0a:
drivers/hid/hid-logitech-dj.c:1141: device_type = "eQUAD nano Lite";
drivers/hid/hid-logitech-dj.c-1142- logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
--
drivers/hid/hid-logitech-dj.c-1144- case 0x0c:
drivers/hid/hid-logitech-dj.c:1145: device_type = "eQUAD Lightspeed 1";
drivers/hid/hid-logitech-dj.c-1146- logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
--
drivers/hid/hid-logitech-dj.c-1149- case 0x0d:
drivers/hid/hid-logitech-dj.c:1150: device_type = "eQUAD Lightspeed 1.1";
drivers/hid/hid-logitech-dj.c-1151- logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
--
drivers/hid/hid-logitech-dj.c-1155- case 0x11:
drivers/hid/hid-logitech-dj.c:1156: device_type = "eQUAD Lightspeed 1.2";
drivers/hid/hid-logitech-dj.c-1157- logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
--
drivers/hid/hid-logitech-dj.c-1160- case 0x10:
drivers/hid/hid-logitech-dj.c:1161: device_type = "Bolt";
drivers/hid/hid-logitech-dj.c-1162- logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
--
drivers/hid/hid-logitech-dj.c-1173- "unusable device of type %s (0x%02x) connected on slot %d",
drivers/hid/hid-logitech-dj.c:1174: device_type,
drivers/hid/hid-logitech-dj.c-1175- hidpp_report->params[HIDPP_PARAM_PROTO_TYPE],
--
drivers/hid/hid-logitech-dj.c-1180- hid_info(hdev, "device of type %s (0x%02x) connected on slot %d",
drivers/hid/hid-logitech-dj.c:1181: device_type, hidpp_report->params[HIDPP_PARAM_PROTO_TYPE],
drivers/hid/hid-logitech-dj.c-1182- hidpp_report->device_index);
--
drivers/hid/hid-plantronics.c=40=struct plt_drv_data {
drivers/hid/hid-plantronics.c:41: unsigned long device_type;
drivers/hid/hid-plantronics.c-42- unsigned long last_key_ts;
--
drivers/hid/hid-plantronics.c=47=static int plantronics_input_mapping(struct hid_device *hdev,
--
drivers/hid/hid-plantronics.c-54- struct plt_drv_data *drv_data = hid_get_drvdata(hdev);
drivers/hid/hid-plantronics.c:55: unsigned long plt_type = drv_data->device_type;
drivers/hid/hid-plantronics.c-56- int allow_mute = usage->hid == HID_TELEPHONY_MUTE;
--
drivers/hid/hid-plantronics.c=131=static int plantronics_event(struct hid_device *hdev, struct hid_field *field,
--
drivers/hid/hid-plantronics.c-157-
drivers/hid/hid-plantronics.c:158:static unsigned long plantronics_device_type(struct hid_device *hdev)
drivers/hid/hid-plantronics.c-159-{
--
drivers/hid/hid-plantronics.c=183=static int plantronics_probe(struct hid_device *hdev,
--
drivers/hid/hid-plantronics.c-198-
drivers/hid/hid-plantronics.c:199: drv_data->device_type = plantronics_device_type(hdev);
drivers/hid/hid-plantronics.c-200- drv_data->double_key_to = msecs_to_jiffies(PLT_DOUBLE_KEY_TIMEOUT);
--
drivers/hid/intel-ish-hid/ishtp/bus.c=399=static void ishtp_cl_dev_release(struct device *dev)
--
drivers/hid/intel-ish-hid/ishtp/bus.c-403-
drivers/hid/intel-ish-hid/ishtp/bus.c:404:static const struct device_type ishtp_cl_device_type = {
drivers/hid/intel-ish-hid/ishtp/bus.c-405- .release = ishtp_cl_dev_release,
--
drivers/hid/intel-ish-hid/ishtp/bus.c=419=static struct ishtp_cl_device *ishtp_bus_add_device(struct ishtp_device *dev,
--
drivers/hid/intel-ish-hid/ishtp/bus.c-443- device->dev.bus = &ishtp_cl_bus_type;
drivers/hid/intel-ish-hid/ishtp/bus.c:444: device->dev.type = &ishtp_cl_device_type;
drivers/hid/intel-ish-hid/ishtp/bus.c-445- device->ishtp_dev = dev;
--
drivers/hid/wacom_sys.c=439=static void wacom_usage_mapping(struct hid_device *hdev,
--
drivers/hid/wacom_sys.c-453- if (pen)
drivers/hid/wacom_sys.c:454: features->device_type |= WACOM_DEVICETYPE_PEN;
drivers/hid/wacom_sys.c-455- else if (finger)
drivers/hid/wacom_sys.c:456: features->device_type |= WACOM_DEVICETYPE_TOUCH;
drivers/hid/wacom_sys.c-457- else
--
drivers/hid/wacom_sys.c=495=static void wacom_post_parse_hid(struct hid_device *hdev,
--
drivers/hid/wacom_sys.c-504- if (wacom_wac->is_direct_mode)
drivers/hid/wacom_sys.c:505: features->device_type |= WACOM_DEVICETYPE_DIRECT;
drivers/hid/wacom_sys.c-506- else
drivers/hid/wacom_sys.c:507: features->device_type &= ~WACOM_DEVICETYPE_DIRECT;
drivers/hid/wacom_sys.c-508- }
--
drivers/hid/wacom_sys.c-510- if (features->touch_max > 1) {
drivers/hid/wacom_sys.c:511: if (features->device_type & WACOM_DEVICETYPE_DIRECT)
drivers/hid/wacom_sys.c-512- input_mt_init_slots(wacom_wac->touch_input,
--
drivers/hid/wacom_sys.c=686=static int _wacom_query_tablet_data(struct wacom *wacom)
--
drivers/hid/wacom_sys.c-695- if (features->type != HID_GENERIC) {
drivers/hid/wacom_sys.c:696: if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
drivers/hid/wacom_sys.c-697- if (features->type > TABLETPC) {
--
drivers/hid/wacom_sys.c-710- }
drivers/hid/wacom_sys.c:711: } else if (features->device_type & WACOM_DEVICETYPE_PEN) {
drivers/hid/wacom_sys.c-712- if (features->type <= BAMBOO_PT) {
--
drivers/hid/wacom_sys.c=727=static void wacom_retrieve_hid_descriptor(struct hid_device *hdev,
--
drivers/hid/wacom_sys.c-747- if (intf->cur_altsetting->desc.bInterfaceNumber == 0)
drivers/hid/wacom_sys.c:748: features->device_type = WACOM_DEVICETYPE_WL_MONITOR;
drivers/hid/wacom_sys.c-749- else
drivers/hid/wacom_sys.c:750: features->device_type = WACOM_DEVICETYPE_NONE;
drivers/hid/wacom_sys.c-751- return;
--
drivers/hid/wacom_sys.c=767=static bool wacom_are_sibling(struct hid_device *hdev,
--
drivers/hid/wacom_sys.c-803- */
drivers/hid/wacom_sys.c:804: if ((features->device_type & WACOM_DEVICETYPE_DIRECT) &&
drivers/hid/wacom_sys.c:805: !(sibling_features->device_type & WACOM_DEVICETYPE_DIRECT))
drivers/hid/wacom_sys.c-806- return false;
--
drivers/hid/wacom_sys.c-811- */
drivers/hid/wacom_sys.c:812: if (!(features->device_type & WACOM_DEVICETYPE_DIRECT) &&
drivers/hid/wacom_sys.c:813: (sibling_features->device_type & WACOM_DEVICETYPE_DIRECT))
drivers/hid/wacom_sys.c-814- return false;
--
drivers/hid/wacom_sys.c-816- /* Pen devices may only be siblings of touch devices */
drivers/hid/wacom_sys.c:817: if ((features->device_type & WACOM_DEVICETYPE_PEN) &&
drivers/hid/wacom_sys.c:818: !(sibling_features->device_type & WACOM_DEVICETYPE_TOUCH))
drivers/hid/wacom_sys.c-819- return false;
--
drivers/hid/wacom_sys.c-821- /* Touch devices may only be siblings of pen devices */
drivers/hid/wacom_sys.c:822: if ((features->device_type & WACOM_DEVICETYPE_TOUCH) &&
drivers/hid/wacom_sys.c:823: !(sibling_features->device_type & WACOM_DEVICETYPE_PEN))
drivers/hid/wacom_sys.c-824- return false;
--
drivers/hid/wacom_sys.c=888=static int wacom_add_shared_data(struct hid_device *hdev)
--
drivers/hid/wacom_sys.c-917-
drivers/hid/wacom_sys.c:918: if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH)
drivers/hid/wacom_sys.c-919- wacom_wac->shared->touch = hdev;
drivers/hid/wacom_sys.c:920: else if (wacom_wac->features.device_type & WACOM_DEVICETYPE_PEN)
drivers/hid/wacom_sys.c-921- wacom_wac->shared->pen = hdev;
--
drivers/hid/wacom_sys.c=1607=int wacom_initialize_leds(struct wacom *wacom)
--
drivers/hid/wacom_sys.c-1610-
drivers/hid/wacom_sys.c:1611: if (!(wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD))
drivers/hid/wacom_sys.c-1612- return 0;
--
drivers/hid/wacom_sys.c=2344=static void wacom_set_shared_values(struct wacom_wac *wacom_wac)
drivers/hid/wacom_sys.c-2345-{
drivers/hid/wacom_sys.c:2346: if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) {
drivers/hid/wacom_sys.c-2347- wacom_wac->shared->type = wacom_wac->features.type;
--
drivers/hid/wacom_sys.c=2370=static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
--
drivers/hid/wacom_sys.c-2416-
drivers/hid/wacom_sys.c:2417: if (features->device_type == WACOM_DEVICETYPE_NONE &&
drivers/hid/wacom_sys.c-2418- features->type != WIRELESS) {
--
drivers/hid/wacom_sys.c-2420-
drivers/hid/wacom_sys.c:2421: dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.",
drivers/hid/wacom_sys.c-2422- hdev->name,
--
drivers/hid/wacom_sys.c-2427-
drivers/hid/wacom_sys.c:2428: features->device_type |= WACOM_DEVICETYPE_PEN;
drivers/hid/wacom_sys.c-2429- }
--
drivers/hid/wacom_sys.c-2436- if ((features->type == BAMBOO_PEN) &&
drivers/hid/wacom_sys.c:2437: ((features->device_type & WACOM_DEVICETYPE_TOUCH) ||
drivers/hid/wacom_sys.c:2438: (features->device_type & WACOM_DEVICETYPE_PAD))) {
drivers/hid/wacom_sys.c-2439- error = -ENODEV;
--
drivers/hid/wacom_sys.c-2464-
drivers/hid/wacom_sys.c:2465: if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) {
drivers/hid/wacom_sys.c-2466- error = wacom_initialize_leds(wacom);
--
drivers/hid/wacom_sys.c-2481- if ((features->type == BAMBOO_TOUCH) &&
drivers/hid/wacom_sys.c:2482: (features->device_type & WACOM_DEVICETYPE_PEN)) {
drivers/hid/wacom_sys.c-2483- cancel_delayed_work_sync(&wacom->init_work);
--
drivers/hid/wacom_sys.c-2488-
drivers/hid/wacom_sys.c:2489: if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) {
drivers/hid/wacom_sys.c-2490- error = hid_hw_open(hdev);
--
drivers/hid/wacom_sys.c=2901=static void wacom_remove(struct hid_device *hdev)
--
drivers/hid/wacom_sys.c-2906-
drivers/hid/wacom_sys.c:2907: if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR)
drivers/hid/wacom_sys.c-2908- hid_hw_close(hdev);
--
drivers/hid/wacom_wac.c=2014=static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
--
drivers/hid/wacom_wac.c-2026- wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0);
drivers/hid/wacom_wac.c:2027: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2028- break;
--
drivers/hid/wacom_wac.c-2031- wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0);
drivers/hid/wacom_wac.c:2032: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2033- break;
--
drivers/hid/wacom_wac.c-2036- wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
drivers/hid/wacom_wac.c:2037: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2038- break;
--
drivers/hid/wacom_wac.c-2048- features->numbered_buttons++;
drivers/hid/wacom_wac.c:2049: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2050- break;
--
drivers/hid/wacom_wac.c-2069- wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
drivers/hid/wacom_wac.c:2070: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2071- break;
--
drivers/hid/wacom_wac.c-2073- wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0);
drivers/hid/wacom_wac.c:2074: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2075- break;
--
drivers/hid/wacom_wac.c-2093- }
drivers/hid/wacom_wac.c:2094: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2095- break;
--
drivers/hid/wacom_wac.c-2103- set_bit(EV_ABS, input->evbit);
drivers/hid/wacom_wac.c:2104: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2105- break;
--
drivers/hid/wacom_wac.c-2107- wacom_map_usage(input, usage, field, EV_KEY, KEY_BUTTONCONFIG, 0);
drivers/hid/wacom_wac.c:2108: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2109- break;
--
drivers/hid/wacom_wac.c-2111- wacom_map_usage(input, usage, field, EV_KEY, KEY_ONSCREEN_KEYBOARD, 0);
drivers/hid/wacom_wac.c:2112: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2113- break;
--
drivers/hid/wacom_wac.c-2115- wacom_map_usage(input, usage, field, EV_KEY, KEY_CONTROLPANEL, 0);
drivers/hid/wacom_wac.c:2116: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2117- break;
--
drivers/hid/wacom_wac.c-2123- }
drivers/hid/wacom_wac.c:2124: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2125- break;
--
drivers/hid/wacom_wac.c-2133- features->numbered_buttons++;
drivers/hid/wacom_wac.c:2134: features->device_type |= WACOM_DEVICETYPE_PAD;
drivers/hid/wacom_wac.c-2135- break;
--
drivers/hid/wacom_wac.c=2929=void wacom_wac_usage_mapping(struct hid_device *hdev,
--
drivers/hid/wacom_wac.c-2936- if (WACOM_DIRECT_DEVICE(field))
drivers/hid/wacom_wac.c:2937: features->device_type |= WACOM_DEVICETYPE_DIRECT;
drivers/hid/wacom_wac.c-2938-
--
drivers/hid/wacom_wac.c=3284=static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
--
drivers/hid/wacom_wac.c-3288- if ((features->type == INTUOSHT2) &&
drivers/hid/wacom_wac.c:3289: (features->device_type & WACOM_DEVICETYPE_PEN))
drivers/hid/wacom_wac.c-3290- return wacom_intuos_irq(wacom);
--
drivers/hid/wacom_wac.c=3648=void wacom_setup_device_quirks(struct wacom *wacom)
--
drivers/hid/wacom_wac.c-3656- (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
]
|
| 143/4 |
2026/09/21 01:08 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 77163
output: 28
thoughts: 269
Thoughts: **My Analysis of Device Type Determination**
Okay, let's break down how this `device_type` flag gets set within `wacom_features`. From what I can see, the assignment is happening in a few key places. First, the `wacom_wac_usage_mapping` and `wacom_usage_mapping` functions are clearly responsible. Specifically, the bitwise OR operations are used to set the `WACOM_DEVICETYPE_PEN`, `WACOM_DEVICETYPE_TOUCH`, and `WACOM_DEVICETYPE_DIRECT` bits within the `device_type` field of the `features` structure. I'm assuming these functions are handling the initial parsing of usage reports to identify the device's basic input capabilities.
Then, there's `wacom_wac_pad_usage_mapping` which seems dedicated to handling pad devices, as its setting the `WACOM_DEVICETYPE_PAD` bit. Makes sense, given the function name.
Next, I see `wacom_retrieve_hid_descriptor` is involved. Now, this one's interesting, as it's specifically setting `features->device_type` to `WACOM_DEVICETYPE_WL_MONITOR` or `NONE`. So, if the device reports as a wireless monitor, it identifies it as such. Otherwise, it gets initialized to none.
The `wacom_parse_and_register` function comes into play. If, and only if, the `device_type` is currently `WACOM_DEVICETYPE_NONE`, this one defaults to setting the `WACOM_DEVICETYPE_PEN` bit. I'd assume that this functions as a default, catching any devices that haven't been explicitly categorized elsewhere. This is the fallback I would have expected to see.
Now, to get the full picture, I need to consult the `wacom_wac.h` header file. It's the definitive source for these `device_type` definitions. I also want to go searching for some device IDs, so I'm going to quickly grep through `drivers/hid/` looking for something like `INTUOSHT2` to get a feel for what the different device types actually map to. That will fill in the missing pieces here.
|
| 144/4 |
2026/09/21 01:08 |
tool |
grepper |
0m
Args: map[Expression:INTUOSHT2 PathPrefix:drivers/hid]
Results: map[Output:drivers/hid/wacom_wac.c=496=static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
--
drivers/hid/wacom_wac.c-503- re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
drivers/hid/wacom_wac.c:504: if (features->type == INTUOSHT2)
drivers/hid/wacom_wac.c:505: r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID];
drivers/hid/wacom_wac.c-506- else
--
drivers/hid/wacom_wac.c=773=static int wacom_intuos_inout(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-802- if ((data[1] & 0xfe) == 0x20) {
drivers/hid/wacom_wac.c:803: if (features->type != INTUOSHT2)
drivers/hid/wacom_wac.c-804- wacom->shared->stylus_in_proximity = true;
--
drivers/hid/wacom_wac.c=849=static int wacom_intuos_general(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-899- }
drivers/hid/wacom_wac.c:900: if (features->type == INTUOSHT2)
drivers/hid/wacom_wac.c-901- distance = features->distance_max - distance;
--
drivers/hid/wacom_wac.c-915- input_report_abs(input, ABS_PRESSURE, t);
drivers/hid/wacom_wac.c:916: if (features->type != INTUOSHT2) {
drivers/hid/wacom_wac.c-917- input_report_abs(input, ABS_TILT_X,
--
drivers/hid/wacom_wac.c=3119=static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
--
drivers/hid/wacom_wac.c-3138-
drivers/hid/wacom_wac.c:3139: if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
drivers/hid/wacom_wac.c-3140- width = data[5] * 100;
--
drivers/hid/wacom_wac.c=3162=static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
--
drivers/hid/wacom_wac.c-3166-
drivers/hid/wacom_wac.c:3167: if (features->type == INTUOSHT || features->type == INTUOSHT2) {
drivers/hid/wacom_wac.c-3168- input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
--
drivers/hid/wacom_wac.c=3284=static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
--
drivers/hid/wacom_wac.c-3287-
drivers/hid/wacom_wac.c:3288: if ((features->type == INTUOSHT2) &&
drivers/hid/wacom_wac.c-3289- (features->device_type & WACOM_DEVICETYPE_PEN))
--
drivers/hid/wacom_wac.c=3385=static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
--
drivers/hid/wacom_wac.c-3397- if ((wacom->shared->type == INTUOSHT ||
drivers/hid/wacom_wac.c:3398: wacom->shared->type == INTUOSHT2) &&
drivers/hid/wacom_wac.c-3399- wacom->shared->touch_input &&
--
drivers/hid/wacom_wac.c=3427=static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
--
drivers/hid/wacom_wac.c-3436- if ((features->type == INTUOSHT ||
drivers/hid/wacom_wac.c:3437: features->type == INTUOSHT2) &&
drivers/hid/wacom_wac.c-3438- wacom_wac->shared->touch_input &&
--
drivers/hid/wacom_wac.c=3461=void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
--
drivers/hid/wacom_wac.c-3555- case INTUOSHT:
drivers/hid/wacom_wac.c:3556: case INTUOSHT2:
drivers/hid/wacom_wac.c-3557- if (wacom_wac->data[0] == WACOM_REPORT_USB)
--
drivers/hid/wacom_wac.c=3648=void wacom_setup_device_quirks(struct wacom *wacom)
--
drivers/hid/wacom_wac.c-3680-
drivers/hid/wacom_wac.c:3681: if (features->type == INTUOSHT2) {
drivers/hid/wacom_wac.c-3682- features->x_max = features->x_max / 10;
--
drivers/hid/wacom_wac.c=3801=int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
--
drivers/hid/wacom_wac.c-3942- case BAMBOO_PEN:
drivers/hid/wacom_wac.c:3943: case INTUOSHT2:
drivers/hid/wacom_wac.c-3944- case INTUOSHT3_BT:
drivers/hid/wacom_wac.c:3945: if (features->type == INTUOSHT2 ||
drivers/hid/wacom_wac.c-3946- features->type == INTUOSHT3_BT) {
--
drivers/hid/wacom_wac.c=3966=int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
--
drivers/hid/wacom_wac.c-4075- case INTUOSHT:
drivers/hid/wacom_wac.c:4076: case INTUOSHT2:
drivers/hid/wacom_wac.c-4077- input_dev->evbit[0] |= BIT_MASK(EV_SW);
--
drivers/hid/wacom_wac.c=4239=int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
--
drivers/hid/wacom_wac.c-4385- case BAMBOO_TOUCH:
drivers/hid/wacom_wac.c:4386: case INTUOSHT2:
drivers/hid/wacom_wac.c-4387- __clear_bit(ABS_MISC, input_dev->absbit);
--
drivers/hid/wacom_wac.c=4903=static const struct wacom_features wacom_features_0x33B =
drivers/hid/wacom_wac.c-4904- { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
drivers/hid/wacom_wac.c:4905: INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
drivers/hid/wacom_wac.c-4906- .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
drivers/hid/wacom_wac.c=4907=static const struct wacom_features wacom_features_0x33C =
drivers/hid/wacom_wac.c-4908- { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
drivers/hid/wacom_wac.c:4909: INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
drivers/hid/wacom_wac.c-4910- .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
drivers/hid/wacom_wac.c=4911=static const struct wacom_features wacom_features_0x33D =
drivers/hid/wacom_wac.c-4912- { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
drivers/hid/wacom_wac.c:4913: INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
drivers/hid/wacom_wac.c-4914- .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
drivers/hid/wacom_wac.c=4915=static const struct wacom_features wacom_features_0x33E =
drivers/hid/wacom_wac.c-4916- { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
drivers/hid/wacom_wac.c:4917: INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
drivers/hid/wacom_wac.c-4918- .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
--
drivers/hid/wacom_wac.h-66-#define WACOM_REPORT_REMOTE 17
drivers/hid/wacom_wac.h:67:#define WACOM_REPORT_INTUOSHT2_ID 8
drivers/hid/wacom_wac.h-68-
--
drivers/hid/wacom_wac.h=190=enum {
--
drivers/hid/wacom_wac.h-229- INTUOSHT,
drivers/hid/wacom_wac.h:230: INTUOSHT2,
drivers/hid/wacom_wac.h-231- BAMBOO_TOUCH,
]
|
| 145/4 |
2026/09/21 01:08 |
llm |
codeexpert-compressor |
0m
Model:
Reply: ### Investigation Overview and Goal
The user is investigating an apparent potential `NULL` pointer dereference in `drivers/hid/wacom_wac.c`:
- `wacom_intuos_irq()` is called from `wacom_bpt_irq()` when `features->type == INTUOSHT2` and `features->device_type & WACOM_DEVICETYPE_PEN`.
- In `wacom_intuos_irq()`, `wacom->pen_input` is dereferenced (e.g. at line 1036: `dev_dbg(input->dev.parent, ...)`).
- In `wacom_setup_inputs()`, `wacom->pen_input` is freed and set to `NULL` if `wacom_setup_pen_input_capabilities()` returns an error.
- `wacom_setup_pen_input_capabilities()` returns `-ENODEV` if `!(features->device_type & WACOM_DEVICETYPE_PEN)`.
- Core question: Are there any other ways `wacom->pen_input` can be `NULL` when `wacom_intuos_irq()` is called?
- Sub-question 1: Could `wacom_setup_pen_input_capabilities()` return an error for another reason?
- Sub-question 2: Could `wacom->pen_input` be freed/set to `NULL` somewhere else after `wacom_setup_inputs()`?
- Sub-question 3: Could `features->device_type` be modified after `wacom_setup_inputs()`?
- Sub-question 4: Could `wacom_bpt_irq()` be called before `wacom_setup_inputs()` completes?
- General: Any other possible ways `wacom->pen_input` can be `NULL` in `wacom_intuos_irq()`?
---
### Approaches and Findings So Far
1. **`wacom_setup_pen_input_capabilities()` Analysis (`drivers/hid/wacom_wac.c:3801-3964`)**
- Examined the entire function body:
- Line 3806: `if (!(features->device_type & WACOM_DEVICETYPE_PEN)) return -ENODEV;`
- If `features->type == HID_GENERIC`, returns `0`.
- Sets input properties and capabilities.
- Switch on `features->type`:
- `INTUOSHT2` and `INTUOSHT3_BT` call `wacom_setup_basic_pro_pen(wacom_wac); break;`
- `wacom_setup_basic_pro_pen()` has return type `void`.
- All other cases either set abs/key bits or call void helper functions (`wacom_setup_intuos`, `wacom_setup_cintiq`).
- Line 3963: Ends with `return 0;`.
- **Conclusion on Sub-question 1:** `wacom_setup_pen_input_capabilities()` has **only one** error return path: `-ENODEV` when `!(features->device_type & WACOM_DEVICETYPE_PEN)`. There are **no other reasons** it can return an error.
2. **All Writes/Assignments to `wacom_wac->pen_input` Across `drivers/hid`**
- Performed exact reference search (`codesearch-find-references` on `wacom_wac::pen_input`):
- `wacom_sys.c:2112` in `wacom_allocate_inputs()`: `wacom_wac->pen_input = wacom_allocate_input(wacom);`
- `wacom_sys.c:2144` in `wacom_setup_inputs()`: `wacom_wac->pen_input = NULL;` (when `wacom_setup_pen_input_capabilities()` returns error).
- `wacom_sys.c:2200` in `wacom_register_inputs()` under `fail:`: `wacom_wac->pen_input = NULL;` (if `input_register_device()` fails on pen, touch, or pad).
- `wacom_sys.c:2339` in `wacom_release_resources()`: `wacom->wacom_wac.pen_input = NULL;`.
- No other writes to `pen_input` exist in the kernel.
3. **Call Tree & Lifecycle around `wacom_setup_inputs()` and Registration (`drivers/hid/wacom_sys.c:2440-2508`)**
- In `wacom_parse_and_register(struct wacom *wacom, bool wireless)`:
```c
error = wacom_setup_inputs(wacom);
if (error)
goto fail;
if (features->type == HID_GENERIC)
connect_mask |= HID_CONNECT_DRIVER;
/* Regular HID work starts now */
error = hid_hw_start(hdev, connect_mask);
if (error)
goto fail;
error = wacom_register_inputs(wacom);
if (error)
goto fail_hw_stop;
...
fail_hw_stop:
hid_hw_stop(hdev);
fail:
wacom_release_resources(wacom);
return error;
```
- Notice: `hid_hw_start()` is called *before* `wacom_register_inputs(wacom)`.
- Notice: If `wacom_register_inputs()` fails:
- `wacom_register_inputs()` sets `wacom_wac->pen_input = NULL` in `fail:`.
- Then jumps to `fail_hw_stop: hid_hw_stop(hdev);` and `wacom_release_resources(wacom)`.
- Notice: Input devices are opened via `wacom_open(struct input_dev *dev)` (`wacom_sys.c:187-192`), which calls `hid_hw_open(wacom->hdev)`.
- BUT for `features->device_type & WACOM_DEVICETYPE_WL_MONITOR`, line 2490 explicitly calls `hid_hw_open(hdev)`.
- What happens with `wacom_raw_event()`? It dispatches to `wacom_wac_irq()`, which dispatches to `wacom_bpt_irq()`.
4. **Call Paths to `wacom_intuos_irq()`**
From `codesearch-find-references` on `wacom_intuos_irq`:
- `wacom_intuos_bt_process_data()` (called from `wacom_intuos_bt_irq()` for BT reports 0x03/0x04)
- `wacom_wac_irq()` switch:
- `case CINTIQ_COMPANION_2: sync = wacom_intuos_irq(wacom_wac); break;`
- `case INTUOS: ... else sync = wacom_intuos_irq(wacom_wac); break;`
- `wacom_bpt_irq()`:
```c
if ((features->type == INTUOSHT2) &&
(features->device_type & WACOM_DEVICETYPE_PEN))
return wacom_intuos_irq(wacom);
```
5. **`wacom_intuos_irq()` Dereference Details (`drivers/hid/wacom_wac.c:1022-1057`)**
```c
static int wacom_intuos_irq(struct wacom_wac *wacom)
{
unsigned char *data = wacom->data;
struct input_dev *input = wacom->pen_input;
int result;
if (data[0] != WACOM_REPORT_PENABLED &&
data[0] != WACOM_REPORT_INTUOS_ID1 &&
data[0] != WACOM_REPORT_INTUOS_ID2 &&
data[0] != WACOM_REPORT_INTUOSPAD &&
data[0] != WACOM_REPORT_INTUOS_PEN &&
data[0] != WACOM_REPORT_CINTIQ &&
data[0] != WACOM_REPORT_CINTIQPAD &&
data[0] != WACOM_REPORT_INTUOS5PAD) {
dev_dbg(input->dev.parent,
"%s: received unknown report #%d\n", __func__, data[0]);
return 0;
}
...
result = wacom_intuos_pad(wacom);
...
result = wacom_intuos_inout(wacom);
...
result = wacom_intuos_general(wacom);
```
If `input` is `NULL`, `input->dev.parent` immediately faults.
Also inside `wacom_intuos_inout()` and `wacom_intuos_general()`, `wacom->pen_input` is also dereferenced without checking `if (!input)`.
---
### Key Questions and Active Lines of Investigation
To provide a complete answer to the prompt:
1. **Could `wacom_setup_pen_input_capabilities()` return an error for another reason?**
- Answer verified: **No**. Only `!(features->device_type & WACOM_DEVICETYPE_PEN)` returns `-ENODEV`. All other branches return `0`.
2. **Could `features->device_type` be modified after `wacom_setup_inputs()`?**
- Need to check all places where `features->device_type` is written. Is it modified dynamically anywhere? (e.g. wireless work, quirks, battery detection, probe, mode switching, etc.)
3. **Could `wacom_bpt_irq()` be called before `wacom_setup_inputs()` completes?**
- Need to trace when interrupts/URBs/raw events can be delivered.
- When does `hid_hw_start()` start accepting URBs / raw_events? Does `hid_hw_start()` start before `wacom_register_inputs()`? What about before `wacom_setup_inputs()`?
- In `wacom_parse_and_register()`:
- `wacom_setup_inputs()` is called *before* `hid_hw_start(hdev, connect_mask)`.
- But what about shared devices / wireless / paired interfaces? Wacom multi-interface devices (e.g., touch interface vs pen interface, bamboo pad rerouting, or `wacom_wireless_work`)?
4. **Could `wacom->pen_input` be freed or set to `NULL` somewhere else after `wacom_setup_inputs()`?**
- In `wacom_register_inputs()`, if registration fails for `touch_input` or `pad_input` after `pen_input` is registered:
- `pen_input` is unregistered, and `wacom_wac->pen_input = NULL;`.
- But in that case, probe fails and `hid_hw_stop` is called. Could an in-flight raw_event hit while stopping?
- In `wacom_release_resources()`, `wacom_wac.pen_input = NULL;`.
- What about `wacom_remove()` / disconnect / unbind? If device disconnects, `wacom_remove` calls `hid_hw_close` / `hid_hw_stop`, but does a concurrent raw event run?
5. **Are there any cases where `features->type == INTUOSHT2` and `features->device_type & WACOM_DEVICETYPE_PEN` might have `pen_input == NULL`?**
- Check multi-interface devices: Wacom devices often have 2 USB interfaces (interface 0 = pen, interface 1 = touch).
- Check if the touch interface could ever receive a pen report or share features/irq handler with the pen interface, or if `features` struct is shared or distinct.
- Check Bamboo / Intuos Draw/Art/Photo (CTL-490, CTH-490, CTH-690, etc. which are INTUOSHT2).
- Check wireless receiver (`wacom_wireless.c` / `wacom_wireless_work`): When wireless dongle is plugged in without tablet attached or when tablet connects/disconnects.
---
### Critical Code & Files
- `drivers/hid/wacom_wac.c`:
- `wacom_bpt_irq()`: lines 3284-3300
- `wacom_intuos_irq()`: lines 1022-1057
- `wacom_setup_pen_input_capabilities()`: lines 3801-3964
- `drivers/hid/wacom_sys.c`:
- `wacom_allocate_inputs()`: lines 2108-2125
- `wacom_setup_inputs()`: lines 2127-2165
- `wacom_register_inputs()`: lines 2167-2202
- `wacom_parse_and_register()`: lines 2370-2507
- `wacom_raw_event()`: lines 169-185
- `wacom_release_resources()`: lines 2334-2342
- `drivers/hid/wacom.h`:
- Device type flags: `WACOM_DEVICETYPE_PEN`, `WACOM_DEVICETYPE_TOUCH`, `WACOM_DEVICETYPE_PAD`, `WACOM_DEVICETYPE_WL_MONITOR`, etc.
### Next Steps to Check
- Check all writes to `features.device_type` across `drivers/hid/wacom*`.
- Check shared data between interfaces (`wacom->shared`, `wacom_wac->shared`).
- Check if `wacom_bpt_irq` can be called from another interface or during disconnect/failure.
- Remember: Must call `set-results` tool exactly once before the final reply.
Tokens:
input: 61811
output: 3343
thoughts: 0
|
| 146/4 |
2026/09/21 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 28432
output: 40
thoughts: 0
|
| 147/4 |
2026/09/21 01:09 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3280 LineCount:40]
Results: map[Contents:3280:
3281: return 1;
3282: }
3283:
3284: static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
3285: {
3286: struct wacom_features *features = &wacom->features;
3287:
3288: if ((features->type == INTUOSHT2) &&
3289: (features->device_type & WACOM_DEVICETYPE_PEN))
3290: return wacom_intuos_irq(wacom);
3291: else if (len == WACOM_PKGLEN_BBTOUCH)
3292: return wacom_bpt_touch(wacom);
3293: else if (len == WACOM_PKGLEN_BBTOUCH3)
3294: return wacom_bpt3_touch(wacom);
3295: else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
3296: return wacom_bpt_pen(wacom);
3297:
3298: return 0;
3299: }
3300:
3301: static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
3302: unsigned char *data)
3303: {
3304: unsigned char prefix;
3305:
3306: /*
3307: * We need to reroute the event from the debug interface to the
3308: * pen interface.
3309: * We need to add the report ID to the actual pen report, so we
3310: * temporary overwrite the first byte to prevent having to kzalloc/kfree
3311: * and memcpy the report.
3312: */
3313: prefix = data[0];
3314: data[0] = WACOM_REPORT_BPAD_PEN;
3315:
3316: /*
3317: * actually reroute the event.
3318: * No need to check if wacom->shared->pen is valid, hid_input_report()
3319: * will check for us.
]
|
| 148/4 |
2026/09/21 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 29103
output: 39
thoughts: 0
|
| 149/4 |
2026/09/21 01:09 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2105 LineCount:65]
Results: map[Contents:2105: return input_dev;
2106: }
2107:
2108: static int wacom_allocate_inputs(struct wacom *wacom)
2109: {
2110: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2111:
2112: wacom_wac->pen_input = wacom_allocate_input(wacom);
2113: wacom_wac->touch_input = wacom_allocate_input(wacom);
2114: wacom_wac->pad_input = wacom_allocate_input(wacom);
2115: if (!wacom_wac->pen_input ||
2116: !wacom_wac->touch_input ||
2117: !wacom_wac->pad_input)
2118: return -ENOMEM;
2119:
2120: wacom_wac->pen_input->name = wacom_wac->pen_name;
2121: wacom_wac->touch_input->name = wacom_wac->touch_name;
2122: wacom_wac->pad_input->name = wacom_wac->pad_name;
2123:
2124: return 0;
2125: }
2126:
2127: static int wacom_setup_inputs(struct wacom *wacom)
2128: {
2129: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
2130: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2131: int error = 0;
2132:
2133: pen_input_dev = wacom_wac->pen_input;
2134: touch_input_dev = wacom_wac->touch_input;
2135: pad_input_dev = wacom_wac->pad_input;
2136:
2137: if (!pen_input_dev || !touch_input_dev || !pad_input_dev)
2138: return -EINVAL;
2139:
2140: error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
2141: if (error) {
2142: /* no pen in use on this interface */
2143: input_free_device(pen_input_dev);
2144: wacom_wac->pen_input = NULL;
2145: pen_input_dev = NULL;
2146: }
2147:
2148: error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac);
2149: if (error) {
2150: /* no touch in use on this interface */
2151: input_free_device(touch_input_dev);
2152: wacom_wac->touch_input = NULL;
2153: touch_input_dev = NULL;
2154: }
2155:
2156: error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
2157: if (error) {
2158: /* no pad events using this interface */
2159: input_free_device(pad_input_dev);
2160: wacom_wac->pad_input = NULL;
2161: pad_input_dev = NULL;
2162: }
2163:
2164: return 0;
2165: }
2166:
2167: static int wacom_register_inputs(struct wacom *wacom)
2168: {
2169: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
]
|
| 150/4 |
2026/09/21 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 30237
output: 39
thoughts: 0
|
| 151/4 |
2026/09/21 01:09 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2167 LineCount:50]
Results: map[Contents:2167: static int wacom_register_inputs(struct wacom *wacom)
2168: {
2169: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
2170: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2171: int error = 0;
2172:
2173: pen_input_dev = wacom_wac->pen_input;
2174: touch_input_dev = wacom_wac->touch_input;
2175: pad_input_dev = wacom_wac->pad_input;
2176:
2177: if (pen_input_dev) {
2178: error = input_register_device(pen_input_dev);
2179: if (error)
2180: goto fail;
2181: }
2182:
2183: if (touch_input_dev) {
2184: error = input_register_device(touch_input_dev);
2185: if (error)
2186: goto fail;
2187: }
2188:
2189: if (pad_input_dev) {
2190: error = input_register_device(pad_input_dev);
2191: if (error)
2192: goto fail;
2193: }
2194:
2195: return 0;
2196:
2197: fail:
2198: wacom_wac->pad_input = NULL;
2199: wacom_wac->touch_input = NULL;
2200: wacom_wac->pen_input = NULL;
2201: return error;
2202: }
2203:
2204: /*
2205: * Not all devices report physical dimensions from HID.
2206: * Compute the default from hardcoded logical dimension
2207: * and resolution before driver overwrites them.
2208: */
2209: static void wacom_set_default_phy(struct wacom_features *features)
2210: {
2211: if (features->x_resolution) {
2212: features->x_phy = (features->x_max * 100) /
2213: features->x_resolution;
2214: features->y_phy = (features->y_max * 100) /
2215: features->y_resolution;
2216: }
]
|
| 152/4 |
2026/09/21 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 31007
output: 39
thoughts: 0
|
| 153/4 |
2026/09/21 01:09 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2445 LineCount:70]
Results: map[Contents:2445: goto fail;
2446:
2447: error = wacom_setup_inputs(wacom);
2448: if (error)
2449: goto fail;
2450:
2451: if (features->type == HID_GENERIC)
2452: connect_mask |= HID_CONNECT_DRIVER;
2453:
2454: /* Regular HID work starts now */
2455: error = hid_hw_start(hdev, connect_mask);
2456: if (error) {
2457: hid_err(hdev, "hw start failed\n");
2458: goto fail;
2459: }
2460:
2461: error = wacom_register_inputs(wacom);
2462: if (error)
2463: goto fail_hw_stop;
2464:
2465: if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) {
2466: error = wacom_initialize_leds(wacom);
2467: if (error)
2468: goto fail_hw_stop;
2469:
2470: error = wacom_initialize_remotes(wacom);
2471: if (error)
2472: goto fail_hw_stop;
2473: }
2474:
2475: if (!wireless) {
2476: /* Note that if query fails it is not a hard failure */
2477: wacom_query_tablet_data(wacom);
2478: }
2479:
2480: /* touch only Bamboo doesn't support pen */
2481: if ((features->type == BAMBOO_TOUCH) &&
2482: (features->device_type & WACOM_DEVICETYPE_PEN)) {
2483: cancel_delayed_work_sync(&wacom->init_work);
2484: _wacom_query_tablet_data(wacom);
2485: error = -ENODEV;
2486: goto fail_hw_stop;
2487: }
2488:
2489: if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) {
2490: error = hid_hw_open(hdev);
2491: if (error) {
2492: hid_err(hdev, "hw open failed\n");
2493: goto fail_hw_stop;
2494: }
2495: }
2496:
2497: wacom_set_shared_values(wacom_wac);
2498: devres_close_group(&hdev->dev, wacom);
2499:
2500: return 0;
2501:
2502: fail_hw_stop:
2503: hid_hw_stop(hdev);
2504: fail:
2505: wacom_release_resources(wacom);
2506: return error;
2507: }
2508:
2509: static void wacom_wireless_work(struct work_struct *work)
2510: {
2511: struct wacom *wacom = container_of(work, struct wacom, wireless_work);
2512: struct usb_device *usbdev = wacom->usbdev;
2513: struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2514: struct hid_device *hdev1, *hdev2;
]
|
| 154/4 |
2026/09/21 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 32068
output: 39
thoughts: 0
|
| 155/4 |
2026/09/21 01:09 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2510 LineCount:85]
Results: map[Contents:2510: {
2511: struct wacom *wacom = container_of(work, struct wacom, wireless_work);
2512: struct usb_device *usbdev = wacom->usbdev;
2513: struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2514: struct hid_device *hdev1, *hdev2;
2515: struct wacom *wacom1, *wacom2;
2516: struct wacom_wac *wacom_wac1, *wacom_wac2;
2517: int error;
2518:
2519: /*
2520: * Regardless if this is a disconnect or a new tablet,
2521: * remove any existing input and battery devices.
2522: */
2523:
2524: wacom_destroy_battery(wacom);
2525:
2526: if (!usbdev)
2527: return;
2528:
2529: /* Stylus interface */
2530: hdev1 = usb_get_intfdata(usbdev->config->interface[1]);
2531: wacom1 = hid_get_drvdata(hdev1);
2532: wacom_wac1 = &(wacom1->wacom_wac);
2533: wacom_release_resources(wacom1);
2534:
2535: /* Touch interface */
2536: hdev2 = usb_get_intfdata(usbdev->config->interface[2]);
2537: wacom2 = hid_get_drvdata(hdev2);
2538: wacom_wac2 = &(wacom2->wacom_wac);
2539: wacom_release_resources(wacom2);
2540:
2541: if (wacom_wac->pid == 0) {
2542: hid_info(wacom->hdev, "wireless tablet disconnected\n");
2543: } else {
2544: const struct hid_device_id *id = wacom_ids;
2545:
2546: hid_info(wacom->hdev, "wireless tablet connected with PID %x\n",
2547: wacom_wac->pid);
2548:
2549: while (id->bus) {
2550: if (id->vendor == USB_VENDOR_ID_WACOM &&
2551: id->product == wacom_wac->pid)
2552: break;
2553: id++;
2554: }
2555:
2556: if (!id->bus) {
2557: hid_info(wacom->hdev, "ignoring unknown PID.\n");
2558: return;
2559: }
2560:
2561: /* Stylus interface */
2562: wacom_wac1->features =
2563: *((struct wacom_features *)id->driver_data);
2564:
2565: wacom_wac1->pid = wacom_wac->pid;
2566: hid_hw_stop(hdev1);
2567: error = wacom_parse_and_register(wacom1, true);
2568: if (error)
2569: goto fail;
2570:
2571: /* Touch interface */
2572: if (wacom_wac1->features.touch_max ||
2573: (wacom_wac1->features.type >= INTUOSHT &&
2574: wacom_wac1->features.type <= BAMBOO_PT)) {
2575: wacom_wac2->features =
2576: *((struct wacom_features *)id->driver_data);
2577: wacom_wac2->pid = wacom_wac->pid;
2578: hid_hw_stop(hdev2);
2579: error = wacom_parse_and_register(wacom2, true);
2580: if (error)
2581: goto fail;
2582: }
2583:
2584: if (strscpy(wacom_wac->name, wacom_wac1->name,
2585: sizeof(wacom_wac->name)) < 0) {
2586: hid_warn(wacom->hdev, "String overflow while assembling device name");
2587: }
2588: }
2589:
2590: return;
2591:
2592: fail:
2593: wacom_release_resources(wacom1);
2594: wacom_release_resources(wacom2);
]
|
| 156/4 |
2026/09/21 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 33441
output: 39
thoughts: 0
|
| 157/4 |
2026/09/21 01:09 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2325 LineCount:30]
Results: map[Contents:2325: "%s%s Pad", name, suffix);
2326: }
2327:
2328: static void wacom_release_resources(struct wacom *wacom)
2329: {
2330: struct hid_device *hdev = wacom->hdev;
2331:
2332: if (!wacom->resources)
2333: return;
2334:
2335: devres_release_group(&hdev->dev, wacom);
2336:
2337: wacom->resources = false;
2338:
2339: wacom->wacom_wac.pen_input = NULL;
2340: wacom->wacom_wac.touch_input = NULL;
2341: wacom->wacom_wac.pad_input = NULL;
2342: }
2343:
2344: static void wacom_set_shared_values(struct wacom_wac *wacom_wac)
2345: {
2346: if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) {
2347: wacom_wac->shared->type = wacom_wac->features.type;
2348: wacom_wac->shared->touch_input = wacom_wac->touch_input;
2349: }
2350:
2351: if (wacom_wac->has_mute_touch_switch) {
2352: wacom_wac->shared->has_mute_touch_switch = true;
2353: /* Hardware touch switch may be off. Wait until
2354: * we know the switch state to decide is_touch_on.
]
|
| 158/4 |
2026/09/21 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 33974
output: 38
thoughts: 0
|
| 159/4 |
2026/09/21 01:09 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:165 LineCount:40]
Results: map[Contents: 165:
166: return insert && !flush;
167: }
168:
169: static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
170: u8 *raw_data, int size)
171: {
172: struct wacom *wacom = hid_get_drvdata(hdev);
173:
174: if (wacom->wacom_wac.features.type == BOOTLOADER)
175: return 0;
176:
177: if (wacom_wac_pen_serial_enforce(hdev, report, raw_data, size))
178: return -1;
179:
180: wacom->wacom_wac.data = raw_data;
181:
182: wacom_wac_irq(&wacom->wacom_wac, size);
183:
184: return 0;
185: }
186:
187: static int wacom_open(struct input_dev *dev)
188: {
189: struct wacom *wacom = input_get_drvdata(dev);
190:
191: return hid_hw_open(wacom->hdev);
192: }
193:
194: static void wacom_close(struct input_dev *dev)
195: {
196: struct wacom *wacom = input_get_drvdata(dev);
197:
198: /*
199: * wacom->hdev should never be null, but surprisingly, I had the case
200: * once while unplugging the Wacom Wireless Receiver.
201: */
202: if (wacom->hdev)
203: hid_hw_close(wacom->hdev);
204: }
]
|
| 160/4 |
2026/09/21 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 34586
output: 38
thoughts: 0
|
| 161/4 |
2026/09/21 01:09 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:725 LineCount:40]
Results: map[Contents: 725: }
726:
727: static void wacom_retrieve_hid_descriptor(struct hid_device *hdev,
728: struct wacom_features *features)
729: {
730: struct wacom *wacom = hid_get_drvdata(hdev);
731: struct usb_interface *intf = wacom->intf;
732:
733: /* default features */
734: features->x_fuzz = 4;
735: features->y_fuzz = 4;
736: features->pressure_fuzz = 0;
737: features->distance_fuzz = 1;
738: features->tilt_fuzz = 1;
739:
740: /*
741: * The wireless device HID is basic and layout conflicts with
742: * other tablets (monitor and touch interface can look like pen).
743: * Skip the query for this type and modify defaults based on
744: * interface number.
745: */
746: if (features->type == WIRELESS && intf) {
747: if (intf->cur_altsetting->desc.bInterfaceNumber == 0)
748: features->device_type = WACOM_DEVICETYPE_WL_MONITOR;
749: else
750: features->device_type = WACOM_DEVICETYPE_NONE;
751: return;
752: }
753:
754: wacom_parse_hid(hdev, features);
755: }
756:
757: struct wacom_hdev_data {
758: struct list_head list;
759: struct kref kref;
760: struct hid_device *dev;
761: struct wacom_shared shared;
762: };
763:
764: static LIST_HEAD(wacom_udev_list);
]
|
| 162/4 |
2026/09/21 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 35205
output: 40
thoughts: 0
|
| 163/4 |
2026/09/21 01:09 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_sys.c Name:wacom_parse_hid]
Results: map[SourceCode: 523: static void wacom_parse_hid(struct hid_device *hdev,
524: struct wacom_features *features)
525: {
526: struct hid_report_enum *rep_enum;
527: struct hid_report *hreport;
528: int i, j;
529:
530: /* check features first */
531: rep_enum = &hdev->report_enum[HID_FEATURE_REPORT];
532: list_for_each_entry(hreport, &rep_enum->report_list, list) {
533: for (i = 0; i < hreport->maxfield; i++) {
534: /* Ignore if report count is out of bounds. */
535: if (hreport->field[i]->report_count < 1)
536: continue;
537:
538: for (j = 0; j < hreport->field[i]->maxusage; j++) {
539: wacom_feature_mapping(hdev, hreport->field[i],
540: hreport->field[i]->usage + j);
541: }
542: }
543: }
544:
545: /* now check the input usages */
546: rep_enum = &hdev->report_enum[HID_INPUT_REPORT];
547: list_for_each_entry(hreport, &rep_enum->report_list, list) {
548:
549: if (!hreport->maxfield)
550: continue;
551:
552: for (i = 0; i < hreport->maxfield; i++)
553: for (j = 0; j < hreport->field[i]->maxusage; j++)
554: wacom_usage_mapping(hdev, hreport->field[i],
555: hreport->field[i]->usage + j);
556: }
557:
558: wacom_post_parse_hid(hdev, features);
559: }
SourceFile:drivers/hid/wacom_sys.c]
|
| 164/4 |
2026/09/21 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 35874
output: 26
thoughts: 1665
Thoughts: **Deep Dive into Wacom Driver Initialization and Resource Management**
Okay, let's break down this `wacom_parse_and_register()` function and the surrounding code. My initial thought is to trace the execution flow and consider potential failure points. First, I see `wacom_setup_inputs()`, which seems to set up the necessary input devices. If we have a pen device (`WACOM_DEVICETYPE_PEN`), it sets up `pen_input` and keeps it valid. Then, `hid_hw_start()` is called with `connect_mask`. My immediate question is whether this call to `hid_hw_start()` actually initiates the USB interrupt URB. I need to confirm how `hid_hw_start` works, specifically if it starts the interrupt transfers in the USB HID context. I'll need to check the behavior of `usbhid_start()`.
I'm now diving deeper into how the USB interrupt transfers are started: is it `usbhid_start` or `usbhid_open`? What exactly is the difference between `hid_hw_open` and `hid_hw_start`? Also, what effect does the `connect_mask` have? If `HID_CONNECT_HIDRAW` or `HID_CONNECT_DRIVER` is set, does it change the initialization process? I know in the code, `connect_mask` starts as `HID_CONNECT_HIDRAW`, and it becomes `HID_CONNECT_DRIVER` only if the device `features->type == HID_GENERIC`. In the INTUOSHT2 case, that does not happen. So, effectively we have `connect_mask == HID_CONNECT_HIDRAW`, and I know that `hidraw_open()` calls `hid_hw_open()`.
Now let's examine `wacom_register_inputs()`. What happens if this call fails? Let's trace it; it registers the input devices for pen, touch, and pad. It appears that if registering any of them fails (e.g., touch), it jumps to the `fail` label, which calls `wacom_release_resources()` *after* setting `wacom_wac->pen_input = NULL`. So, if pen input registers successfully, but the touch input registration fails, the pen input device gets unregistered in that `wacom_register_inputs` call, before `hid_hw_stop` is called. So, in `wacom_parse_and_register`, if `wacom_register_inputs` fails, the `fail_hw_stop` is jumped to, which calls `hid_hw_stop(hdev)`, and then calls `wacom_release_resources()`.
Here is an interesting case: before `hid_hw_stop(hdev)` is called, could an event still be received? Or, will `wacom_release_resources()` run?
Now, let's consider `wacom_wireless_work()`! I see code that deals with wireless tablets and specifically calls `wacom_release_resources()` and `hid_hw_stop()`. I see that the wireless receiver's data, which is obtained via `usb_get_intfdata`, is used. Specifically, look at the code lines 2530-2540. I see that the code calls `wacom_release_resources(wacom1)`.
Now, if a wireless tablet disconnects, and `wacom_wac->pid == 0`, `wacom_release_resources(wacom1)` is called, but what does that function do? Examining `wacom_release_resources()`, it releases the device resources and also sets `wacom->wacom_wac.pen_input` to NULL. The key here is: does `wacom_release_resources()` stop the device, and does it call `hid_hw_stop()` on disconnect? I see that if `wacom_wac->pid == 0` (disconnected case), `hid_hw_stop(hdev1)` is *not* called! In fact, `hid_hw_stop(hdev1)` is only called in the `else` branch. So, in the disconnected case, the device is not stopped. So, is `hdev1` still open/started? What driver would even handle events on `hdev1`? I need to check how the wireless receiver actually works to fully understand this.
|
| 165/4 |
2026/09/21 01:10 |
tool |
grepper |
0m
Args: map[Expression:wireless_work PathPrefix:drivers/hid]
Results: map[Output:drivers/hid/wacom.h=157=struct wacom {
--
drivers/hid/wacom.h-162- struct mutex lock;
drivers/hid/wacom.h:163: struct work_struct wireless_work;
drivers/hid/wacom.h-164- struct work_struct battery_work;
--
drivers/hid/wacom.h=185=static inline void wacom_schedule_work(struct wacom_wac *wacom_wac,
--
drivers/hid/wacom.h-191- case WACOM_WORKER_WIRELESS:
drivers/hid/wacom.h:192: schedule_work(&wacom->wireless_work);
drivers/hid/wacom.h-193- break;
--
drivers/hid/wacom_sys.c=2370=static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
--
drivers/hid/wacom_sys.c-2508-
drivers/hid/wacom_sys.c:2509:static void wacom_wireless_work(struct work_struct *work)
drivers/hid/wacom_sys.c-2510-{
drivers/hid/wacom_sys.c:2511: struct wacom *wacom = container_of(work, struct wacom, wireless_work);
drivers/hid/wacom_sys.c-2512- struct usb_device *usbdev = wacom->usbdev;
--
drivers/hid/wacom_sys.c=2822=static int wacom_probe(struct hid_device *hdev,
--
drivers/hid/wacom_sys.c-2866- INIT_DELAYED_WORK(&wacom->aes_battery_work, wacom_aes_battery_handler);
drivers/hid/wacom_sys.c:2867: INIT_WORK(&wacom->wireless_work, wacom_wireless_work);
drivers/hid/wacom_sys.c-2868- INIT_WORK(&wacom->battery_work, wacom_battery_work);
--
drivers/hid/wacom_sys.c=2901=static void wacom_remove(struct hid_device *hdev)
--
drivers/hid/wacom_sys.c-2913- cancel_delayed_work_sync(&wacom->aes_battery_work);
drivers/hid/wacom_sys.c:2914: cancel_work_sync(&wacom->wireless_work);
drivers/hid/wacom_sys.c-2915- cancel_work_sync(&wacom->battery_work);
]
|
| 166/4 |
2026/09/21 01:10 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 39184
output: 31
thoughts: 16
Thoughts: Okay, here's my attempt at summarizing that thought process, tailored for an expert audience:
**Investigating the WACOM_WORKER_WIRELESS Process Scheduling**
Right, let's dive into this. My initial thought is to figure out where `WACOM_WORKER_WIRELESS` is currently scheduled within the system. I need to understand its position in the overall resource allocation scheme. Is it hogging a particular core? Is it being unfairly starved by higher-priority processes? Knowing the scheduler context is crucial for diagnosing any potential performance bottlenecks or behavioral oddities. I'm thinking about the different scheduling classes and priorities β is it a real-time process interfering with user-space responsiveness, or is it behaving as expected within the normal time-sharing scheme? I need to quickly identify its CPU affinity, and current runtime and its history, to establish a performance baseline, then dive deeper if I find anomalies. This investigation will set the stage for further analysis.
|
| 167/4 |
2026/09/21 01:10 |
tool |
grepper |
0m
Args: map[Expression:WACOM_WORKER_WIRELESS PathPrefix:drivers/hid]
Results: map[Output:drivers/hid/wacom.h=104=enum wacom_worker {
drivers/hid/wacom.h:105: WACOM_WORKER_WIRELESS,
drivers/hid/wacom.h-106- WACOM_WORKER_BATTERY,
--
drivers/hid/wacom.h=185=static inline void wacom_schedule_work(struct wacom_wac *wacom_wac,
--
drivers/hid/wacom.h-190- switch (which) {
drivers/hid/wacom.h:191: case WACOM_WORKER_WIRELESS:
drivers/hid/wacom.h-192- schedule_work(&wacom->wireless_work);
--
drivers/hid/wacom_wac.c=3385=static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
--
drivers/hid/wacom_wac.c-3410- wacom->pid = pid;
drivers/hid/wacom_wac.c:3411: wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
drivers/hid/wacom_wac.c-3412- }
--
drivers/hid/wacom_wac.c-3419- wacom->pid = 0;
drivers/hid/wacom_wac.c:3420: wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
drivers/hid/wacom_wac.c-3421- wacom_notify_battery(wacom, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
]
|
| 168/4 |
2026/09/21 01:10 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 39984
output: 1079
thoughts: 1688
Thoughts: **Analysis of Wacom Tablet Driver: Identifying Potential NULL Pointer Dereference**
Okay, let's break this down. My goal here is to pinpoint every possible scenario where `wacom->pen_input` might be `NULL` when `wacom_intuos_irq()` is called, especially considering the conditional check in `wacom_bpt_irq()` that *should* prevent this.
First, I examined the only error return in `wacom_setup_pen_input_capabilities()`, which is `-ENODEV` if the device isn't a pen device. However, `wacom_bpt_irq()` *itself* checks for the presence of the `WACOM_DEVICETYPE_PEN` flag, so this shouldn't be the issue. So, that avenue is closed.
Next, I looked for other places where `wacom->pen_input` is modified. I found that the `pen_input` pointer is allocated in `wacom_allocate_inputs()`. It's set to `NULL` in the `fail:` label of `wacom_register_inputs()` if input registration fails after it is already registered, and it's also cleared in `wacom_release_resources()`. Critically, `wacom_release_resources()` is called in several places: driver cleanup, during disconnect/unbind, and, notably, within `wacom_wireless_work()`. This wireless work queue is the first key area to focus on.
Then, I investigated if `features->device_type` could be altered after `wacom_setup_inputs()` completes. The code suggests that `features->device_type` is determined early on. After `wacom_setup_inputs()` completes, `features->device_type` is read in most places. However, it *is* modified, or overwritten, within `wacom_mode_change_work()` and, importantly, when a wireless tablet disconnects/reconnects in `wacom_wireless_work()`, including when `wacom_release_resources()` is called. That makes the wireless disconnect case particularly relevant.
Finally, I considered the timing between `wacom_bpt_irq()` and `wacom_setup_inputs()`. The standard initial probe flow ensures interrupts don't arrive before setup. However, this is where it gets interesting:
* I realized the code assumes initial setup and registration are complete.
* Because raw event delivery starts *after* `hid_hw_start()`, and before `wacom_register_inputs()` completes, a race *could* occur.
* Furthermore, even if the initial device type check in `wacom_bpt_irq()` passes, other interfaces, or other *parts* of the interface, may not include the pen, and thus the check won't happen. Calls to `wacom_intuos_irq()` made from the `CINTIQ_COMPANION_2` or `INTUOS` family code paths *directly* call the handler, bypassing the device type check. If a non-pen event is received on those interfaces, `pen_input` could be `NULL`.
Therefore, my conclusion is that: `wacom->pen_input` can be NULL in these cases:
* During initial device setup, if input registration fails for some reason (e.g. from a race or failure of `input_register_device()`) between `hid_hw_start()` and `wacom_register_inputs()` within `wacom_parse_and_register()`.
* During a wireless device disconnect via `wacom_wireless_work()` where `wacom_release_resources()` clears `pen_input`.
* Interrupts received on multi-interface devices or touch/pad-only interfaces of those types, *after* setup but before `wacom_release_resources()` happens, or when the initial check does not occur (e.g. `CINTIQ_COMPANION_2` or `INTUOS` family).
|
| 169/4 |
2026/09/21 01:10 |
tool |
set-results |
0m
Args: map[Answer:Based on kernel source code analysis of `drivers/hid/wacom_sys.c` and `drivers/hid/wacom_wac.c`, here are the findings regarding the questions:
1. **Could `wacom_setup_pen_input_capabilities()` return an error for another reason?**
- **No.** An inspection of `wacom_setup_pen_input_capabilities()` (lines 3801β3964) shows that it has only a single error exit point at line 3806:
```c
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
return -ENODEV;
```
All subsequent paths (including the `INTUOSHT2` case, which calls `wacom_setup_basic_pro_pen()` returning `void`) only set capability bits on the input device and conclude with `return 0;`. There are no memory allocations or other fallible operations.
2. **Where else can `wacom->pen_input` be freed or set to NULL?**
Every write to `pen_input` across `drivers/hid/` was examined:
- **Input registration failure (`wacom_register_inputs()` in `wacom_sys.c:2200`):**
`wacom_register_inputs()` registers `pen_input`, `touch_input`, and `pad_input` sequentially. If `pen_input` is registered successfully but registering `touch_input` or `pad_input` fails with an error, the code jumps to `fail:`, setting:
```c
wacom_wac->pad_input = NULL;
wacom_wac->touch_input = NULL;
wacom_wac->pen_input = NULL;
```
Because `hid_hw_start()` was already called earlier in `wacom_parse_and_register()`, this occurs while the hardware interface is started, before `hid_hw_stop()` is called in the unwind path.
- **Resource release / Wireless disconnect (`wacom_release_resources()` in `wacom_sys.c:2339`):**
`wacom_release_resources()` sets `pen_input = NULL` (and releases the devres group). This function is called:
- On failure cleanup paths in `wacom_parse_and_register()`.
- In `wacom_wireless_work()` (`wacom_sys.c:2533`): when a wireless receiver reports that a tablet disconnected (`wacom_wac->pid == 0`), `wacom_release_resources(wacom1)` is called for the stylus interface, setting `wacom1->wacom_wac.pen_input = NULL;`.
3. **Could `features->device_type` be modified after `wacom_setup_inputs()`?**
- In regular probe operation, `device_type` is determined prior to `wacom_setup_inputs()` and is not modified afterwards.
- The only dynamic modifications to `features` occur during mode switching (`wacom_mode_change_work()`) and wireless tablet connect/disconnect (`wacom_wireless_work()`), both of which re-parse and re-register interfaces rather than mutating `device_type` in-place on an active interface.
4. **Could `wacom_bpt_irq()` be called before `wacom_setup_inputs()` completes?**
- For a single interface during probe, `wacom_setup_inputs()` runs before `hid_hw_start()`. Raw input reports are only dispatched after hardware start and open, so `wacom_bpt_irq()` will not be called before `wacom_setup_inputs()` completes on that interface.
- However, after `hid_hw_start()` is called, if `wacom_register_inputs()` fails or during wireless disconnect cleanup in `wacom_wireless_work()`, `pen_input` can be NULL while reports might still arrive.
- Additionally, in other call paths leading to `wacom_intuos_irq()` (such as `wacom_wac_irq()` directly for `CINTIQ_COMPANION_2` and `INTUOS` models), there is no check for `WACOM_DEVICETYPE_PEN` prior to calling `wacom_intuos_irq()`, which can lead to dereferencing `pen_input == NULL` if an unexpected report is delivered to a touch- or pad-only interface.
(Caveat / unverified: The exact concurrency and locking behavior between USB URB completion in `wacom_raw_event()` and asynchronous work in `wacom_wireless_work()` was not fully traced due to tool limits.)]
Results: map[Answer:Based on kernel source code analysis of `drivers/hid/wacom_sys.c` and `drivers/hid/wacom_wac.c`, here are the findings regarding the questions:
1. **Could `wacom_setup_pen_input_capabilities()` return an error for another reason?**
- **No.** An inspection of `wacom_setup_pen_input_capabilities()` (lines 3801β3964) shows that it has only a single error exit point at line 3806:
```c
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
return -ENODEV;
```
All subsequent paths (including the `INTUOSHT2` case, which calls `wacom_setup_basic_pro_pen()` returning `void`) only set capability bits on the input device and conclude with `return 0;`. There are no memory allocations or other fallible operations.
2. **Where else can `wacom->pen_input` be freed or set to NULL?**
Every write to `pen_input` across `drivers/hid/` was examined:
- **Input registration failure (`wacom_register_inputs()` in `wacom_sys.c:2200`):**
`wacom_register_inputs()` registers `pen_input`, `touch_input`, and `pad_input` sequentially. If `pen_input` is registered successfully but registering `touch_input` or `pad_input` fails with an error, the code jumps to `fail:`, setting:
```c
wacom_wac->pad_input = NULL;
wacom_wac->touch_input = NULL;
wacom_wac->pen_input = NULL;
```
Because `hid_hw_start()` was already called earlier in `wacom_parse_and_register()`, this occurs while the hardware interface is started, before `hid_hw_stop()` is called in the unwind path.
- **Resource release / Wireless disconnect (`wacom_release_resources()` in `wacom_sys.c:2339`):**
`wacom_release_resources()` sets `pen_input = NULL` (and releases the devres group). This function is called:
- On failure cleanup paths in `wacom_parse_and_register()`.
- In `wacom_wireless_work()` (`wacom_sys.c:2533`): when a wireless receiver reports that a tablet disconnected (`wacom_wac->pid == 0`), `wacom_release_resources(wacom1)` is called for the stylus interface, setting `wacom1->wacom_wac.pen_input = NULL;`.
3. **Could `features->device_type` be modified after `wacom_setup_inputs()`?**
- In regular probe operation, `device_type` is determined prior to `wacom_setup_inputs()` and is not modified afterwards.
- The only dynamic modifications to `features` occur during mode switching (`wacom_mode_change_work()`) and wireless tablet connect/disconnect (`wacom_wireless_work()`), both of which re-parse and re-register interfaces rather than mutating `device_type` in-place on an active interface.
4. **Could `wacom_bpt_irq()` be called before `wacom_setup_inputs()` completes?**
- For a single interface during probe, `wacom_setup_inputs()` runs before `hid_hw_start()`. Raw input reports are only dispatched after hardware start and open, so `wacom_bpt_irq()` will not be called before `wacom_setup_inputs()` completes on that interface.
- However, after `hid_hw_start()` is called, if `wacom_register_inputs()` fails or during wireless disconnect cleanup in `wacom_wireless_work()`, `pen_input` can be NULL while reports might still arrive.
- Additionally, in other call paths leading to `wacom_intuos_irq()` (such as `wacom_wac_irq()` directly for `CINTIQ_COMPANION_2` and `INTUOS` models), there is no check for `WACOM_DEVICETYPE_PEN` prior to calling `wacom_intuos_irq()`, which can lead to dereferencing `pen_input == NULL` if an unexpected report is delivered to a touch- or pad-only interface.
(Caveat / unverified: The exact concurrency and locking behavior between USB URB completion in `wacom_raw_event()` and asynchronous work in `wacom_wireless_work()` was not fully traced due to tool limits.)]
|
| 170/2 |
2026/09/21 01:10 |
llm |
expert |
0m
Model:
Tokens:
input: 38883
output: 264
thoughts: 0
|
| 171/2 |
2026/09/21 01:10 |
tool |
codeexpert |
7m
Error:
Args: map[Question:In `wacom_parse_and_register()`, `hid_hw_start()` is called on line 2455.
Then `wacom_register_inputs()` is called on line 2461.
If `wacom_register_inputs()` fails, it sets `pen_input = NULL`.
Then `wacom_parse_and_register()` jumps to `fail_hw_stop` on line 2463, which calls `hid_hw_stop()`.
Could an interrupt/report arrive between `hid_hw_start()` and `hid_hw_stop()`?
If so, `wacom_raw_event()` -> `wacom_wac_irq()` -> `wacom_bpt_irq()` -> `wacom_intuos_irq()` could be called while `pen_input` is NULL.
Is this a plausible race condition?
Also, since syzkaller triggers this via `/dev/uhid`, it has full control over when reports are sent and can easily send a report exactly in this window.
Please confirm if this race condition is possible and if it explains the crash.]
|
| 172/3 |
2026/09/21 01:10 |
agent |
codeexpert |
7m
Model:
Error:
Instruction:
You are a capable Linux kernel developer tasked with researching complex questions
about kernel source code. You will be given a concrete question, and need to provide
a concrete answer.
Research the question using targeted, efficient tool calls. Don't make assumptions,
or rely on your previous knowledge about the kernel source code, use available tools
to access the actual source code. Keep your tool calls focused and limited to the
scope of the question. Do not explore tangential code paths or perform unbounded searches.
Use all available sources of information:
- kernel source code
- documentation in the Documentation dir in the source tree
- git commits descriptions, git blame
Do not guess file names or file paths and attempt to read them without
verifying their existence first using content search or directory listing tools.
If a file, symbol, or directory is not found via content search (grepper) or
directory listing (codesearch-dir-index), treat it as completely absent.
Do not attempt to guess alternative names, extensions, or directories.
Tool Selection Guidelines:
1. For C functions, structs, and variables: Prefer codesearch-definition-source
or codesearch-struct-layout FIRST to retrieve clean, exact definitions
without line-number guessing.
2. If symbol lookup fails (e.g., preprocessor macros, macro-generated code, or
disabled #ifdef branches), fall back to read-file or grepper.
3. For file headers, #include directives, preprocessor macro definitions, and
non-C files (Kconfig, Makefiles, docs): Use read-file or grepper directly.
4. Be concise and targeted. Answer the question as directly and concisely as possible
once you have located the relevant code or definitions. If a symbol or function cannot
be found after targeted searches, conclude with the best available information rather
than continuing repetitive searches.
Do NOT use git-log to search for the presence or existence of files in the
repository. git-log is only for tracing commit history of files that are
already present in the current checkout. If a file does not exist in the
current checkout, it cannot be used for reproduction.
Avoid running broad git-log queries (such as searches on the entire repo)
without a specific 'PathPrefix' to restrict the scope, as these are very
expensive and will time out.
If a git-log tool call times out, do not retry the query with the same broad
scope. You must specify a tighter, narrower 'PathPrefix' for subsequent queries.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: In `wacom_parse_and_register()`, `hid_hw_start()` is called on line 2455.
Then `wacom_register_inputs()` is called on line 2461.
If `wacom_register_inputs()` fails, it sets `pen_input = NULL`.
Then `wacom_parse_and_register()` jumps to `fail_hw_stop` on line 2463, which calls `hid_hw_stop()`.
Could an interrupt/report arrive between `hid_hw_start()` and `hid_hw_stop()`?
If so, `wacom_raw_event()` -> `wacom_wac_irq()` -> `wacom_bpt_irq()` -> `wacom_intuos_irq()` could be called while `pen_input` is NULL.
Is this a plausible race condition?
Also, since syzkaller triggers this via `/dev/uhid`, it has full control over when reports are sent and can easily send a report exactly in this window.
Please confirm if this race condition is possible and if it explains the crash.
|
| 173/4 |
2026/09/21 01:10 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 4396
output: 22
thoughts: 418
Thoughts: **Analyzing a Potential Race Condition in the Wacom Driver**
Okay, so I'm digging into this `wacom_parse_and_register()` function in the Linux kernel Wacom driver. The user's raising a really interesting point. It seems they've found a potential race condition and they're asking me to confirm its existence and relevance to a crash triggered by syzkaller.
Here's the breakdown as I see it: On line 2455, we call `hid_hw_start()`. Then, a few lines down on line 2461, we call `wacom_register_inputs()`. The crucial bit is that if `wacom_register_inputs()` fails, it nulls out `pen_input`. Now, the code jumps to `fail_hw_stop` on line 2463, where `hid_hw_stop()` is called.
The concern, and it's a valid one, is: could an interrupt or report arrive *between* the calls to `hid_hw_start()` and `hid_hw_stop()`? If so, we're looking at a possible call chain: `wacom_raw_event()` -> `wacom_wac_irq()` -> `wacom_bpt_irq()` -> `wacom_intuos_irq()`. But if `pen_input` is null at that point, we've got a problem. The user mentions that syzkaller, through `/dev/uhid`, can precisely control the timing of these reports, meaning this window of vulnerability could be exploited.
So, the user is essentially asking: is this a plausible race condition? Does it explain the crash? Given the user's expertise and the thoroughness of the analysis, it's a good question to ask, and this is a perfectly normal kernel debugging/vulnerability auditing/code analysis inquiry. This is a low severity issue, but worth investigating. I'm going to fire up some tools, probably `grepper` or `codesearch-definition-source`, and take a closer look at the `wacom_parse_and_register()` function and the surrounding code to verify this hypothesis. Time to get my hands dirty!
|
| 174/4 |
2026/09/21 01:11 |
tool |
grepper |
0m
Args: map[Expression:wacom_parse_and_register]
Results: map[Output:drivers/hid/wacom_sys.c=2344=static void wacom_set_shared_values(struct wacom_wac *wacom_wac)
--
drivers/hid/wacom_sys.c-2369-
drivers/hid/wacom_sys.c:2370:static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
drivers/hid/wacom_sys.c-2371-{
--
drivers/hid/wacom_sys.c=2509=static void wacom_wireless_work(struct work_struct *work)
--
drivers/hid/wacom_sys.c-2566- hid_hw_stop(hdev1);
drivers/hid/wacom_sys.c:2567: error = wacom_parse_and_register(wacom1, true);
drivers/hid/wacom_sys.c-2568- if (error)
--
drivers/hid/wacom_sys.c-2578- hid_hw_stop(hdev2);
drivers/hid/wacom_sys.c:2579: error = wacom_parse_and_register(wacom2, true);
drivers/hid/wacom_sys.c-2580- if (error)
--
drivers/hid/wacom_sys.c=2782=static void wacom_mode_change_work(struct work_struct *work)
--
drivers/hid/wacom_sys.c-2807- if (wacom1) {
drivers/hid/wacom_sys.c:2808: error = wacom_parse_and_register(wacom1, false);
drivers/hid/wacom_sys.c-2809- if (error)
--
drivers/hid/wacom_sys.c-2813- if (wacom2) {
drivers/hid/wacom_sys.c:2814: error = wacom_parse_and_register(wacom2, false);
drivers/hid/wacom_sys.c-2815- if (error)
--
drivers/hid/wacom_sys.c=2822=static int wacom_probe(struct hid_device *hdev,
--
drivers/hid/wacom_sys.c-2884-
drivers/hid/wacom_sys.c:2885: error = wacom_parse_and_register(wacom, false);
drivers/hid/wacom_sys.c-2886- if (error)
]
|
| 175/4 |
2026/09/21 01:11 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 5961
output: 40
thoughts: 27
Thoughts: Okay, here's my interpretation of what's going through my mind as I approach this code:
**Diving into the Wacom Driver Registration**
Alright, time to crack open the `wacom_parse_and_register` function. Specifically, it's located in `drivers/hid/wacom_sys.c`. I need to understand how this driver handles parsing and registering Wacom devices. This function is obviously critical to the whole device detection and initialization process. I need to figure out: How does it identify the device? What data does it extract from the device? And, most importantly, how does it fit into the overall HID subsystem and the kernel's device management framework? This is where the core logic that ties the hardware to the software starts. Let's see how it's done... time to get into it.
|
| 176/4 |
2026/09/21 01:11 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2370 LineCount:100]
Results: map[Contents:2370: static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
2371: {
2372: struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2373: struct wacom_features *features = &wacom_wac->features;
2374: struct hid_device *hdev = wacom->hdev;
2375: int error;
2376: unsigned int connect_mask = HID_CONNECT_HIDRAW;
2377:
2378: features->pktlen = wacom_compute_pktlen(hdev);
2379: if (!features->pktlen)
2380: return -ENODEV;
2381:
2382: if (!devres_open_group(&hdev->dev, wacom, GFP_KERNEL))
2383: return -ENOMEM;
2384:
2385: error = wacom_devm_kfifo_alloc(wacom);
2386: if (error)
2387: goto fail;
2388:
2389: wacom->resources = true;
2390:
2391: error = wacom_allocate_inputs(wacom);
2392: if (error)
2393: goto fail;
2394:
2395: /*
2396: * Bamboo Pad has a generic hid handling for the Pen, and we switch it
2397: * into debug mode for the touch part.
2398: * We ignore the other interfaces.
2399: */
2400: if (features->type == BAMBOO_PAD) {
2401: if (features->pktlen == WACOM_PKGLEN_PENABLED) {
2402: features->type = HID_GENERIC;
2403: } else if ((features->pktlen != WACOM_PKGLEN_BPAD_TOUCH) &&
2404: (features->pktlen != WACOM_PKGLEN_BPAD_TOUCH_USB)) {
2405: error = -ENODEV;
2406: goto fail;
2407: }
2408: }
2409:
2410: /* set the default size in case we do not get them from hid */
2411: wacom_set_default_phy(features);
2412:
2413: /* Retrieve the physical and logical size for touch devices */
2414: wacom_retrieve_hid_descriptor(hdev, features);
2415: wacom_setup_device_quirks(wacom);
2416:
2417: if (features->device_type == WACOM_DEVICETYPE_NONE &&
2418: features->type != WIRELESS) {
2419: error = features->type == HID_GENERIC ? -ENODEV : 0;
2420:
2421: dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.",
2422: hdev->name,
2423: error ? "Ignoring" : "Assuming pen");
2424:
2425: if (error)
2426: goto fail;
2427:
2428: features->device_type |= WACOM_DEVICETYPE_PEN;
2429: }
2430:
2431: wacom_calculate_res(features);
2432:
2433: wacom_update_name(wacom, wireless ? " (WL)" : "");
2434:
2435: /* pen only Bamboo neither support touch nor pad */
2436: if ((features->type == BAMBOO_PEN) &&
2437: ((features->device_type & WACOM_DEVICETYPE_TOUCH) ||
2438: (features->device_type & WACOM_DEVICETYPE_PAD))) {
2439: error = -ENODEV;
2440: goto fail;
2441: }
2442:
2443: error = wacom_add_shared_data(hdev);
2444: if (error)
2445: goto fail;
2446:
2447: error = wacom_setup_inputs(wacom);
2448: if (error)
2449: goto fail;
2450:
2451: if (features->type == HID_GENERIC)
2452: connect_mask |= HID_CONNECT_DRIVER;
2453:
2454: /* Regular HID work starts now */
2455: error = hid_hw_start(hdev, connect_mask);
2456: if (error) {
2457: hid_err(hdev, "hw start failed\n");
2458: goto fail;
2459: }
2460:
2461: error = wacom_register_inputs(wacom);
2462: if (error)
2463: goto fail_hw_stop;
2464:
2465: if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) {
2466: error = wacom_initialize_leds(wacom);
2467: if (error)
2468: goto fail_hw_stop;
2469:
]
|
| 177/4 |
2026/09/21 01:11 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 7695
output: 39
thoughts: 17
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm deeply embedded in a specific field and am encountering this text:
**Focusing In: Lines 2470-2510**
Alright, that's where we're going next. I'm zeroing in on lines 2470 through 2510. It means I've already established a context, I've got a grasp of what came before, and now I'm ready to dig into this specific section. This likely holds crucial data or argumentation that builds off of, or challenges, the concepts I have already read. I'm assuming that these lines probably address the core issue I'm looking into at the moment. Time to see what we've got.
|
| 178/4 |
2026/09/21 01:11 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2470 LineCount:40]
Results: map[Contents:2470: error = wacom_initialize_remotes(wacom);
2471: if (error)
2472: goto fail_hw_stop;
2473: }
2474:
2475: if (!wireless) {
2476: /* Note that if query fails it is not a hard failure */
2477: wacom_query_tablet_data(wacom);
2478: }
2479:
2480: /* touch only Bamboo doesn't support pen */
2481: if ((features->type == BAMBOO_TOUCH) &&
2482: (features->device_type & WACOM_DEVICETYPE_PEN)) {
2483: cancel_delayed_work_sync(&wacom->init_work);
2484: _wacom_query_tablet_data(wacom);
2485: error = -ENODEV;
2486: goto fail_hw_stop;
2487: }
2488:
2489: if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) {
2490: error = hid_hw_open(hdev);
2491: if (error) {
2492: hid_err(hdev, "hw open failed\n");
2493: goto fail_hw_stop;
2494: }
2495: }
2496:
2497: wacom_set_shared_values(wacom_wac);
2498: devres_close_group(&hdev->dev, wacom);
2499:
2500: return 0;
2501:
2502: fail_hw_stop:
2503: hid_hw_stop(hdev);
2504: fail:
2505: wacom_release_resources(wacom);
2506: return error;
2507: }
2508:
2509: static void wacom_wireless_work(struct work_struct *work)
]
|
| 179/4 |
2026/09/21 01:11 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 8493
output: 40
thoughts: 26
Thoughts: Here's my take on those thoughts, tailored for an expert audience:
**Diving into `wacom_register_inputs`**
Okay, time to dissect `wacom_register_inputs`. I need a quick refresher on its core functionality, so I'll jump right to the definition. Let's see how it handles the device registration process within the Wacom driver framework. I'm especially interested in how it interacts with the input subsystem, the device nodes it creates (if any), and any crucial setup or initialization it performs related to the tablet's capabilities. Specifically, I'm thinking about the implications for input event handling, HID report descriptors, and potentially, quirks that might be necessary for different Wacom models or variants. My focus is on understanding the fundamental mechanics of how new Wacom devices are brought online and integrated into the system's input processing.
|
| 180/4 |
2026/09/21 01:11 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_sys.c Name:wacom_register_inputs]
Results: map[SourceCode:2167: static int wacom_register_inputs(struct wacom *wacom)
2168: {
2169: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
2170: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2171: int error = 0;
2172:
2173: pen_input_dev = wacom_wac->pen_input;
2174: touch_input_dev = wacom_wac->touch_input;
2175: pad_input_dev = wacom_wac->pad_input;
2176:
2177: if (pen_input_dev) {
2178: error = input_register_device(pen_input_dev);
2179: if (error)
2180: goto fail;
2181: }
2182:
2183: if (touch_input_dev) {
2184: error = input_register_device(touch_input_dev);
2185: if (error)
2186: goto fail;
2187: }
2188:
2189: if (pad_input_dev) {
2190: error = input_register_device(pad_input_dev);
2191: if (error)
2192: goto fail;
2193: }
2194:
2195: return 0;
2196:
2197: fail:
2198: wacom_wac->pad_input = NULL;
2199: wacom_wac->touch_input = NULL;
2200: wacom_wac->pen_input = NULL;
2201: return error;
2202: }
SourceFile:drivers/hid/wacom_sys.c]
|
| 181/4 |
2026/09/21 01:11 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 9284
output: 28
thoughts: 674
Thoughts: **Analyzing Wacom Input Device Registration**
Okay, let's break this down. First, I'm looking at `wacom_register_inputs`. I see that it grabs the input devices: pen, touch, and pad, from `wacom_wac`. Then it calls `input_register_device` on each. The interesting part is the error handling. If *any* of those registrations fail (pen, touch, or pad), the code *unregisters* all three input devices by setting them to NULL: `wacom_wac->pad_input = NULL; wacom_wac->touch_input = NULL; wacom_wac->pen_input = NULL;`. This is critical.
Now, before `wacom_register_inputs` is called, `hid_hw_start(hdev, connect_mask)` is called. That makes me think about timing. Can an interrupt or report arrive *before* registration, that is when `hid_hw_start()` is called?
This leads me to a crucial question. How does the HID subsystem work, specifically with Wacom devices? I need to understand what `hid_hw_start()`, `hid_hw_open()`, and `wacom_raw_event()` are doing. Does `hid_hw_start()` immediately initiate report delivery, or does the device require an `hid_hw_open()` call? I know there are different transports: is it transport-dependent? Does USB, I2C, or uhid send reports regardless of `hid_hw_open()`?
Now I'm looking at `wacom_parse_and_register`. Here's where it gets interesting:
1. `hid_hw_start(hdev, connect_mask)` is called.
2. Then `wacom_register_inputs(wacom)` is called.
...and *then* there's a conditional: if the device is a WL monitor, `hid_hw_open(hdev)` is called.
Okay, so `hid_hw_open` is *conditionally* called. That has to mean something. I need to understand when it's called and why, and what it does in relation to the event handling. I wonder: does a `wacom_open()` function exist? I must know when/where `hid_hw_open()` is called and what its impact is on the raw event processing in the Wacom driver.
|
| 182/4 |
2026/09/21 01:12 |
tool |
grepper |
0m
Args: map[Expression:wacom_open PathPrefix:drivers/hid/]
Results: map[Output:drivers/hid/wacom_sys.c=169=static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
--
drivers/hid/wacom_sys.c-186-
drivers/hid/wacom_sys.c:187:static int wacom_open(struct input_dev *dev)
drivers/hid/wacom_sys.c-188-{
--
drivers/hid/wacom_sys.c=2083=static struct input_dev *wacom_allocate_input(struct wacom *wacom)
--
drivers/hid/wacom_sys.c-2095- input_dev->dev.parent = &hdev->dev;
drivers/hid/wacom_sys.c:2096: input_dev->open = wacom_open;
drivers/hid/wacom_sys.c-2097- input_dev->close = wacom_close;
]
|
| 183/4 |
2026/09/21 01:12 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 10757
output: 38
thoughts: 10
Thoughts: Okay, here's my attempt at summarizing the thought process, tailored for an expert audience, and written in the first person:
**Analyzing `wacom_open`**
Alright, let's dive into this `wacom_open` function. My initial thought process here is to immediately consider a few key aspects, given my experience. First, I'm expecting this to be a low-level function, probably interacting directly with the Wacom tablet driver or hardware. Therefore, I'm anticipating some system calls, perhaps related to device file operations, ioctls, or maybe even direct memory access. I'm already mentally flagging the potential for issues related to permissions, device enumeration, and error handling β these are classic pain points in this area.
Secondly, I'm curious about the specific input arguments. Are we taking a device file path, a vendor/product ID, or something else entirely? The input signature will immediately reveal the intended method of device identification, which will in turn suggest the complexity of the underlying device discovery mechanism.
Thirdly, I'm going to look for any initialization steps. Is this function responsible for allocating resources, initializing internal data structures, or setting up any device-specific configurations? Any memory allocation or resource acquisition needs to be carefully scrutinized for potential leaks or race conditions.
Finally, the return value is crucial. Is it a simple success/failure code, or does it return a file descriptor, a handle, or some other identifier that's going to be used by subsequent functions? The type of return value provides insight into how the device is represented and managed from that point on. I also need to make sure to account for and expect potential returns that can trigger an error response.
Essentially, I'm mentally parsing the function's responsibility: does `wacom_open` simply open the device, or does it set up some sort of communication channel and perform other setup steps for later use by higher-level tablet routines?
|
| 184/4 |
2026/09/21 01:12 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_sys.c Name:wacom_open]
Results: map[SourceCode: 187: static int wacom_open(struct input_dev *dev)
188: {
189: struct wacom *wacom = input_get_drvdata(dev);
190:
191: return hid_hw_open(wacom->hdev);
192: }
SourceFile:drivers/hid/wacom_sys.c]
|
| 185/4 |
2026/09/21 01:12 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 11331
output: 32
thoughts: 581
Thoughts: **Analyzing a Potential Race Condition in Wacom Driver Initialization**
Okay, here's what's running through my head. The question presents a very intriguing scenario, and I need to methodically break it down. Let's see...
First, I need to confirm the core of the issue: the timing. It's suggesting a race condition within the Wacom driver during initialization, specifically between `hid_hw_start()` and `hid_hw_stop()`. The crucial point is that `wacom_register_inputs()` can fail, and if it does, `pen_input` gets set to `NULL`. The concern is that an interrupt could arrive *between* the start and stop calls, triggering a chain of events: `wacom_raw_event()` -> `wacom_wac_irq()` -> `wacom_bpt_irq()` -> `wacom_intuos_irq()`. This could happen while `pen_input` is null, leading to a crash. The use of syzkaller is key, because it provides control of interrupt timing, making this scenario even more plausible.
So, where do I start? I need to analyze the `uhid` code. The key question is whether UHID, the user-space HID interface, calls `hid_input_report()` or something similar to inject the reports. I need to understand the path of a report originating from `/dev/uhid`, specifically looking at `UHID_INPUT` and `UHID_INPUT2`. Does the report bypass the necessary initialization?
Next, I need to nail down the precise state of `pen_input`. Can reports arrive *before* `wacom_register_inputs()` fails, or is `pen_input` already NULL *before* the function can return a failure? Does it *start* as NULL, or does it become NULL as a result of the failed registration? What about devices that don't even *have* a `pen_input`? How are those devices handled by the code?
I need to dive into the Wacom driver's code itself to trace the `pen_input` usage. I need to thoroughly examine the interrupt handlers: `wacom_raw_event`, `wacom_wac_irq`, `wacom_bpt_irq`, and `wacom_intuos_irq`. I'll look for any places where a `NULL` `pen_input` pointer could cause a dereference and a subsequent crash.
Finally, I'll need to check the git log and some relevant search terms, specifically looking for recent commits or existing syzkaller crash reports related to `wacom_register_inputs`, `wacom_parse_and_register`, and the interrupt routines. This will provide context for the issue and may help identify if anyone else has already encountered or addressed a similar problem. I also need to search for syzkaller crash reports.
|
| 186/4 |
2026/09/21 01:12 |
tool |
grepper |
0m
Args: map[Expression:wacom_intuos_irq PathPrefix:drivers/hid/]
Results: map[Output:drivers/hid/wacom.h-57- * - Fixed a Graphire bug
drivers/hid/wacom.h:58: * - Merged wacom_intuos3_irq into wacom_intuos_irq
drivers/hid/wacom.h-59- * v1.44 (pc) - Added support for Graphire4, Cintiq 710, Intuos3 6x11, etc.
--
drivers/hid/wacom_wac.c=849=static int wacom_intuos_general(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-1021-
drivers/hid/wacom_wac.c:1022:static int wacom_intuos_irq(struct wacom_wac *wacom)
drivers/hid/wacom_wac.c-1023-{
--
drivers/hid/wacom_wac.c=1192=static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
--
drivers/hid/wacom_wac.c-1197- wacom->data = data;
drivers/hid/wacom_wac.c:1198: wacom_intuos_irq(wacom);
drivers/hid/wacom_wac.c-1199- wacom->data = saved_data;
--
drivers/hid/wacom_wac.c=3284=static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
--
drivers/hid/wacom_wac.c-3289- (features->device_type & WACOM_DEVICETYPE_PEN))
drivers/hid/wacom_wac.c:3290: return wacom_intuos_irq(wacom);
drivers/hid/wacom_wac.c-3291- else if (len == WACOM_PKGLEN_BBTOUCH)
--
drivers/hid/wacom_wac.c=3461=void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
--
drivers/hid/wacom_wac.c-3510- case CINTIQ_COMPANION_2:
drivers/hid/wacom_wac.c:3511: sync = wacom_intuos_irq(wacom_wac);
drivers/hid/wacom_wac.c-3512- break;
--
drivers/hid/wacom_wac.c-3533- else
drivers/hid/wacom_wac.c:3534: sync = wacom_intuos_irq(wacom_wac);
drivers/hid/wacom_wac.c-3535- break;
]
|
| 187/4 |
2026/09/21 01:12 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 13299
output: 40
thoughts: 25
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Diving into the Wacom Driver**
Alright, let's get down to brass tacks. I'm going to jump into the `drivers/hid/wacom_sys.c` file. Specifically, I need to see what's happening with `wacom_raw_event`. It's a key function, the likely entry point for raw event processing from Wacom tablets. My initial guess is this is where the lower-level data from the device gets translated into something the input subsystem can understand. I'm hoping I can find a key to decode the Wacom's data.
|
| 188/4 |
2026/09/21 01:12 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_sys.c Name:wacom_raw_event]
Results: map[SourceCode: 169: static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
170: u8 *raw_data, int size)
171: {
172: struct wacom *wacom = hid_get_drvdata(hdev);
173:
174: if (wacom->wacom_wac.features.type == BOOTLOADER)
175: return 0;
176:
177: if (wacom_wac_pen_serial_enforce(hdev, report, raw_data, size))
178: return -1;
179:
180: wacom->wacom_wac.data = raw_data;
181:
182: wacom_wac_irq(&wacom->wacom_wac, size);
183:
184: return 0;
185: }
SourceFile:drivers/hid/wacom_sys.c]
|
| 189/4 |
2026/09/21 01:12 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 13807
output: 43
thoughts: 40
Thoughts: Here's my summary, as if I were thinking these thoughts:
**Analyzing Interrupt Handling in Wacom Drivers**
Okay, let's dive into the interrupt handling mechanisms. I need to take a look at how the `wacom_bpt_irq` and `wacom_intuos_irq` functions are implemented. I know those are in `drivers/hid/wacom_wac.c`, so I'll start there. Understanding how these interrupts are managed is key to diagnosing any potential latency issues or unexpected behavior with the tablets. I'm assuming there's some common logic, but it's important to see if there are device-specific differences in the interrupt service routines. Specifically, I'm interested in how they're connected to the hardware, the interrupt flags they utilize, and any workqueues or tasklets involved in processing the data. I'll need to pay close attention to the synchronization primitives being used, too, as race conditions here would be a nightmare. Let's dig in and see what's what.
|
| 190/4 |
2026/09/21 01:12 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_wac.c Name:wacom_bpt_irq]
Results: map[SourceCode:3284: static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
3285: {
3286: struct wacom_features *features = &wacom->features;
3287:
3288: if ((features->type == INTUOSHT2) &&
3289: (features->device_type & WACOM_DEVICETYPE_PEN))
3290: return wacom_intuos_irq(wacom);
3291: else if (len == WACOM_PKGLEN_BBTOUCH)
3292: return wacom_bpt_touch(wacom);
3293: else if (len == WACOM_PKGLEN_BBTOUCH3)
3294: return wacom_bpt3_touch(wacom);
3295: else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
3296: return wacom_bpt_pen(wacom);
3297:
3298: return 0;
3299: }
SourceFile:drivers/hid/wacom_wac.c]
|
| 191/4 |
2026/09/21 01:12 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 14445
output: 43
thoughts: 14
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Analyzing `wacom_intuos_irq`**
Alright, let's dive into this `wacom_intuos_irq` situation. My initial thought is, "Okay, Wacom Intuos... that usually means HID, right?" My mind immediately starts to run through the common interrupt handling paths for these devices. I'm thinking about the standard input interrupt routines, possibly related to `evdev`, `hidraw`, and how the kernel interacts with the device.
I'm picturing the interrupt handler structure in the kernel, and I'm instantly considering things like:
* **Interrupt latency:** Is this related to a performance problem? I need to think about jitter and responsiveness.
* **Contention:** Are there any other devices competing for interrupts on the same IRQ line? This would be a crucial point to check.
* **Driver version:** Is this on an older kernel? Has there been any changes made to the driver that might affect the behavior of this file?
* **Hardware specifics:** Is there anything specific about the Intuos model or hardware version that might be relevant? Is it USB? If so, what are the bus and device IDs, and am I sure it's not a driver conflict?
I'm starting to formulate a mental checklist: checking kernel logs for relevant error messages, tracing the interrupt handling flow, and reviewing the associated device driver code in the kernel tree. I'm assuming, of course, that this `wacom_intuos_irq` refers to *kernel* code and not something in user space. I would consider the user-space implications after ruling out or understanding a kernel-side problem. I'm thinking about relevant kernel modules involved and if there might be a module conflict or even a driver bug.
My next step would be to start gathering data: `dmesg`, `lsmod`, interrupt statistics (`/proc/interrupts`), possibly some `perf` or `ftrace` profiling if this is a performance issue. I'm expecting to either pinpoint a specific cause (like a problematic IRQ handler, a lock contention issue, or an input event misconfiguration) or at least narrow down the scope of the problem considerably. I'll need to know the specific context this reference is showing up.
|
| 192/4 |
2026/09/21 01:13 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_wac.c Name:wacom_intuos_irq]
Results: map[SourceCode:1022: static int wacom_intuos_irq(struct wacom_wac *wacom)
1023: {
1024: unsigned char *data = wacom->data;
1025: struct input_dev *input = wacom->pen_input;
1026: int result;
1027:
1028: if (data[0] != WACOM_REPORT_PENABLED &&
1029: data[0] != WACOM_REPORT_INTUOS_ID1 &&
1030: data[0] != WACOM_REPORT_INTUOS_ID2 &&
1031: data[0] != WACOM_REPORT_INTUOSPAD &&
1032: data[0] != WACOM_REPORT_INTUOS_PEN &&
1033: data[0] != WACOM_REPORT_CINTIQ &&
1034: data[0] != WACOM_REPORT_CINTIQPAD &&
1035: data[0] != WACOM_REPORT_INTUOS5PAD) {
1036: dev_dbg(input->dev.parent,
1037: "%s: received unknown report #%d\n", __func__, data[0]);
1038: return 0;
1039: }
1040:
1041: /* process pad events */
1042: result = wacom_intuos_pad(wacom);
1043: if (result)
1044: return result;
1045:
1046: /* process in/out prox events */
1047: result = wacom_intuos_inout(wacom);
1048: if (result)
1049: return result - 1;
1050:
1051: /* process general packets */
1052: result = wacom_intuos_general(wacom);
1053: if (result)
1054: return result - 1;
1055:
1056: return 0;
1057: }
SourceFile:drivers/hid/wacom_wac.c]
|
| 193/4 |
2026/09/21 01:13 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 15601
output: 42
thoughts: 355
Thoughts: **Debugging the Wacom Intuos IRQ Handler**
Okay, so I'm looking at this `wacom_intuos_irq` function, specifically lines 1025 through 1036. It's in the `wacom_intuos_irq` file, and I'm seeing a potential issue right away. This `dev_dbg` call looks suspicious. It's dereferencing `input->dev.parent`, but there's no check for `input` being NULL first! If `input` somehow *is* NULL, then we're going to crash with a NULL pointer dereference. Not good, not good at all.
However, let's step back and consider some context. The code checks `data[0]` against a series of constants related to different Wacom report types. It looks like it logs an unknown report and returns, skipping further processing if the report doesn't match a defined type. Wait a minute... What happens if `data[0]` actually *does* match one of those allowed reports? Does that avoid this NULL pointer dereference? Hmmm... I'm going to want to look at where `input` is set up and determine when it could be NULL... But first, I need to see what `wacom_intuos_pad` does with that data. It seems like the code doesn't proceed if it's not a known report, so, I will assume the developer intended `input` to be non-NULL when `data[0]` is of an expected report type. Let's see how that report is handled...
|
| 194/4 |
2026/09/21 01:13 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_wac.c Name:wacom_intuos_pad]
Results: map[SourceCode: 513: static int wacom_intuos_pad(struct wacom_wac *wacom)
514: {
515: struct wacom_features *features = &wacom->features;
516: unsigned char *data = wacom->data;
517: struct input_dev *input = wacom->pad_input;
518: int i;
519: int buttons = 0, nbuttons = features->numbered_buttons;
520: int keys = 0, nkeys = 0;
521: int ring1 = 0, ring2 = 0;
522: int strip1 = 0, strip2 = 0;
523: bool prox = false;
524: bool wrench = false, keyboard = false, mute_touch = false, menu = false,
525: info = false;
526:
527: /* pad packets. Works as a second tool and is always in prox */
528: if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
529: data[0] == WACOM_REPORT_CINTIQPAD))
530: return 0;
531:
532: if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
533: buttons = (data[3] << 1) | (data[2] & 0x01);
534: ring1 = data[1];
535: } else if (features->type == DTK) {
536: buttons = data[6];
537: } else if (features->type == WACOM_13HD) {
538: buttons = (data[4] << 1) | (data[3] & 0x01);
539: } else if (features->type == WACOM_24HD) {
540: buttons = (data[8] << 8) | data[6];
541: ring1 = data[1];
542: ring2 = data[2];
543:
544: /*
545: * Three "buttons" are available on the 24HD which are
546: * physically implemented as a touchstrip. Each button
547: * is approximately 3 bits wide with a 2 bit spacing.
548: * The raw touchstrip bits are stored at:
549: * ((data[3] & 0x1f) << 8) | data[4])
550: */
551: nkeys = 3;
552: keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
553: ((data[4] & 0xE0) ? 1<<1 : 0) |
554: ((data[4] & 0x07) ? 1<<0 : 0);
555: keyboard = !!(data[4] & 0xE0);
556: info = !!(data[3] & 0x1C);
557:
558: if (features->oPid) {
559: mute_touch = !!(data[4] & 0x07);
560: if (mute_touch)
561: wacom->shared->is_touch_on =
562: !wacom->shared->is_touch_on;
563: } else {
564: wrench = !!(data[4] & 0x07);
565: }
566: } else if (features->type == WACOM_27QHD) {
567: nkeys = 3;
568: keys = data[2] & 0x07;
569:
570: wrench = !!(data[2] & 0x01);
571: keyboard = !!(data[2] & 0x02);
572:
573: if (features->oPid) {
574: mute_touch = !!(data[2] & 0x04);
575: if (mute_touch)
576: wacom->shared->is_touch_on =
577: !wacom->shared->is_touch_on;
578: } else {
579: menu = !!(data[2] & 0x04);
580: }
581: input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
582: input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
583: input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
584: } else if (features->type == CINTIQ_HYBRID) {
585: /*
586: * Do not send hardware buttons under Android. They
587: * are already sent to the system through GPIO (and
588: * have different meaning).
589: *
590: * d-pad right -> data[4] & 0x10
591: * d-pad up -> data[4] & 0x20
592: * d-pad left -> data[4] & 0x40
593: * d-pad down -> data[4] & 0x80
594: * d-pad center -> data[3] & 0x01
595: */
596: buttons = (data[4] << 1) | (data[3] & 0x01);
597: } else if (features->type == CINTIQ_COMPANION_2) {
598: /* d-pad right -> data[2] & 0x10
599: * d-pad up -> data[2] & 0x20
600: * d-pad left -> data[2] & 0x40
601: * d-pad down -> data[2] & 0x80
602: * d-pad center -> data[1] & 0x01
603: */
604: buttons = ((data[2] >> 4) << 7) |
605: ((data[1] & 0x04) << 4) |
606: ((data[2] & 0x0F) << 2) |
607: (data[1] & 0x03);
608: } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
609: /*
610: * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
611: * addition to the mechanical switch. Switch data is
612: * stored in data[4], capacitive data in data[5].
613: *
614: * Touch ring mode switch (data[3]) has no capacitive sensor
615: */
616: buttons = (data[4] << 1) | (data[3] & 0x01);
617: ring1 = data[2];
618: } else {
619: if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
620: buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) |
621: (data[6] << 1) | (data[5] & 0x01);
622:
623: if (features->type == WACOM_22HD) {
624: nkeys = 3;
625: keys = data[9] & 0x07;
626:
627: info = !!(data[9] & 0x01);
628: wrench = !!(data[9] & 0x02);
629: }
630: } else {
631: buttons = ((data[6] & 0x10) << 5) |
632: ((data[5] & 0x10) << 4) |
633: ((data[6] & 0x0F) << 4) |
634: (data[5] & 0x0F);
635: }
636: strip1 = ((data[1] & 0x1f) << 8) | data[2];
637: strip2 = ((data[3] & 0x1f) << 8) | data[4];
638: }
639:
640: prox = (buttons & ~(~0U << nbuttons)) | (keys & ~(~0U << nkeys)) |
641: (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2;
642:
643: wacom_report_numbered_buttons(input, nbuttons, buttons);
644:
645: for (i = 0; i < nkeys; i++)
646: input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
647:
648: input_report_key(input, KEY_BUTTONCONFIG, wrench);
649: input_report_key(input, KEY_ONSCREEN_KEYBOARD, keyboard);
650: input_report_key(input, KEY_CONTROLPANEL, menu);
651: input_report_key(input, KEY_INFO, info);
652:
653: if (wacom->shared && wacom->shared->touch_input) {
654: input_report_switch(wacom->shared->touch_input,
655: SW_MUTE_DEVICE,
656: !wacom->shared->is_touch_on);
657: input_sync(wacom->shared->touch_input);
658: }
659:
660: input_report_abs(input, ABS_RX, strip1);
661: input_report_abs(input, ABS_RY, strip2);
662:
663: input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0);
664: input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0);
665:
666: input_report_key(input, wacom->tool[1], prox ? 1 : 0);
667: input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
668:
669: input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
670:
671: return 1;
672: }
SourceFile:drivers/hid/wacom_wac.c]
|
| 195/4 |
2026/09/21 01:13 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 19467
output: 43
thoughts: 25
Thoughts: Okay, here's my attempt at summarizing the thought process, as requested, geared toward an expert audience, and written in the first person:
**Investigating Input Device Behavior**
Right, let's dive in. I need to get a handle on this input device stuff. The main focus is on this behavior. But before I go too deep, I should probably also examine the other, related areas. I should take a look at the code or configurations for `wacom_intuos_inout` and `wacom_intuos_general`. There might be something relevant in those as well, some interaction, some shared resources, something I can leverage. It is unlikely that one section functions in isolation. It is better to have as complete a picture of the available information as possible.
|
| 196/4 |
2026/09/21 01:13 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_wac.c Name:wacom_intuos_inout]
Results: map[SourceCode: 773: static int wacom_intuos_inout(struct wacom_wac *wacom)
774: {
775: struct wacom_features *features = &wacom->features;
776: unsigned char *data = wacom->data;
777: struct input_dev *input = wacom->pen_input;
778: int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
779:
780: if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
781: ((data[1] & 0xfe) == 0x20) || /* in range */
782: ((data[1] & 0xfe) == 0x80))) /* out prox */
783: return 0;
784:
785: /* Enter report */
786: if ((data[1] & 0xfc) == 0xc0) {
787: /* serial number of the tool */
788: wacom->serial[idx] = ((__u64)(data[3] & 0x0f) << 28) +
789: (data[4] << 20) + (data[5] << 12) +
790: (data[6] << 4) + (data[7] >> 4);
791:
792: wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
793: ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8);
794:
795: wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]);
796:
797: wacom->shared->stylus_in_proximity = true;
798: return 1;
799: }
800:
801: /* in Range */
802: if ((data[1] & 0xfe) == 0x20) {
803: if (features->type != INTUOSHT2)
804: wacom->shared->stylus_in_proximity = true;
805:
806: /* in Range while exiting */
807: if (wacom->reporting_data) {
808: input_report_key(input, BTN_TOUCH, 0);
809: input_report_abs(input, ABS_PRESSURE, 0);
810: input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
811: return 2;
812: }
813: return 1;
814: }
815:
816: /* Exit report */
817: if ((data[1] & 0xfe) == 0x80) {
818: wacom->shared->stylus_in_proximity = false;
819: wacom->reporting_data = false;
820:
821: /* don't report exit if we don't know the ID */
822: if (!wacom->id[idx])
823: return 1;
824:
825: wacom_exit_report(wacom);
826: return 2;
827: }
828:
829: return 0;
830: }
SourceFile:drivers/hid/wacom_wac.c]
|
| 197/4 |
2026/09/21 01:13 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 20739
output: 42
thoughts: 12
Thoughts: Okay, here's my interpretation of "And look at `wacom_intuos_general`," rendered as my thought process, keeping in mind I'm an expert:
**Diving into the Wacom Intuos Landscape**
Right, let's pull up that `wacom_intuos_general` file. This likely contains the overarching configuration, documentation, or codebase related to the generic Intuos line. I'm immediately thinking, "Okay, what's the level of abstraction here?" Is this a high-level overview of the entire product family, encompassing driver configurations, hardware ID definitions, and perhaps even some cross-platform code? Or is this geared more towards a specific aspect, like general device settings management across different models?
My brain's already running through a mental checklist: what sort of data structures are we likely dealing with? Configuration files? Perhaps some kind of object model defining the capabilities and features common to the Intuos line? Are there any obvious areas of concern I should focus on first? Driver compatibility, perhaps? Or maybe potential conflicts between different Intuos generations or driver versions?
Iβm expecting to see a structured approach. Iβm hoping for good commenting and a clear delineation between the core features and the model-specific configurations. The goal, always, is to understand the general principles that govern the whole line, rather than getting bogged down in specifics too early. My initial read will involve quickly identifying the main components and then, depending on what I find, I will drill down into sections of relevance. The real test is: can I understand the `wacom_intuos_general` as a foundation upon which the more complex, device-specific elements are built? Itβs all about the architecture, the design, and how the general concepts are concretely implemented.
|
| 198/4 |
2026/09/21 01:13 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_wac.c Name:wacom_intuos_general]
Results: map[SourceCode: 849: static int wacom_intuos_general(struct wacom_wac *wacom)
850: {
851: struct wacom_features *features = &wacom->features;
852: unsigned char *data = wacom->data;
853: struct input_dev *input = wacom->pen_input;
854: int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
855: unsigned char type = (data[1] >> 1) & 0x0F;
856: unsigned int x, y, distance, t;
857:
858: if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
859: data[0] != WACOM_REPORT_INTUOS_PEN)
860: return 0;
861:
862: if (delay_pen_events(wacom))
863: return 1;
864:
865: /* don't report events if we don't know the tool ID */
866: if (!wacom->id[idx]) {
867: /* but reschedule a read of the current tool */
868: wacom_intuos_schedule_prox_event(wacom);
869: return 1;
870: }
871:
872: /*
873: * don't report events for invalid data
874: */
875: /* older I4 styli don't work with new Cintiqs */
876: if ((!((wacom->id[idx] >> 16) & 0x01) &&
877: (features->type == WACOM_21UX2)) ||
878: /* Only large Intuos support Lense Cursor */
879: (wacom->tool[idx] == BTN_TOOL_LENS &&
880: (features->type == INTUOS3 ||
881: features->type == INTUOS3S ||
882: features->type == INTUOS4 ||
883: features->type == INTUOS4S ||
884: features->type == INTUOS5 ||
885: features->type == INTUOS5S ||
886: features->type == INTUOSPM ||
887: features->type == INTUOSPS)) ||
888: /* Cintiq doesn't send data when RDY bit isn't set */
889: (features->type == CINTIQ && !(data[1] & 0x40)))
890: return 1;
891:
892: x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
893: y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
894: distance = data[9] >> 2;
895: if (features->type < INTUOS3S) {
896: x >>= 1;
897: y >>= 1;
898: distance >>= 1;
899: }
900: if (features->type == INTUOSHT2)
901: distance = features->distance_max - distance;
902: input_report_abs(input, ABS_X, x);
903: input_report_abs(input, ABS_Y, y);
904: input_report_abs(input, ABS_DISTANCE, distance);
905:
906: switch (type) {
907: case 0x00:
908: case 0x01:
909: case 0x02:
910: case 0x03:
911: /* general pen packet */
912: t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1);
913: if (features->pressure_max < 2047)
914: t >>= 1;
915: input_report_abs(input, ABS_PRESSURE, t);
916: if (features->type != INTUOSHT2) {
917: input_report_abs(input, ABS_TILT_X,
918: (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
919: input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
920: }
921: input_report_key(input, BTN_STYLUS, data[1] & 2);
922: input_report_key(input, BTN_STYLUS2, data[1] & 4);
923: input_report_key(input, BTN_TOUCH, t > 10);
924: break;
925:
926: case 0x0a:
927: /* airbrush second packet */
928: input_report_abs(input, ABS_WHEEL,
929: (data[6] << 2) | ((data[7] >> 6) & 3));
930: input_report_abs(input, ABS_TILT_X,
931: (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
932: input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
933: break;
934:
935: case 0x05:
936: /* Rotation packet */
937: if (features->type >= INTUOS3S) {
938: /* I3 marker pen rotation */
939: t = (data[6] << 3) | ((data[7] >> 5) & 7);
940: t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
941: ((t-1) / 2 + 450)) : (450 - t / 2) ;
942: input_report_abs(input, ABS_Z, t);
943: } else {
944: /* 4D mouse 2nd packet */
945: t = (data[6] << 3) | ((data[7] >> 5) & 7);
946: input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
947: ((t - 1) / 2) : -t / 2);
948: }
949: break;
950:
951: case 0x04:
952: /* 4D mouse 1st packet */
953: input_report_key(input, BTN_LEFT, data[8] & 0x01);
954: input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
955: input_report_key(input, BTN_RIGHT, data[8] & 0x04);
956:
957: input_report_key(input, BTN_SIDE, data[8] & 0x20);
958: input_report_key(input, BTN_EXTRA, data[8] & 0x10);
959: t = (data[6] << 2) | ((data[7] >> 6) & 3);
960: input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
961: break;
962:
963: case 0x06:
964: /* I4 mouse */
965: input_report_key(input, BTN_LEFT, data[6] & 0x01);
966: input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
967: input_report_key(input, BTN_RIGHT, data[6] & 0x04);
968: input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
969: - ((data[7] & 0x40) >> 6));
970: input_report_key(input, BTN_SIDE, data[6] & 0x08);
971: input_report_key(input, BTN_EXTRA, data[6] & 0x10);
972:
973: input_report_abs(input, ABS_TILT_X,
974: (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
975: input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
976: break;
977:
978: case 0x08:
979: if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
980: /* 2D mouse packet */
981: input_report_key(input, BTN_LEFT, data[8] & 0x04);
982: input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
983: input_report_key(input, BTN_RIGHT, data[8] & 0x10);
984: input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
985: - ((data[8] & 0x02) >> 1));
986:
987: /* I3 2D mouse side buttons */
988: if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
989: input_report_key(input, BTN_SIDE, data[8] & 0x40);
990: input_report_key(input, BTN_EXTRA, data[8] & 0x20);
991: }
992: }
993: else if (wacom->tool[idx] == BTN_TOOL_LENS) {
994: /* Lens cursor packets */
995: input_report_key(input, BTN_LEFT, data[8] & 0x01);
996: input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
997: input_report_key(input, BTN_RIGHT, data[8] & 0x04);
998: input_report_key(input, BTN_SIDE, data[8] & 0x10);
999: input_report_key(input, BTN_EXTRA, data[8] & 0x08);
1000: }
1001: break;
1002:
1003: case 0x07:
1004: case 0x09:
1005: case 0x0b:
1006: case 0x0c:
1007: case 0x0d:
1008: case 0x0e:
1009: case 0x0f:
1010: /* unhandled */
1011: break;
1012: }
1013:
1014: input_report_abs(input, ABS_MISC,
1015: wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */
1016: input_report_key(input, wacom->tool[idx], 1);
1017: input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
1018: wacom->reporting_data = true;
1019: return 2;
1020: }
SourceFile:drivers/hid/wacom_wac.c]
|
| 199/4 |
2026/09/21 01:13 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 24646
output: 35
thoughts: 90
Thoughts: Okay, here's my summary, framed as my thought process:
**Diving Deep into the HID Wacom History**
Right, time to get to the heart of this. My initial thought is to dive straight into the git history. I need to understand what's been done before in the `drivers/hid/wacom*` area. I'm focusing on commits that might have addressed similar issues β specifically, fixes. I'll be targeting keywords and authors known for their work in this space. I'll search for commits by the usual suspects: Ping Cheng, Jason Gerecke, Benjamin Tissoires, Jiri Kosina, etc. They're the ones most likely to have encountered and solved related problems. Beyond that I want to see if any commits are touching key files that I know are important for these types of Wacom devices. Specifically, I'm thinking about anything dealing with `pen_input`, `wacom_intuos_irq`, or `wacom_parse_and_register`. That should be a good starting point to quickly identify relevant changes or potential solutions.
|
| 200/4 |
2026/09/21 01:14 |
tool |
git-log |
0m
Args: map[CodeRegexp:pen_input Count:10 PathPrefix:drivers/hid/]
Results: map[Output:518e5b794c06 Merge tag 'for-7.3-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
]
|
| 201/4 |
2026/09/21 01:14 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 25064
output: 32
thoughts: 52
Thoughts: **Investigating Git Log Behavior**
Okay, hold on a second. That's odd. I ran `git log` and specified `CodeRegexp`, but it only spat out *one* commit. That can't be right. I need to understand what's going on here, because that definitely isn't what I expected, and it's throwing off my workflow.
I suspect the `CodeRegexp` search might be too restrictive, or maybe I am misremembering something, so I need to check something related to this area. I'll test by running `git log` with a `PathPrefix` instead. Let's try it for either `drivers/hid/wacom_sys.c` or `drivers/hid/wacom_wac.c` and see what that gets me. I want to see if the problem lies with the regular expression or with my initial assumptions about the commit history in that area. This should clarify if the issue is with my search term or something else entirely.
|
| 202/4 |
2026/09/21 01:14 |
tool |
git-log |
0m
Args: map[Count:10 PathPrefix:drivers/hid/wacom_wac.c]
Results: map[Output:518e5b794c06 Merge tag 'for-7.3-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
]
|
| 203/4 |
2026/09/21 01:14 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 25426
output: 41
thoughts: 31
Thoughts: Here's my take on the situation:
**Investigating a Potentially Shallow Git History**
Hold on a second! Before I dive any deeper, I need to rule out some basic git history issues. This feels like a situation where the problem might be something fundamental, like a shallow clone or a misconfigured repository. The first thing I'm going to do is run a `git log --oneline -n 5` without a path prefix, just to see if the overall history is truncated. If that looks normal, I'll switch gears and give `git blame` a try on a suspect file, to see if there are any obvious clues hidden in the metadata of the blame output. Gotta eliminate the simple explanations first!
|
| 204/4 |
2026/09/21 01:14 |
tool |
git-blame |
0m
Args: map[End:1039 File:drivers/hid/wacom_wac.c Start:1022]
Results: map[Output:^518e5b794c06 1022) static int wacom_intuos_irq(struct wacom_wac *wacom)
^518e5b794c06 1023) {
^518e5b794c06 1024) unsigned char *data = wacom->data;
^518e5b794c06 1025) struct input_dev *input = wacom->pen_input;
^518e5b794c06 1026) int result;
^518e5b794c06 1027)
^518e5b794c06 1028) if (data[0] != WACOM_REPORT_PENABLED &&
^518e5b794c06 1029) data[0] != WACOM_REPORT_INTUOS_ID1 &&
^518e5b794c06 1030) data[0] != WACOM_REPORT_INTUOS_ID2 &&
^518e5b794c06 1031) data[0] != WACOM_REPORT_INTUOSPAD &&
^518e5b794c06 1032) data[0] != WACOM_REPORT_INTUOS_PEN &&
^518e5b794c06 1033) data[0] != WACOM_REPORT_CINTIQ &&
^518e5b794c06 1034) data[0] != WACOM_REPORT_CINTIQPAD &&
^518e5b794c06 1035) data[0] != WACOM_REPORT_INTUOS5PAD) {
^518e5b794c06 1036) dev_dbg(input->dev.parent,
^518e5b794c06 1037) "%s: received unknown report #%d\n", __func__, data[0]);
^518e5b794c06 1038) return 0;
^518e5b794c06 1039) }
]
|
| 205/4 |
2026/09/21 01:14 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 26271
output: 27
thoughts: 362
Thoughts: **Analyzing a Potential Race Condition in Wacom Driver Code**
Okay, so I've got the code checked out at the relevant commit or a shallow clone, ready to dive in. First, let's make sure I've got the problem absolutely clear. Okay, rereading the prompt... it's about a potential race condition in the `wacom_parse_and_register()` function. Specifically, `hid_hw_start()` is called, then `wacom_register_inputs()`, and if the latter fails, it sets `pen_input` to NULL. The code then jumps to `fail_hw_stop` which calls `hid_hw_stop()`. The question is, could an interrupt or report arrive *between* `hid_hw_start()` and `hid_hw_stop()`? If so, the interrupt path, going through `wacom_raw_event()`, `wacom_wac_irq()`, `wacom_bpt_irq()`, and `wacom_intuos_irq()` could be called while `pen_input` is indeed NULL. That's a classic race condition scenario, and the syzkaller trigger via `/dev/uhid` means the fuzzer has precise control over the timing of the reports.
But, before I get too excited and start writing up an explanation of the race, I need to double-check my assumptions. Is it possible that `pen_input` *could* be NULL *without* the race condition, before these functions are called? I need to verify how `pen_input` is allocated and assigned. Let's see... `wacom_allocate_inputs` and `wacom_setup_inputs` are the obvious candidates to investigate. Gotta ensure it isn't uninitialized in some cases. Gotta be thorough.
|
| 206/4 |
2026/09/21 01:14 |
tool |
grepper |
0m
Args: map[Expression:pen_input PathPrefix:drivers/hid/]
Results: map[Output:drivers/hid/hid-uclogic-core.c=33=static void uclogic_inrange_timeout(struct timer_list *t)
--
drivers/hid/hid-uclogic-core.c-36- inrange_timer);
drivers/hid/hid-uclogic-core.c:37: struct input_dev *input = drvdata->pen_input;
drivers/hid/hid-uclogic-core.c-38-
--
drivers/hid/hid-uclogic-core.c=125=static int uclogic_input_configured(struct hid_device *hdev,
--
drivers/hid/hid-uclogic-core.c-144- /* Remember the input device so we can simulate events */
drivers/hid/hid-uclogic-core.c:145: drvdata->pen_input = hi->input;
drivers/hid/hid-uclogic-core.c-146- }
--
drivers/hid/hid-uclogic-core.c=547=static void uclogic_remove(struct hid_device *hdev)
--
drivers/hid/hid-uclogic-core.c-557- * timer and makes any later re-arm a no-op, so it is provably dead
drivers/hid/hid-uclogic-core.c:558: * before hid_hw_stop() frees the input device drvdata->pen_input
drivers/hid/hid-uclogic-core.c-559- * points at.
--
drivers/hid/hid-uclogic-params.h=248=struct uclogic_drvdata {
--
drivers/hid/hid-uclogic-params.h-258- /* Pen input device */
drivers/hid/hid-uclogic-params.h:259: struct input_dev *pen_input;
drivers/hid/hid-uclogic-params.h-260- /* In-range timer */
--
drivers/hid/hid-udraw-ps3.c=68=struct udraw {
--
drivers/hid/hid-udraw-ps3.c-70- struct input_dev *touch_input_dev;
drivers/hid/hid-udraw-ps3.c:71: struct input_dev *pen_input_dev;
drivers/hid/hid-udraw-ps3.c-72- struct input_dev *accel_input_dev;
--
drivers/hid/hid-udraw-ps3.c=101=static int udraw_raw_event(struct hid_device *hdev, struct hid_report *report,
--
drivers/hid/hid-udraw-ps3.c-235-
drivers/hid/hid-udraw-ps3.c:236: input_report_key(udraw->pen_input_dev, BTN_TOUCH, (level != 0));
drivers/hid/hid-udraw-ps3.c:237: input_report_key(udraw->pen_input_dev, BTN_TOOL_PEN, 1);
drivers/hid/hid-udraw-ps3.c:238: input_report_abs(udraw->pen_input_dev, ABS_PRESSURE, level);
drivers/hid/hid-udraw-ps3.c:239: input_report_abs(udraw->pen_input_dev, ABS_X, x);
drivers/hid/hid-udraw-ps3.c:240: input_report_abs(udraw->pen_input_dev, ABS_Y, y);
drivers/hid/hid-udraw-ps3.c-241- } else {
drivers/hid/hid-udraw-ps3.c:242: input_report_key(udraw->pen_input_dev, BTN_TOUCH, 0);
drivers/hid/hid-udraw-ps3.c:243: input_report_key(udraw->pen_input_dev, BTN_TOOL_PEN, 0);
drivers/hid/hid-udraw-ps3.c:244: input_report_abs(udraw->pen_input_dev, ABS_PRESSURE, 0);
drivers/hid/hid-udraw-ps3.c-245- }
drivers/hid/hid-udraw-ps3.c:246: input_sync(udraw->pen_input_dev);
drivers/hid/hid-udraw-ps3.c-247-
--
drivers/hid/hid-udraw-ps3.c=329=static bool udraw_setup_pen(struct udraw *udraw,
--
drivers/hid/hid-udraw-ps3.c-351-
drivers/hid/hid-udraw-ps3.c:352: udraw->pen_input_dev = input_dev;
drivers/hid/hid-udraw-ps3.c-353-
--
drivers/hid/hid-udraw-ps3.c=407=static int udraw_probe(struct hid_device *hdev, const struct hid_device_id *id)
--
drivers/hid/hid-udraw-ps3.c-437- input_register_device(udraw->touch_input_dev) ||
drivers/hid/hid-udraw-ps3.c:438: input_register_device(udraw->pen_input_dev) ||
drivers/hid/hid-udraw-ps3.c-439- input_register_device(udraw->accel_input_dev);
--
drivers/hid/wacom.h=232=void wacom_setup_device_quirks(struct wacom *wacom);
drivers/hid/wacom.h:233:int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
drivers/hid/wacom.h-234- struct wacom_wac *wacom_wac);
--
drivers/hid/wacom_sys.c=2108=static int wacom_allocate_inputs(struct wacom *wacom)
--
drivers/hid/wacom_sys.c-2111-
drivers/hid/wacom_sys.c:2112: wacom_wac->pen_input = wacom_allocate_input(wacom);
drivers/hid/wacom_sys.c-2113- wacom_wac->touch_input = wacom_allocate_input(wacom);
drivers/hid/wacom_sys.c-2114- wacom_wac->pad_input = wacom_allocate_input(wacom);
drivers/hid/wacom_sys.c:2115: if (!wacom_wac->pen_input ||
drivers/hid/wacom_sys.c-2116- !wacom_wac->touch_input ||
--
drivers/hid/wacom_sys.c-2119-
drivers/hid/wacom_sys.c:2120: wacom_wac->pen_input->name = wacom_wac->pen_name;
drivers/hid/wacom_sys.c-2121- wacom_wac->touch_input->name = wacom_wac->touch_name;
--
drivers/hid/wacom_sys.c=2127=static int wacom_setup_inputs(struct wacom *wacom)
drivers/hid/wacom_sys.c-2128-{
drivers/hid/wacom_sys.c:2129: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
drivers/hid/wacom_sys.c-2130- struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
--
drivers/hid/wacom_sys.c-2132-
drivers/hid/wacom_sys.c:2133: pen_input_dev = wacom_wac->pen_input;
drivers/hid/wacom_sys.c-2134- touch_input_dev = wacom_wac->touch_input;
--
drivers/hid/wacom_sys.c-2136-
drivers/hid/wacom_sys.c:2137: if (!pen_input_dev || !touch_input_dev || !pad_input_dev)
drivers/hid/wacom_sys.c-2138- return -EINVAL;
drivers/hid/wacom_sys.c-2139-
drivers/hid/wacom_sys.c:2140: error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
drivers/hid/wacom_sys.c-2141- if (error) {
drivers/hid/wacom_sys.c-2142- /* no pen in use on this interface */
drivers/hid/wacom_sys.c:2143: input_free_device(pen_input_dev);
drivers/hid/wacom_sys.c:2144: wacom_wac->pen_input = NULL;
drivers/hid/wacom_sys.c:2145: pen_input_dev = NULL;
drivers/hid/wacom_sys.c-2146- }
--
drivers/hid/wacom_sys.c=2167=static int wacom_register_inputs(struct wacom *wacom)
drivers/hid/wacom_sys.c-2168-{
drivers/hid/wacom_sys.c:2169: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
drivers/hid/wacom_sys.c-2170- struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
--
drivers/hid/wacom_sys.c-2172-
drivers/hid/wacom_sys.c:2173: pen_input_dev = wacom_wac->pen_input;
drivers/hid/wacom_sys.c-2174- touch_input_dev = wacom_wac->touch_input;
--
drivers/hid/wacom_sys.c-2176-
drivers/hid/wacom_sys.c:2177: if (pen_input_dev) {
drivers/hid/wacom_sys.c:2178: error = input_register_device(pen_input_dev);
drivers/hid/wacom_sys.c-2179- if (error)
--
drivers/hid/wacom_sys.c-2199- wacom_wac->touch_input = NULL;
drivers/hid/wacom_sys.c:2200: wacom_wac->pen_input = NULL;
drivers/hid/wacom_sys.c-2201- return error;
--
drivers/hid/wacom_sys.c=2328=static void wacom_release_resources(struct wacom *wacom)
--
drivers/hid/wacom_sys.c-2338-
drivers/hid/wacom_sys.c:2339: wacom->wacom_wac.pen_input = NULL;
drivers/hid/wacom_sys.c-2340- wacom->wacom_wac.touch_input = NULL;
--
drivers/hid/wacom_wac.c=41=static void wacom_force_proxout(struct wacom_wac *wacom_wac)
drivers/hid/wacom_wac.c-42-{
drivers/hid/wacom_wac.c:43: struct input_dev *input = wacom_wac->pen_input;
drivers/hid/wacom_wac.c-44-
--
drivers/hid/wacom_wac.c=126=static int wacom_penpartner_irq(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-128- unsigned char *data = wacom->data;
drivers/hid/wacom_wac.c:129: struct input_dev *input = wacom->pen_input;
drivers/hid/wacom_wac.c-130-
--
drivers/hid/wacom_wac.c=170=static int wacom_pl_irq(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-173- unsigned char *data = wacom->data;
drivers/hid/wacom_wac.c:174: struct input_dev *input = wacom->pen_input;
drivers/hid/wacom_wac.c-175- int prox, pressure;
--
drivers/hid/wacom_wac.c=231=static int wacom_ptu_irq(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-233- unsigned char *data = wacom->data;
drivers/hid/wacom_wac.c:234: struct input_dev *input = wacom->pen_input;
drivers/hid/wacom_wac.c-235-
--
drivers/hid/wacom_wac.c=260=static int wacom_dtu_irq(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-262- unsigned char *data = wacom->data;
drivers/hid/wacom_wac.c:263: struct input_dev *input = wacom->pen_input;
drivers/hid/wacom_wac.c-264- int prox = data[1] & 0x20;
--
drivers/hid/wacom_wac.c=290=static int wacom_dtus_irq(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-292- unsigned char *data = wacom->data;
drivers/hid/wacom_wac.c:293: struct input_dev *input = wacom->pen_input;
drivers/hid/wacom_wac.c-294- unsigned short prox, pressure = 0;
--
drivers/hid/wacom_wac.c=341=static int wacom_graphire_irq(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-344- unsigned char *data = wacom->data;
drivers/hid/wacom_wac.c:345: struct input_dev *input = wacom->pen_input;
drivers/hid/wacom_wac.c-346- struct input_dev *pad_input = wacom->pad_input;
--
drivers/hid/wacom_wac.c=734=static void wacom_exit_report(struct wacom_wac *wacom)
drivers/hid/wacom_wac.c-735-{
drivers/hid/wacom_wac.c:736: struct input_dev *input = wacom->pen_input;
drivers/hid/wacom_wac.c-737- struct wacom_features *features = &wacom->features;
--
drivers/hid/wacom_wac.c=773=static int wacom_intuos_inout(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-776- unsigned char *data = wacom->data;
drivers/hid/wacom_wac.c:777: struct input_dev *input = wacom->pen_input;
drivers/hid/wacom_wac.c-778- int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
--
drivers/hid/wacom_wac.c=849=static int wacom_intuos_general(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-852- unsigned char *data = wacom->data;
drivers/hid/wacom_wac.c:853: struct input_dev *input = wacom->pen_input;
drivers/hid/wacom_wac.c-854- int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
--
drivers/hid/wacom_wac.c=1022=static int wacom_intuos_irq(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-1024- unsigned char *data = wacom->data;
drivers/hid/wacom_wac.c:1025: struct input_dev *input = wacom->pen_input;
drivers/hid/wacom_wac.c-1026- int result;
--
drivers/hid/wacom_wac.c=1192=static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
--
drivers/hid/wacom_wac.c-1200-
drivers/hid/wacom_wac.c:1201: input_sync(wacom->pen_input);
drivers/hid/wacom_wac.c-1202- if (wacom->pad_input)
--
drivers/hid/wacom_wac.c=1206=static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
--
drivers/hid/wacom_wac.c-1214- if (len < 32) {
drivers/hid/wacom_wac.c:1215: dev_warn(wacom->pen_input->dev.parent,
drivers/hid/wacom_wac.c-1216- "Report 0x04 too short: %zu bytes\n", len);
--
drivers/hid/wacom_wac.c-1223- if (i == 1 && len < 22) {
drivers/hid/wacom_wac.c:1224: dev_warn(wacom->pen_input->dev.parent,
drivers/hid/wacom_wac.c-1225- "Report 0x03 too short: %zu bytes\n", len);
--
drivers/hid/wacom_wac.c-1241- default:
drivers/hid/wacom_wac.c:1242: dev_dbg(wacom->pen_input->dev.parent,
drivers/hid/wacom_wac.c-1243- "Unknown report: %d,%d size:%zu\n",
--
drivers/hid/wacom_wac.c=1275=static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-1278-
drivers/hid/wacom_wac.c:1279: struct input_dev *pen_input = wacom->pen_input;
drivers/hid/wacom_wac.c-1280- unsigned char *data = wacom->data;
--
drivers/hid/wacom_wac.c-1334- wacom_exit_report(wacom);
drivers/hid/wacom_wac.c:1335: input_sync(pen_input);
drivers/hid/wacom_wac.c-1336-
--
drivers/hid/wacom_wac.c-1354-
drivers/hid/wacom_wac.c:1355: input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
drivers/hid/wacom_wac.c:1356: input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
drivers/hid/wacom_wac.c-1357-
--
drivers/hid/wacom_wac.c-1367-
drivers/hid/wacom_wac.c:1368: input_report_abs(pen_input, ABS_TILT_X,
drivers/hid/wacom_wac.c-1369- (signed char)frame[7]);
drivers/hid/wacom_wac.c:1370: input_report_abs(pen_input, ABS_TILT_Y,
drivers/hid/wacom_wac.c-1371- (signed char)frame[8]);
drivers/hid/wacom_wac.c:1372: input_report_abs(pen_input, ABS_Z, rotation);
drivers/hid/wacom_wac.c:1373: input_report_abs(pen_input, ABS_WHEEL,
drivers/hid/wacom_wac.c-1374- get_unaligned_le16(&frame[11]));
--
drivers/hid/wacom_wac.c-1378- if (wacom->tool[0]) {
drivers/hid/wacom_wac.c:1379: input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
drivers/hid/wacom_wac.c-1380- if (wacom->features.type == INTUOSP2_BT ||
drivers/hid/wacom_wac.c-1381- wacom->features.type == INTUOSP2S_BT) {
drivers/hid/wacom_wac.c:1382: input_report_abs(pen_input, ABS_DISTANCE,
drivers/hid/wacom_wac.c-1383- range ? frame[13] : wacom->features.distance_max);
drivers/hid/wacom_wac.c-1384- } else {
drivers/hid/wacom_wac.c:1385: input_report_abs(pen_input, ABS_DISTANCE,
drivers/hid/wacom_wac.c-1386- range ? frame[7] : wacom->features.distance_max);
--
drivers/hid/wacom_wac.c-1388-
drivers/hid/wacom_wac.c:1389: input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x09);
drivers/hid/wacom_wac.c:1390: input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
drivers/hid/wacom_wac.c:1391: input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
drivers/hid/wacom_wac.c-1392-
drivers/hid/wacom_wac.c:1393: input_report_key(pen_input, wacom->tool[0], prox);
drivers/hid/wacom_wac.c:1394: input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
drivers/hid/wacom_wac.c:1395: input_report_abs(pen_input, ABS_MISC,
drivers/hid/wacom_wac.c-1396- wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
--
drivers/hid/wacom_wac.c-1401- /* add timestamp to unpack the frames */
drivers/hid/wacom_wac.c:1402: input_set_timestamp(pen_input, event_timestamp);
drivers/hid/wacom_wac.c-1403-
drivers/hid/wacom_wac.c:1404: input_sync(pen_input);
drivers/hid/wacom_wac.c-1405- }
--
drivers/hid/wacom_wac.c=1543=static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
--
drivers/hid/wacom_wac.c-1547- if (data[0] != 0x80 && data[0] != 0x81) {
drivers/hid/wacom_wac.c:1548: dev_dbg(wacom->pen_input->dev.parent,
drivers/hid/wacom_wac.c-1549- "%s: received unknown report #%d\n", __func__, data[0]);
--
drivers/hid/wacom_wac.c-1555- if (len < 286) {
drivers/hid/wacom_wac.c:1556: dev_warn(wacom->pen_input->dev.parent,
drivers/hid/wacom_wac.c-1557- "Pro2 BT report too short: %zu bytes\n", len);
--
drivers/hid/wacom_wac.c-1560- } else if (len < 46) {
drivers/hid/wacom_wac.c:1561: dev_warn(wacom->pen_input->dev.parent,
drivers/hid/wacom_wac.c-1562- "Pro2 BT report too short: %zu bytes\n", len);
--
drivers/hid/wacom_wac.c=1765=static int wacom_tpc_pen(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-1767- unsigned char *data = wacom->data;
drivers/hid/wacom_wac.c:1768: struct input_dev *input = wacom->pen_input;
drivers/hid/wacom_wac.c-1769- bool prox = data[1] & 0x20;
--
drivers/hid/wacom_wac.c=1795=static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
--
drivers/hid/wacom_wac.c-1798-
drivers/hid/wacom_wac.c:1799: if (wacom->pen_input) {
drivers/hid/wacom_wac.c:1800: dev_dbg(wacom->pen_input->dev.parent,
drivers/hid/wacom_wac.c-1801- "%s: received report #%d\n", __func__, data[0]);
--
drivers/hid/wacom_wac.c=2320=static void wacom_set_barrel_switch3_usage(struct wacom_wac *wacom_wac)
drivers/hid/wacom_wac.c-2321-{
drivers/hid/wacom_wac.c:2322: struct input_dev *input = wacom_wac->pen_input;
drivers/hid/wacom_wac.c-2323- struct wacom_features *features = &wacom_wac->features;
--
drivers/hid/wacom_wac.c=2335=static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
--
drivers/hid/wacom_wac.c-2340- struct wacom_features *features = &wacom_wac->features;
drivers/hid/wacom_wac.c:2341: struct input_dev *input = wacom_wac->pen_input;
drivers/hid/wacom_wac.c-2342- unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
--
drivers/hid/wacom_wac.c=2423=static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
--
drivers/hid/wacom_wac.c-2428- struct wacom_features *features = &wacom_wac->features;
drivers/hid/wacom_wac.c:2429: struct input_dev *input = wacom_wac->pen_input;
drivers/hid/wacom_wac.c-2430- unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
--
drivers/hid/wacom_wac.c=2581=static void wacom_wac_pen_report(struct hid_device *hdev,
--
drivers/hid/wacom_wac.c-2585- struct wacom_wac *wacom_wac = &wacom->wacom_wac;
drivers/hid/wacom_wac.c:2586: struct input_dev *input = wacom_wac->pen_input;
drivers/hid/wacom_wac.c-2587- bool range = wacom_wac->hid_data.inrange_state;
--
drivers/hid/wacom_wac.c=2950=void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
--
drivers/hid/wacom_wac.c-2965- wacom_wac_pad_event(hdev, field, usage, value);
drivers/hid/wacom_wac.c:2966: else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
drivers/hid/wacom_wac.c-2967- wacom_wac_pen_event(hdev, field, usage, value);
--
drivers/hid/wacom_wac.c=2998=static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report,
--
drivers/hid/wacom_wac.c-3017- return 0;
drivers/hid/wacom_wac.c:3018: else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
drivers/hid/wacom_wac.c-3019- wacom_wac_pen_report(hdev, report);
--
drivers/hid/wacom_wac.c=3026=void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
--
drivers/hid/wacom_wac.c-3055- wacom_wac_pad_pre_report(hdev, report);
drivers/hid/wacom_wac.c:3056: if (pen_in_hid_field && wacom_wac->pen_input)
drivers/hid/wacom_wac.c-3057- wacom_wac_pen_pre_report(hdev, report);
--
drivers/hid/wacom_wac.c=3209=static int wacom_bpt_pen(struct wacom_wac *wacom)
--
drivers/hid/wacom_wac.c-3211- struct wacom_features *features = &wacom->features;
drivers/hid/wacom_wac.c:3212: struct input_dev *input = wacom->pen_input;
drivers/hid/wacom_wac.c-3213- unsigned char *data = wacom->data;
--
drivers/hid/wacom_wac.c=3461=void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
--
drivers/hid/wacom_wac.c-3584- if (sync) {
drivers/hid/wacom_wac.c:3585: if (wacom_wac->pen_input)
drivers/hid/wacom_wac.c:3586: input_sync(wacom_wac->pen_input);
drivers/hid/wacom_wac.c-3587- if (wacom_wac->touch_input)
--
drivers/hid/wacom_wac.c=3594=static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
drivers/hid/wacom_wac.c-3595-{
drivers/hid/wacom_wac.c:3596: struct input_dev *input_dev = wacom_wac->pen_input;
drivers/hid/wacom_wac.c-3597-
--
drivers/hid/wacom_wac.c=3608=static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
drivers/hid/wacom_wac.c-3609-{
drivers/hid/wacom_wac.c:3610: struct input_dev *input_dev = wacom_wac->pen_input;
drivers/hid/wacom_wac.c-3611- struct wacom_features *features = &wacom_wac->features;
--
drivers/hid/wacom_wac.c=3627=static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
drivers/hid/wacom_wac.c-3628-{
drivers/hid/wacom_wac.c:3629: struct input_dev *input_dev = wacom_wac->pen_input;
drivers/hid/wacom_wac.c-3630-
--
drivers/hid/wacom_wac.c=3648=void wacom_setup_device_quirks(struct wacom *wacom)
--
drivers/hid/wacom_wac.c-3786- features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
drivers/hid/wacom_wac.c:3787: __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
drivers/hid/wacom_wac.c:3788: __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
drivers/hid/wacom_wac.c:3789: __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
drivers/hid/wacom_wac.c:3790: __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
drivers/hid/wacom_wac.c:3791: __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
drivers/hid/wacom_wac.c:3792: __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
drivers/hid/wacom_wac.c:3793: __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
drivers/hid/wacom_wac.c:3794: __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
drivers/hid/wacom_wac.c:3795: __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
drivers/hid/wacom_wac.c:3796: __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
drivers/hid/wacom_wac.c:3797: __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
drivers/hid/wacom_wac.c-3798- }
--
drivers/hid/wacom_wac.c-3800-
drivers/hid/wacom_wac.c:3801:int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
drivers/hid/wacom_wac.c-3802- struct wacom_wac *wacom_wac)
--
drivers/hid/wacom_wac.h=337=struct wacom_wac {
--
drivers/hid/wacom_wac.h-349- struct wacom_shared *shared;
drivers/hid/wacom_wac.h:350: struct input_dev *pen_input;
drivers/hid/wacom_wac.h-351- struct input_dev *touch_input;
]
|
| 207/4 |
2026/09/21 01:14 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 36351
output: 39
thoughts: 668
Thoughts: **Analyzing Wacom Input Setup**
Okay, here's what I'm seeing. This `grep` output points me directly to `drivers/hid/wacom_sys.c` and specifically to the `wacom_setup_inputs` function. It looks like this function is responsible for initializing the input devices for a Wacom tablet, managing the `pen_input_dev`, `touch_input_dev`, and `pad_input_dev` devices. I immediately see those critical lines, specifically 2140 to 2146. It seems that if `wacom_setup_pen_input_capabilities` fails, the code *frees* the `pen_input_dev`! My intuition tells me that means that the error path handles the case where a pen isn't present, or isn't enabled on this interface. This is important to note and confirms the assumption. I need to dig further into `wacom_setup_pen_input_capabilities` to understand what that function does and why it might fail. I'm going to read the entire `wacom_setup_inputs` function now to get the full context.
|
| 208/4 |
2026/09/21 01:14 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_sys.c FirstLine:2127 LineCount:45]
Results: map[Contents:2127: static int wacom_setup_inputs(struct wacom *wacom)
2128: {
2129: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
2130: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2131: int error = 0;
2132:
2133: pen_input_dev = wacom_wac->pen_input;
2134: touch_input_dev = wacom_wac->touch_input;
2135: pad_input_dev = wacom_wac->pad_input;
2136:
2137: if (!pen_input_dev || !touch_input_dev || !pad_input_dev)
2138: return -EINVAL;
2139:
2140: error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
2141: if (error) {
2142: /* no pen in use on this interface */
2143: input_free_device(pen_input_dev);
2144: wacom_wac->pen_input = NULL;
2145: pen_input_dev = NULL;
2146: }
2147:
2148: error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac);
2149: if (error) {
2150: /* no touch in use on this interface */
2151: input_free_device(touch_input_dev);
2152: wacom_wac->touch_input = NULL;
2153: touch_input_dev = NULL;
2154: }
2155:
2156: error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
2157: if (error) {
2158: /* no pad events using this interface */
2159: input_free_device(pad_input_dev);
2160: wacom_wac->pad_input = NULL;
2161: pad_input_dev = NULL;
2162: }
2163:
2164: return 0;
2165: }
2166:
2167: static int wacom_register_inputs(struct wacom *wacom)
2168: {
2169: struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
2170: struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2171: int error = 0;
]
|
| 209/4 |
2026/09/21 01:14 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 38068
output: 45
thoughts: 69
Thoughts: **Analyzing the Wacom Input Setup**
Okay, let's dive in. I need to understand how this Wacom driver is setting up input. First, I'm going to focus on this `wacom_setup_inputs()` function. My immediate concern is the handling of pen input. I see a critical point: if `wacom_setup_pen_input_capabilities()` returns an error β something other than zero β the driver immediately nulls out `wacom_wac->pen_input`. Hold on, that's significant. That suggests this input setup function is designed to *fail fast* if pen capability initialization goes wrong. I need to understand why and how it's failing in the first place, or if it is at all. I have to scrutinize what `wacom_setup_pen_input_capabilities()` is doing now! I must look at what specifically could cause the pen to be set to NULL here.
|
| 210/4 |
2026/09/21 01:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/hid/wacom_wac.c Name:wacom_setup_pen_input_capabilities]
Results: map[SourceCode:3801: int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3802: struct wacom_wac *wacom_wac)
3803: {
3804: struct wacom_features *features = &wacom_wac->features;
3805:
3806: if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3807: return -ENODEV;
3808:
3809: if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3810: __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3811: else
3812: __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3813:
3814: if (features->type == HID_GENERIC)
3815: /* setup has already been done */
3816: return 0;
3817:
3818: input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3819: __set_bit(BTN_TOUCH, input_dev->keybit);
3820: __set_bit(ABS_MISC, input_dev->absbit);
3821:
3822: input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3823: features->x_max - features->offset_right,
3824: features->x_fuzz, 0);
3825: input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3826: features->y_max - features->offset_bottom,
3827: features->y_fuzz, 0);
3828: input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3829: features->pressure_max, features->pressure_fuzz, 0);
3830:
3831: /* penabled devices have fixed resolution for each model */
3832: input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3833: input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3834:
3835: switch (features->type) {
3836: case GRAPHIRE_BT:
3837: __clear_bit(ABS_MISC, input_dev->absbit);
3838: fallthrough;
3839:
3840: case WACOM_MO:
3841: case WACOM_G4:
3842: input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3843: features->distance_max,
3844: features->distance_fuzz, 0);
3845: fallthrough;
3846:
3847: case GRAPHIRE:
3848: input_set_capability(input_dev, EV_REL, REL_WHEEL);
3849:
3850: __set_bit(BTN_LEFT, input_dev->keybit);
3851: __set_bit(BTN_RIGHT, input_dev->keybit);
3852: __set_bit(BTN_MIDDLE, input_dev->keybit);
3853:
3854: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3855: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3856: __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3857: __set_bit(BTN_STYLUS, input_dev->keybit);
3858: __set_bit(BTN_STYLUS2, input_dev->keybit);
3859: break;
3860:
3861: case WACOM_27QHD:
3862: case WACOM_24HD:
3863: case DTK:
3864: case WACOM_22HD:
3865: case WACOM_21UX2:
3866: case WACOM_BEE:
3867: case CINTIQ:
3868: case WACOM_13HD:
3869: case CINTIQ_HYBRID:
3870: case CINTIQ_COMPANION_2:
3871: input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3872: input_abs_set_res(input_dev, ABS_Z, 287);
3873: wacom_setup_cintiq(wacom_wac);
3874: break;
3875:
3876: case INTUOS3:
3877: case INTUOS3L:
3878: case INTUOS3S:
3879: case INTUOS4:
3880: case INTUOS4WL:
3881: case INTUOS4L:
3882: case INTUOS4S:
3883: input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3884: input_abs_set_res(input_dev, ABS_Z, 287);
3885: fallthrough;
3886:
3887: case INTUOS:
3888: wacom_setup_intuos(wacom_wac);
3889: break;
3890:
3891: case INTUOS5:
3892: case INTUOS5L:
3893: case INTUOSPM:
3894: case INTUOSPL:
3895: case INTUOS5S:
3896: case INTUOSPS:
3897: case INTUOSP2_BT:
3898: case INTUOSP2S_BT:
3899: input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3900: features->distance_max,
3901: features->distance_fuzz, 0);
3902:
3903: input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3904: input_abs_set_res(input_dev, ABS_Z, 287);
3905:
3906: wacom_setup_intuos(wacom_wac);
3907: break;
3908:
3909: case WACOM_24HDT:
3910: case WACOM_27QHDT:
3911: case MTSCREEN:
3912: case MTTPC:
3913: case MTTPC_B:
3914: case TABLETPC2FG:
3915: case TABLETPC:
3916: case TABLETPCE:
3917: __clear_bit(ABS_MISC, input_dev->absbit);
3918: fallthrough;
3919:
3920: case DTUS:
3921: case DTUSX:
3922: case PL:
3923: case DTU:
3924: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3925: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3926: __set_bit(BTN_STYLUS, input_dev->keybit);
3927: __set_bit(BTN_STYLUS2, input_dev->keybit);
3928: break;
3929:
3930: case PTU:
3931: __set_bit(BTN_STYLUS2, input_dev->keybit);
3932: fallthrough;
3933:
3934: case PENPARTNER:
3935: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3936: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3937: __set_bit(BTN_STYLUS, input_dev->keybit);
3938: break;
3939:
3940: case INTUOSHT:
3941: case BAMBOO_PT:
3942: case BAMBOO_PEN:
3943: case INTUOSHT2:
3944: case INTUOSHT3_BT:
3945: if (features->type == INTUOSHT2 ||
3946: features->type == INTUOSHT3_BT) {
3947: wacom_setup_basic_pro_pen(wacom_wac);
3948: } else {
3949: __clear_bit(ABS_MISC, input_dev->absbit);
3950: __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3951: __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3952: __set_bit(BTN_STYLUS, input_dev->keybit);
3953: __set_bit(BTN_STYLUS2, input_dev->keybit);
3954: input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3955: features->distance_max,
3956: features->distance_fuzz, 0);
3957: }
3958: break;
3959: case BAMBOO_PAD:
3960: __clear_bit(ABS_MISC, input_dev->absbit);
3961: break;
3962: }
3963: return 0;
3964: }
SourceFile:drivers/hid/wacom_wac.c]
|
| 211/4 |
2026/09/21 01:14 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 41150
output: 40
thoughts: 289
Thoughts: **Investigating Pen Input Initialization**
Okay, let's dive into this. Line 3806 is the key here. If the `device_type` doesn't include the `WACOM_DEVICETYPE_PEN` flag, `wacom_setup_pen_input_capabilities()` immediately returns `-ENODEV`. That's straightforward enough.
Now, looking at `wacom_setup_inputs()`, the subsequent error handling is what's catching my eye. If `wacom_setup_pen_input_capabilities()` *does* return an error (meaning, no pen detected, presumably), the code explicitly frees `pen_input_dev`, sets `wacom_wac->pen_input` to `NULL`, and sets `pen_input_dev` to `NULL`. The whole pen input struct is nullified. That's the expected behaviour.
But here's where it gets interesting... or maybe concerning. I have to wonder: are there any devices, perhaps those designated as `INTUOSHT2` or a similar type, that *don't* have the `WACOM_DEVICETYPE_PEN` flag set, yet are expected to have some pen functionality? Is there some edge case at play? This demands a deeper look, a wider view. I need to know where `wacom_bpt_irq` is being called, and how it is behaving. This also leads me to investigate `wacom_wac_irq`.
|
| 212/4 |
2026/09/21 01:15 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3461 LineCount:80]
Results: map[Contents:3461: void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
3462: {
3463: bool sync;
3464:
3465: switch (wacom_wac->features.type) {
3466: case PENPARTNER:
3467: sync = wacom_penpartner_irq(wacom_wac);
3468: break;
3469:
3470: case PL:
3471: sync = wacom_pl_irq(wacom_wac);
3472: break;
3473:
3474: case WACOM_G4:
3475: case GRAPHIRE:
3476: case GRAPHIRE_BT:
3477: case WACOM_MO:
3478: sync = wacom_graphire_irq(wacom_wac);
3479: break;
3480:
3481: case PTU:
3482: sync = wacom_ptu_irq(wacom_wac);
3483: break;
3484:
3485: case DTU:
3486: sync = wacom_dtu_irq(wacom_wac);
3487: break;
3488:
3489: case DTUS:
3490: case DTUSX:
3491: sync = wacom_dtus_irq(wacom_wac);
3492: break;
3493:
3494: case INTUOS:
3495: case INTUOS3S:
3496: case INTUOS3:
3497: case INTUOS3L:
3498: case INTUOS4S:
3499: case INTUOS4:
3500: case INTUOS4L:
3501: case CINTIQ:
3502: case WACOM_BEE:
3503: case WACOM_13HD:
3504: case WACOM_21UX2:
3505: case WACOM_22HD:
3506: case WACOM_24HD:
3507: case WACOM_27QHD:
3508: case DTK:
3509: case CINTIQ_HYBRID:
3510: case CINTIQ_COMPANION_2:
3511: sync = wacom_intuos_irq(wacom_wac);
3512: break;
3513:
3514: case INTUOS4WL:
3515: sync = wacom_intuos_bt_irq(wacom_wac, len);
3516: break;
3517:
3518: case WACOM_24HDT:
3519: case WACOM_27QHDT:
3520: sync = wacom_24hdt_irq(wacom_wac);
3521: break;
3522:
3523: case INTUOS5S:
3524: case INTUOS5:
3525: case INTUOS5L:
3526: case INTUOSPS:
3527: case INTUOSPM:
3528: case INTUOSPL:
3529: if (len == WACOM_PKGLEN_BBTOUCH3)
3530: sync = wacom_bpt3_touch(wacom_wac);
3531: else if (wacom_wac->data[0] == WACOM_REPORT_USB)
3532: sync = wacom_status_irq(wacom_wac, len);
3533: else
3534: sync = wacom_intuos_irq(wacom_wac);
3535: break;
3536:
3537: case INTUOSP2_BT:
3538: case INTUOSP2S_BT:
3539: case INTUOSHT3_BT:
3540: sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
]
|
| 213/4 |
2026/09/21 01:15 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 42970
output: 40
thoughts: 27
Thoughts: Okay, here's my interpretation of what's going on in those lines of `wacom_wac_irq`, summarized from my perspective as someone deeply familiar with this kind of kernel code:
**Diving Deep into the `wacom_wac_irq` Interrupt Handler**
Alright, let's get back into this. I need to refresh my memory on what's happening specifically between lines 3541 and 3590 of the `wacom_wac_irq` function. This section is critical, because it's where we handle the interrupt that fires from the Wacom device. A miss here, or slow response, and that touch data or pen pressure gets lost.
I remember this area. We're probably dealing with the core of the data processing β the raw data from the hardware needs to be translated into something usable by the input subsystem. I'll bet we are pulling in the raw data buffer from the device register, checking for errors, and validating the data based on device specific parameters. Hopefully this part is well-commented because I know I wrote some of this, and the details get a bit dense in the interrupt handling routines.
It's likely we're checking for things like the status of the device, if there are any errors like buffer overflows or communication failures, or the type of input received, maybe even the specific device mode like stylus, touch, or eraser. I bet there are checks for validity of the pressure values, coordinates, and proximity data, and then filtering out noise. If something is bad, it will probably call some error handling routine or just drop the packet.
After error checking and validation, the good data will then be fed to the input core, perhaps by calling `input_report_abs` with the appropriate event codes for X, Y, pressure, proximity, etc. I'm guessing there's a good amount of conditional logic in here. Depending on the device, its mode, and the type of data received, we'll need to dispatch to the appropriate input events.
This is a critical part of the interrupt routine, and if I'm remembering right, this section probably touches the hardware directly. So, I need to make sure I understand the memory barriers and any potential race conditions that might be in play. I can't afford any data corruption or missed interrupts at this stage! Time to get to it.
|
| 214/4 |
2026/09/21 01:15 |
tool |
read-file |
0m
Args: map[File:drivers/hid/wacom_wac.c FirstLine:3541 LineCount:50]
Results: map[Contents:3541: break;
3542:
3543: case TABLETPC:
3544: case TABLETPCE:
3545: case TABLETPC2FG:
3546: case MTSCREEN:
3547: case MTTPC:
3548: case MTTPC_B:
3549: sync = wacom_tpc_irq(wacom_wac, len);
3550: break;
3551:
3552: case BAMBOO_PT:
3553: case BAMBOO_PEN:
3554: case BAMBOO_TOUCH:
3555: case INTUOSHT:
3556: case INTUOSHT2:
3557: if (wacom_wac->data[0] == WACOM_REPORT_USB)
3558: sync = wacom_status_irq(wacom_wac, len);
3559: else
3560: sync = wacom_bpt_irq(wacom_wac, len);
3561: break;
3562:
3563: case BAMBOO_PAD:
3564: sync = wacom_bamboo_pad_irq(wacom_wac, len);
3565: break;
3566:
3567: case WIRELESS:
3568: sync = wacom_wireless_irq(wacom_wac, len);
3569: break;
3570:
3571: case REMOTE:
3572: sync = false;
3573: if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
3574: wacom_remote_status_irq(wacom_wac, len);
3575: else
3576: sync = wacom_remote_irq(wacom_wac, len);
3577: break;
3578:
3579: default:
3580: sync = false;
3581: break;
3582: }
3583:
3584: if (sync) {
3585: if (wacom_wac->pen_input)
3586: input_sync(wacom_wac->pen_input);
3587: if (wacom_wac->touch_input)
3588: input_sync(wacom_wac->touch_input);
3589: if (wacom_wac->pad_input)
3590: input_sync(wacom_wac->pad_input);
]
|
| 215/4 |
2026/09/21 01:15 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 44268
output: 31
thoughts: 1005
Thoughts: **Analyzing a Potential Race Condition in Wacom Driver Initialization**
Okay, let's break this down. The user is presenting a potential race condition in the Wacom driver, specifically focusing on the initialization sequence and interrupt handling. My immediate thought is, "Yes, this is *exactly* the kind of timing issue that can be tricky to debug and is likely a good explanation for the crash the user is seeing."
First, the core of the concern revolves around the sequence: `hid_hw_start()`, `wacom_register_inputs()`, potential failure in input registration, and then `hid_hw_stop()`. The crucial point is whether an interrupt (and therefore a report) can arrive *between* `hid_hw_start()` and `hid_hw_stop()`. If this happens, it's possible for `wacom_raw_event()` to be called when `pen_input` is potentially `NULL`.
I'm zeroing in on this path: `wacom_raw_event()` -> `wacom_wac_irq()` -> `wacom_bpt_irq()` -> `wacom_intuos_irq()`. Specifically, the important part being, if `pen_input` is `NULL`, then any calls to `input` in `wacom_intuos_irq` will be faulty.
My mind immediately flags `wacom_bpt_irq()`, because it calls `wacom_intuos_irq()` conditionally. Now, the condition: `(features->type == INTUOSHT2) && (features->device_type & WACOM_DEVICETYPE_PEN)`. This indicates that a certain device type (like an Intuos tablet with pen support) triggers a specific interrupt handling path. And this `wacom_intuos_irq` path is where the potential for null pointer dereference exists.
The user rightly points out that `syzkaller` can easily trigger this scenario by controlling the timing of reports via `/dev/uhid`. That's a huge red flag because it means the problem is reproducible and more than likely exists.
Now, the question is: can a report actually arrive between the `start` and `stop` calls? I need to check the `uhid` code itself. I'm going to look at `drivers/hid/uhid.c` to see precisely what `hid_hw_start()` and `hid_hw_stop()` do in the context of the `uhid` driver. That will tell me if the window is indeed open for a report to come in. This is the crucial step - confirm if the interrupt is actually enabled during this critical initialization phase.
|
| 216/4 |
2026/09/21 01:15 |
tool |
grepper |
0m
Args: map[Expression:uhid_ PathPrefix:drivers/hid/uhid.c]
Results: map[Output:drivers/hid/uhid.c-28-
drivers/hid/uhid.c:29:struct uhid_device {
drivers/hid/uhid.c-30- struct mutex devlock;
--
drivers/hid/uhid.c-47- struct hid_device *hid;
drivers/hid/uhid.c:48: struct uhid_event input_buf;
drivers/hid/uhid.c-49-
--
drivers/hid/uhid.c-53- __u8 tail;
drivers/hid/uhid.c:54: struct uhid_event *outq[UHID_BUFSIZE];
drivers/hid/uhid.c-55-
--
drivers/hid/uhid.c-61- u32 report_type;
drivers/hid/uhid.c:62: struct uhid_event report_buf;
drivers/hid/uhid.c-63- struct work_struct worker;
--
drivers/hid/uhid.c-65-
drivers/hid/uhid.c:66:static struct miscdevice uhid_misc;
drivers/hid/uhid.c-67-
drivers/hid/uhid.c:68:static void uhid_device_add_worker(struct work_struct *work)
drivers/hid/uhid.c-69-{
drivers/hid/uhid.c:70: struct uhid_device *uhid = container_of(work, struct uhid_device, worker);
drivers/hid/uhid.c-71- int ret;
--
drivers/hid/uhid.c-91-
drivers/hid/uhid.c:92:static void uhid_queue(struct uhid_device *uhid, struct uhid_event *ev)
drivers/hid/uhid.c-93-{
--
drivers/hid/uhid.c-107-
drivers/hid/uhid.c:108:static int uhid_queue_event(struct uhid_device *uhid, __u32 event)
drivers/hid/uhid.c-109-{
drivers/hid/uhid.c-110- unsigned long flags;
drivers/hid/uhid.c:111: struct uhid_event *ev;
drivers/hid/uhid.c-112-
--
drivers/hid/uhid.c-119- spin_lock_irqsave(&uhid->qlock, flags);
drivers/hid/uhid.c:120: uhid_queue(uhid, ev);
drivers/hid/uhid.c-121- spin_unlock_irqrestore(&uhid->qlock, flags);
--
drivers/hid/uhid.c-125-
drivers/hid/uhid.c:126:static int uhid_hid_start(struct hid_device *hid)
drivers/hid/uhid.c-127-{
drivers/hid/uhid.c:128: struct uhid_device *uhid = hid->driver_data;
drivers/hid/uhid.c:129: struct uhid_event *ev;
drivers/hid/uhid.c-130- unsigned long flags;
--
drivers/hid/uhid.c-145- spin_lock_irqsave(&uhid->qlock, flags);
drivers/hid/uhid.c:146: uhid_queue(uhid, ev);
drivers/hid/uhid.c-147- spin_unlock_irqrestore(&uhid->qlock, flags);
--
drivers/hid/uhid.c-151-
drivers/hid/uhid.c:152:static void uhid_hid_stop(struct hid_device *hid)
drivers/hid/uhid.c-153-{
drivers/hid/uhid.c:154: struct uhid_device *uhid = hid->driver_data;
drivers/hid/uhid.c-155-
drivers/hid/uhid.c-156- hid->claimed = 0;
drivers/hid/uhid.c:157: uhid_queue_event(uhid, UHID_STOP);
drivers/hid/uhid.c-158-}
drivers/hid/uhid.c-159-
drivers/hid/uhid.c:160:static int uhid_hid_open(struct hid_device *hid)
drivers/hid/uhid.c-161-{
drivers/hid/uhid.c:162: struct uhid_device *uhid = hid->driver_data;
drivers/hid/uhid.c-163-
drivers/hid/uhid.c:164: return uhid_queue_event(uhid, UHID_OPEN);
drivers/hid/uhid.c-165-}
drivers/hid/uhid.c-166-
drivers/hid/uhid.c:167:static void uhid_hid_close(struct hid_device *hid)
drivers/hid/uhid.c-168-{
drivers/hid/uhid.c:169: struct uhid_device *uhid = hid->driver_data;
drivers/hid/uhid.c-170-
drivers/hid/uhid.c:171: uhid_queue_event(uhid, UHID_CLOSE);
drivers/hid/uhid.c-172-}
drivers/hid/uhid.c-173-
drivers/hid/uhid.c:174:static int uhid_hid_parse(struct hid_device *hid)
drivers/hid/uhid.c-175-{
drivers/hid/uhid.c:176: struct uhid_device *uhid = hid->driver_data;
drivers/hid/uhid.c-177-
--
drivers/hid/uhid.c-181-/* must be called with report_lock held */
drivers/hid/uhid.c:182:static int __uhid_report_queue_and_wait(struct uhid_device *uhid,
drivers/hid/uhid.c:183: struct uhid_event *ev,
drivers/hid/uhid.c-184- __u32 *report_id)
--
drivers/hid/uhid.c-192- uhid->report_running = true;
drivers/hid/uhid.c:193: uhid_queue(uhid, ev);
drivers/hid/uhid.c-194- spin_unlock_irqrestore(&uhid->qlock, flags);
--
drivers/hid/uhid.c-210-
drivers/hid/uhid.c:211:static void uhid_report_wake_up(struct uhid_device *uhid, u32 id,
drivers/hid/uhid.c:212: const struct uhid_event *ev)
drivers/hid/uhid.c-213-{
--
drivers/hid/uhid.c-231-
drivers/hid/uhid.c:232:static int uhid_hid_get_report(struct hid_device *hid, unsigned char rnum,
drivers/hid/uhid.c-233- u8 *buf, size_t count, u8 rtype)
drivers/hid/uhid.c-234-{
drivers/hid/uhid.c:235: struct uhid_device *uhid = hid->driver_data;
drivers/hid/uhid.c:236: struct uhid_get_report_reply_req *req;
drivers/hid/uhid.c:237: struct uhid_event *ev;
drivers/hid/uhid.c-238- int ret;
--
drivers/hid/uhid.c-257- /* this _always_ takes ownership of @ev */
drivers/hid/uhid.c:258: ret = __uhid_report_queue_and_wait(uhid, ev, &ev->u.get_report.id);
drivers/hid/uhid.c-259- if (ret)
--
drivers/hid/uhid.c-274-
drivers/hid/uhid.c:275:static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum,
drivers/hid/uhid.c-276- const u8 *buf, size_t count, u8 rtype)
drivers/hid/uhid.c-277-{
drivers/hid/uhid.c:278: struct uhid_device *uhid = hid->driver_data;
drivers/hid/uhid.c:279: struct uhid_event *ev;
drivers/hid/uhid.c-280- int ret;
--
drivers/hid/uhid.c-301- /* this _always_ takes ownership of @ev */
drivers/hid/uhid.c:302: ret = __uhid_report_queue_and_wait(uhid, ev, &ev->u.set_report.id);
drivers/hid/uhid.c-303- if (ret)
--
drivers/hid/uhid.c-315-
drivers/hid/uhid.c:316:static int uhid_hid_raw_request(struct hid_device *hid, unsigned char reportnum,
drivers/hid/uhid.c-317- __u8 *buf, size_t len, unsigned char rtype,
--
drivers/hid/uhid.c-337- case HID_REQ_GET_REPORT:
drivers/hid/uhid.c:338: return uhid_hid_get_report(hid, reportnum, buf, len, u_rtype);
drivers/hid/uhid.c-339- case HID_REQ_SET_REPORT:
drivers/hid/uhid.c:340: return uhid_hid_set_report(hid, reportnum, buf, len, u_rtype);
drivers/hid/uhid.c-341- default:
--
drivers/hid/uhid.c-345-
drivers/hid/uhid.c:346:static int uhid_hid_output_raw(struct hid_device *hid, __u8 *buf, size_t count,
drivers/hid/uhid.c-347- unsigned char report_type)
drivers/hid/uhid.c-348-{
drivers/hid/uhid.c:349: struct uhid_device *uhid = hid->driver_data;
drivers/hid/uhid.c-350- __u8 rtype;
drivers/hid/uhid.c-351- unsigned long flags;
drivers/hid/uhid.c:352: struct uhid_event *ev;
drivers/hid/uhid.c-353-
--
drivers/hid/uhid.c-377- spin_lock_irqsave(&uhid->qlock, flags);
drivers/hid/uhid.c:378: uhid_queue(uhid, ev);
drivers/hid/uhid.c-379- spin_unlock_irqrestore(&uhid->qlock, flags);
--
drivers/hid/uhid.c-383-
drivers/hid/uhid.c:384:static int uhid_hid_output_report(struct hid_device *hid, __u8 *buf,
drivers/hid/uhid.c-385- size_t count)
drivers/hid/uhid.c-386-{
drivers/hid/uhid.c:387: return uhid_hid_output_raw(hid, buf, count, HID_OUTPUT_REPORT);
drivers/hid/uhid.c-388-}
drivers/hid/uhid.c-389-
drivers/hid/uhid.c:390:static const struct hid_ll_driver uhid_hid_driver = {
drivers/hid/uhid.c:391: .start = uhid_hid_start,
drivers/hid/uhid.c:392: .stop = uhid_hid_stop,
drivers/hid/uhid.c:393: .open = uhid_hid_open,
drivers/hid/uhid.c:394: .close = uhid_hid_close,
drivers/hid/uhid.c:395: .parse = uhid_hid_parse,
drivers/hid/uhid.c:396: .raw_request = uhid_hid_raw_request,
drivers/hid/uhid.c:397: .output_report = uhid_hid_output_report,
drivers/hid/uhid.c-398- .max_buffer_size = UHID_DATA_MAX,
--
drivers/hid/uhid.c-403-/* Apparently we haven't stepped on these rakes enough times yet. */
drivers/hid/uhid.c:404:struct uhid_create_req_compat {
drivers/hid/uhid.c-405- __u8 name[128];
--
drivers/hid/uhid.c-418-
drivers/hid/uhid.c:419:static int uhid_event_from_user(const char __user *buffer, size_t len,
drivers/hid/uhid.c:420: struct uhid_event *event)
drivers/hid/uhid.c-421-{
--
drivers/hid/uhid.c-433- */
drivers/hid/uhid.c:434: struct uhid_create_req_compat *compat;
drivers/hid/uhid.c-435-
--
drivers/hid/uhid.c-478-#else
drivers/hid/uhid.c:479:static int uhid_event_from_user(const char __user *buffer, size_t len,
drivers/hid/uhid.c:480: struct uhid_event *event)
drivers/hid/uhid.c-481-{
--
drivers/hid/uhid.c-488-
drivers/hid/uhid.c:489:static int uhid_dev_create2(struct uhid_device *uhid,
drivers/hid/uhid.c:490: const struct uhid_event *ev)
drivers/hid/uhid.c-491-{
--
drivers/hid/uhid.c-523-
drivers/hid/uhid.c:524: hid->ll_driver = &uhid_hid_driver;
drivers/hid/uhid.c-525- hid->bus = ev->u.create2.bus;
--
drivers/hid/uhid.c-530- hid->driver_data = uhid;
drivers/hid/uhid.c:531: hid->dev.parent = uhid_misc.this_device;
drivers/hid/uhid.c-532-
--
drivers/hid/uhid.c-537- * which use feature requests during .probe to work, without they would
drivers/hid/uhid.c:538: * be blocked on devlock, which is held by uhid_char_write.
drivers/hid/uhid.c-539- */
--
drivers/hid/uhid.c-550-
drivers/hid/uhid.c:551:static int uhid_dev_create(struct uhid_device *uhid,
drivers/hid/uhid.c:552: struct uhid_event *ev)
drivers/hid/uhid.c-553-{
drivers/hid/uhid.c:554: struct uhid_create_req orig;
drivers/hid/uhid.c-555-
--
drivers/hid/uhid.c-572-
drivers/hid/uhid.c:573: return uhid_dev_create2(uhid, ev);
drivers/hid/uhid.c-574-}
drivers/hid/uhid.c-575-
drivers/hid/uhid.c:576:static int uhid_dev_destroy(struct uhid_device *uhid)
drivers/hid/uhid.c-577-{
--
drivers/hid/uhid.c-592-
drivers/hid/uhid.c:593:static int uhid_dev_input(struct uhid_device *uhid, struct uhid_event *ev)
drivers/hid/uhid.c-594-{
--
drivers/hid/uhid.c-603-
drivers/hid/uhid.c:604:static int uhid_dev_input2(struct uhid_device *uhid, struct uhid_event *ev)
drivers/hid/uhid.c-605-{
--
drivers/hid/uhid.c-614-
drivers/hid/uhid.c:615:static int uhid_dev_get_report_reply(struct uhid_device *uhid,
drivers/hid/uhid.c:616: struct uhid_event *ev)
drivers/hid/uhid.c-617-{
--
drivers/hid/uhid.c-620-
drivers/hid/uhid.c:621: uhid_report_wake_up(uhid, ev->u.get_report_reply.id, ev);
drivers/hid/uhid.c-622- return 0;
--
drivers/hid/uhid.c-624-
drivers/hid/uhid.c:625:static int uhid_dev_set_report_reply(struct uhid_device *uhid,
drivers/hid/uhid.c:626: struct uhid_event *ev)
drivers/hid/uhid.c-627-{
--
drivers/hid/uhid.c-630-
drivers/hid/uhid.c:631: uhid_report_wake_up(uhid, ev->u.set_report_reply.id, ev);
drivers/hid/uhid.c-632- return 0;
--
drivers/hid/uhid.c-634-
drivers/hid/uhid.c:635:static int uhid_char_open(struct inode *inode, struct file *file)
drivers/hid/uhid.c-636-{
drivers/hid/uhid.c:637: struct uhid_device *uhid;
drivers/hid/uhid.c-638-
--
drivers/hid/uhid.c-648- uhid->running = false;
drivers/hid/uhid.c:649: INIT_WORK(&uhid->worker, uhid_device_add_worker);
drivers/hid/uhid.c-650-
--
drivers/hid/uhid.c-656-
drivers/hid/uhid.c:657:static int uhid_char_release(struct inode *inode, struct file *file)
drivers/hid/uhid.c-658-{
drivers/hid/uhid.c:659: struct uhid_device *uhid = file->private_data;
drivers/hid/uhid.c-660- unsigned int i;
drivers/hid/uhid.c-661-
drivers/hid/uhid.c:662: uhid_dev_destroy(uhid);
drivers/hid/uhid.c-663-
--
drivers/hid/uhid.c-671-
drivers/hid/uhid.c:672:static ssize_t uhid_char_read(struct file *file, char __user *buffer,
drivers/hid/uhid.c-673- size_t count, loff_t *ppos)
drivers/hid/uhid.c-674-{
drivers/hid/uhid.c:675: struct uhid_device *uhid = file->private_data;
drivers/hid/uhid.c-676- int ret;
--
drivers/hid/uhid.c-679-
drivers/hid/uhid.c:680: /* they need at least the "type" member of uhid_event */
drivers/hid/uhid.c-681- if (count < sizeof(__u32))
--
drivers/hid/uhid.c-719-
drivers/hid/uhid.c:720:static ssize_t uhid_char_write(struct file *file, const char __user *buffer,
drivers/hid/uhid.c-721- size_t count, loff_t *ppos)
drivers/hid/uhid.c-722-{
drivers/hid/uhid.c:723: struct uhid_device *uhid = file->private_data;
drivers/hid/uhid.c-724- int ret;
--
drivers/hid/uhid.c-726-
drivers/hid/uhid.c:727: /* we need at least the "type" member of uhid_event */
drivers/hid/uhid.c-728- if (count < sizeof(__u32))
--
drivers/hid/uhid.c-737-
drivers/hid/uhid.c:738: ret = uhid_event_from_user(buffer, len, &uhid->input_buf);
drivers/hid/uhid.c-739- if (ret)
--
drivers/hid/uhid.c-744- /*
drivers/hid/uhid.c:745: * 'struct uhid_create_req' contains a __user pointer which is
drivers/hid/uhid.c-746- * copied from, so it's unsafe to allow this with elevated
--
drivers/hid/uhid.c-754- }
drivers/hid/uhid.c:755: ret = uhid_dev_create(uhid, &uhid->input_buf);
drivers/hid/uhid.c-756- break;
drivers/hid/uhid.c-757- case UHID_CREATE2:
drivers/hid/uhid.c:758: ret = uhid_dev_create2(uhid, &uhid->input_buf);
drivers/hid/uhid.c-759- break;
drivers/hid/uhid.c-760- case UHID_DESTROY:
drivers/hid/uhid.c:761: ret = uhid_dev_destroy(uhid);
drivers/hid/uhid.c-762- break;
drivers/hid/uhid.c-763- case UHID_INPUT:
drivers/hid/uhid.c:764: ret = uhid_dev_input(uhid, &uhid->input_buf);
drivers/hid/uhid.c-765- break;
drivers/hid/uhid.c-766- case UHID_INPUT2:
drivers/hid/uhid.c:767: ret = uhid_dev_input2(uhid, &uhid->input_buf);
drivers/hid/uhid.c-768- break;
drivers/hid/uhid.c-769- case UHID_GET_REPORT_REPLY:
drivers/hid/uhid.c:770: ret = uhid_dev_get_report_reply(uhid, &uhid->input_buf);
drivers/hid/uhid.c-771- break;
drivers/hid/uhid.c-772- case UHID_SET_REPORT_REPLY:
drivers/hid/uhid.c:773: ret = uhid_dev_set_report_reply(uhid, &uhid->input_buf);
drivers/hid/uhid.c-774- break;
--
drivers/hid/uhid.c-785-
drivers/hid/uhid.c:786:static __poll_t uhid_char_poll(struct file *file, poll_table *wait)
drivers/hid/uhid.c-787-{
drivers/hid/uhid.c:788: struct uhid_device *uhid = file->private_data;
drivers/hid/uhid.c-789- __poll_t mask = EPOLLOUT | EPOLLWRNORM; /* uhid is always writable */
--
drivers/hid/uhid.c-798-
drivers/hid/uhid.c:799:static const struct file_operations uhid_fops = {
drivers/hid/uhid.c-800- .owner = THIS_MODULE,
drivers/hid/uhid.c:801: .open = uhid_char_open,
drivers/hid/uhid.c:802: .release = uhid_char_release,
drivers/hid/uhid.c:803: .read = uhid_char_read,
drivers/hid/uhid.c:804: .write = uhid_char_write,
drivers/hid/uhid.c:805: .poll = uhid_char_poll,
drivers/hid/uhid.c-806-};
drivers/hid/uhid.c-807-
drivers/hid/uhid.c:808:static struct miscdevice uhid_misc = {
drivers/hid/uhid.c:809: .fops = &uhid_fops,
drivers/hid/uhid.c-810- .minor = UHID_MINOR,
--
drivers/hid/uhid.c-812-};
drivers/hid/uhid.c:813:module_misc_device(uhid_misc);
drivers/hid/uhid.c-814-
]
|
| 217/4 |
2026/09/21 01:15 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 52368
output: 35
thoughts: 37
Thoughts: Here's my take on those code sections in `drivers/hid/uhid.c`:
**Diving into the `uhid` Driver**
Okay, so I'm focusing in on `uhid_dev_input2` and `uhid_device_add_worker` within the `uhid.c` driver. I need to refresh my memory on how this user-space HID emulation is functioning. My first thought is to understand the event flow. `uhid_dev_input2` is probably handling input reports coming from user space, and I'm guessing `uhid_device_add_worker` is responsible for setting up or initializing devices and their associated worker threads. I want to check how the input data is processed, validated, and translated into the HID report format the kernel expects. Is there proper error handling? Does it deal with quirks and different device capabilities gracefully? It's crucial to ensure this driver is secure and doesn't introduce any vulnerabilities. Specifically, I'm thinking about race conditions, buffer overflows, and input validation exploits β those are the vulnerabilities that concern me most with user-space interaction. I need to pinpoint the critical sections that need the most rigorous scrutiny for potential security flaws. I also want to see if the worker thread handles any asynchronous tasks. Any synchronization primitives used will also be of interest.
|
| 218/4 |
2026/09/21 01:15 |
tool |
read-file |
0m
Args: map[File:drivers/hid/uhid.c FirstLine:68 LineCount:40]
Results: map[Contents: 68: static void uhid_device_add_worker(struct work_struct *work)
69: {
70: struct uhid_device *uhid = container_of(work, struct uhid_device, worker);
71: int ret;
72:
73: ret = hid_add_device(uhid->hid);
74: if (ret) {
75: hid_err(uhid->hid, "Cannot register HID device: error %d\n", ret);
76:
77: /* We used to call hid_destroy_device() here, but that's really
78: * messy to get right because we have to coordinate with
79: * concurrent writes from userspace that might be in the middle
80: * of using uhid->hid.
81: * Just leave uhid->hid as-is for now, and clean it up when
82: * userspace tries to close or reinitialize the uhid instance.
83: *
84: * However, we do have to clear the ->running flag and do a
85: * wakeup to make sure userspace knows that the device is gone.
86: */
87: WRITE_ONCE(uhid->running, false);
88: wake_up_interruptible(&uhid->report_wait);
89: }
90: }
91:
92: static void uhid_queue(struct uhid_device *uhid, struct uhid_event *ev)
93: {
94: __u8 newhead;
95:
96: newhead = (uhid->head + 1) % UHID_BUFSIZE;
97:
98: if (newhead != uhid->tail) {
99: uhid->outq[uhid->head] = ev;
100: uhid->head = newhead;
101: wake_up_interruptible(&uhid->waitq);
102: } else {
103: hid_warn(uhid->hid, "Output queue is full\n");
104: kfree(ev);
105: }
106: }
107:
]
|
| 219/4 |
2026/09/21 01:15 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 53331
output: 36
thoughts: 23
Thoughts: Here's a summary of my initial thoughts, presented as if they were my own:
**Initial Assessment of `uhid_dev_input` and `uhid_dev_input2`**
Alright, let's dive into this. The context clearly points towards an investigation of these two input device drivers β `uhid_dev_input` and `uhid_dev_input2`. Immediately, I'm thinking about the potential differences between them. Is this a versioning situation? Are we looking at refinements or optimizations? Perhaps they handle different device classes or protocols under the HID umbrella?
Given my expertise, I'm already mentally running through the typical points of comparison: initialization routines, interrupt handling, data parsing, error management, and any specific quirks related to the USB HID standard. Are we talking about a standard keyboard/mouse, or something more specialized like a game controller or biometric device? The subtle differences could expose critical aspects of the driver's behaviour. I need to understand the architectural layout. Time to map the connections.
|
| 220/4 |
2026/09/21 01:15 |
tool |
read-file |
0m
Args: map[File:drivers/hid/uhid.c FirstLine:590 LineCount:35]
Results: map[Contents: 590: return 0;
591: }
592:
593: static int uhid_dev_input(struct uhid_device *uhid, struct uhid_event *ev)
594: {
595: if (!READ_ONCE(uhid->running))
596: return -EINVAL;
597:
598: hid_safe_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input.data, UHID_DATA_MAX,
599: min_t(size_t, ev->u.input.size, UHID_DATA_MAX), 0);
600:
601: return 0;
602: }
603:
604: static int uhid_dev_input2(struct uhid_device *uhid, struct uhid_event *ev)
605: {
606: if (!READ_ONCE(uhid->running))
607: return -EINVAL;
608:
609: hid_safe_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input2.data, UHID_DATA_MAX,
610: min_t(size_t, ev->u.input2.size, UHID_DATA_MAX), 0);
611:
612: return 0;
613: }
614:
615: static int uhid_dev_get_report_reply(struct uhid_device *uhid,
616: struct uhid_event *ev)
617: {
618: if (!READ_ONCE(uhid->running))
619: return -EINVAL;
620:
621: uhid_report_wake_up(uhid, ev->u.get_report_reply.id, ev);
622: return 0;
623: }
624:
]
|
| 221/4 |
2026/09/21 01:15 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 54173
output: 29
thoughts: 31
Thoughts: Here's my attempt at summarizing the thought process, as if I were thinking it:
**Digging into the UHID State**
Okay, hold on a second. I need to be absolutely clear about the timing here. When does this `uhid->running` flag actually get set to true? I need to understand the control flow. Let's get right to the source code. I'm going to jump into `uhid.c` and hunt down every instance where the `running` variable, or a similar flag, is being modified or set. I need to see the conditions, the context, everything. No guesswork, straight to the evidence. Let's see how this thing *really* works.
|
| 222/4 |
2026/09/21 01:16 |
tool |
grepper |
0m
Args: map[Expression:running PathPrefix:drivers/hid/uhid.c]
Results: map[Output:drivers/hid/uhid.c=29=struct uhid_device {
--
drivers/hid/uhid.c-37- * holding devlock.
drivers/hid/uhid.c:38: * We guarantee that if @running changes from true to false while you're
drivers/hid/uhid.c-39- * holding @devlock, it's still fine to access @hid.
drivers/hid/uhid.c-40- */
drivers/hid/uhid.c:41: bool running;
drivers/hid/uhid.c-42-
--
drivers/hid/uhid.c-58- wait_queue_head_t report_wait;
drivers/hid/uhid.c:59: bool report_running;
drivers/hid/uhid.c-60- u32 report_id;
--
drivers/hid/uhid.c=68=static void uhid_device_add_worker(struct work_struct *work)
--
drivers/hid/uhid.c-83- *
drivers/hid/uhid.c:84: * However, we do have to clear the ->running flag and do a
drivers/hid/uhid.c-85- * wakeup to make sure userspace knows that the device is gone.
drivers/hid/uhid.c-86- */
drivers/hid/uhid.c:87: WRITE_ONCE(uhid->running, false);
drivers/hid/uhid.c-88- wake_up_interruptible(&uhid->report_wait);
--
drivers/hid/uhid.c=182=static int __uhid_report_queue_and_wait(struct uhid_device *uhid,
--
drivers/hid/uhid.c-191- uhid->report_type = ev->type + 1;
drivers/hid/uhid.c:192: uhid->report_running = true;
drivers/hid/uhid.c-193- uhid_queue(uhid, ev);
--
drivers/hid/uhid.c-196- ret = wait_event_interruptible_timeout(uhid->report_wait,
drivers/hid/uhid.c:197: !uhid->report_running || !READ_ONCE(uhid->running),
drivers/hid/uhid.c-198- 5 * HZ);
drivers/hid/uhid.c:199: if (!ret || !READ_ONCE(uhid->running) || uhid->report_running)
drivers/hid/uhid.c-200- ret = -EIO;
--
drivers/hid/uhid.c-205-
drivers/hid/uhid.c:206: uhid->report_running = false;
drivers/hid/uhid.c-207-
--
drivers/hid/uhid.c=211=static void uhid_report_wake_up(struct uhid_device *uhid, u32 id,
--
drivers/hid/uhid.c-220- goto unlock;
drivers/hid/uhid.c:221: if (!uhid->report_running)
drivers/hid/uhid.c-222- goto unlock;
--
drivers/hid/uhid.c-224- memcpy(&uhid->report_buf, ev, sizeof(*ev));
drivers/hid/uhid.c:225: uhid->report_running = false;
drivers/hid/uhid.c-226- wake_up_interruptible(&uhid->report_wait);
--
drivers/hid/uhid.c=232=static int uhid_hid_get_report(struct hid_device *hid, unsigned char rnum,
--
drivers/hid/uhid.c-239-
drivers/hid/uhid.c:240: if (!READ_ONCE(uhid->running))
drivers/hid/uhid.c-241- return -EIO;
--
drivers/hid/uhid.c=275=static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum,
--
drivers/hid/uhid.c-281-
drivers/hid/uhid.c:282: if (!READ_ONCE(uhid->running) || count > UHID_DATA_MAX)
drivers/hid/uhid.c-283- return -EIO;
--
drivers/hid/uhid.c=489=static int uhid_dev_create2(struct uhid_device *uhid,
--
drivers/hid/uhid.c-533- uhid->hid = hid;
drivers/hid/uhid.c:534: uhid->running = true;
drivers/hid/uhid.c-535-
--
drivers/hid/uhid.c=576=static int uhid_dev_destroy(struct uhid_device *uhid)
--
drivers/hid/uhid.c-580-
drivers/hid/uhid.c:581: WRITE_ONCE(uhid->running, false);
drivers/hid/uhid.c-582- wake_up_interruptible(&uhid->report_wait);
--
drivers/hid/uhid.c=593=static int uhid_dev_input(struct uhid_device *uhid, struct uhid_event *ev)
drivers/hid/uhid.c-594-{
drivers/hid/uhid.c:595: if (!READ_ONCE(uhid->running))
drivers/hid/uhid.c-596- return -EINVAL;
--
drivers/hid/uhid.c=604=static int uhid_dev_input2(struct uhid_device *uhid, struct uhid_event *ev)
drivers/hid/uhid.c-605-{
drivers/hid/uhid.c:606: if (!READ_ONCE(uhid->running))
drivers/hid/uhid.c-607- return -EINVAL;
--
drivers/hid/uhid.c=615=static int uhid_dev_get_report_reply(struct uhid_device *uhid,
--
drivers/hid/uhid.c-617-{
drivers/hid/uhid.c:618: if (!READ_ONCE(uhid->running))
drivers/hid/uhid.c-619- return -EINVAL;
--
drivers/hid/uhid.c=625=static int uhid_dev_set_report_reply(struct uhid_device *uhid,
--
drivers/hid/uhid.c-627-{
drivers/hid/uhid.c:628: if (!READ_ONCE(uhid->running))
drivers/hid/uhid.c-629- return -EINVAL;
--
drivers/hid/uhid.c=635=static int uhid_char_open(struct inode *inode, struct file *file)
--
drivers/hid/uhid.c-647- init_waitqueue_head(&uhid->report_wait);
drivers/hid/uhid.c:648: uhid->running = false;
drivers/hid/uhid.c-649- INIT_WORK(&uhid->worker, uhid_device_add_worker);
]
|
| 223/4 |
2026/09/21 01:16 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 56237
output: 36
thoughts: 50
Thoughts: **Analyzing the UHID Device Creation**
Okay, let's dive into this `uhid_dev_create2` function. My initial observation is key: the `uhid->running = true;` flag gets set *before* the `schedule_work(&uhid->worker);` call. This immediately piques my interest. It implies a specific sequencing and potential race condition implications. Now, let's meticulously dissect the code within `uhid_dev_create2` itself, so I can fully grasp the intent and the specific execution path. I need to be sure I understand the critical section.
|
| 224/4 |
2026/09/21 01:16 |
tool |
read-file |
0m
Args: map[File:drivers/hid/uhid.c FirstLine:520 LineCount:35]
Results: map[Contents: 520: strscpy(hid->phys, ev->u.create2.phys, sizeof(hid->phys));
521: BUILD_BUG_ON(sizeof(hid->uniq) != sizeof(ev->u.create2.uniq));
522: strscpy(hid->uniq, ev->u.create2.uniq, sizeof(hid->uniq));
523:
524: hid->ll_driver = &uhid_hid_driver;
525: hid->bus = ev->u.create2.bus;
526: hid->vendor = ev->u.create2.vendor;
527: hid->product = ev->u.create2.product;
528: hid->version = ev->u.create2.version;
529: hid->country = ev->u.create2.country;
530: hid->driver_data = uhid;
531: hid->dev.parent = uhid_misc.this_device;
532:
533: uhid->hid = hid;
534: uhid->running = true;
535:
536: /* Adding of a HID device is done through a worker, to allow HID drivers
537: * which use feature requests during .probe to work, without they would
538: * be blocked on devlock, which is held by uhid_char_write.
539: */
540: schedule_work(&uhid->worker);
541:
542: return 0;
543:
544: err_free:
545: kfree(uhid->rd_data);
546: uhid->rd_data = NULL;
547: uhid->rd_size = 0;
548: return ret;
549: }
550:
551: static int uhid_dev_create(struct uhid_device *uhid,
552: struct uhid_event *ev)
553: {
554: struct uhid_create_req orig;
]
|
| 225/4 |
2026/09/21 01:16 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 57032
output: 21
thoughts: 180
Thoughts: **My Initial Thoughts on the UHID Device Driver**
Okay, so I'm diving into the `uhid` driver to understand its interaction with userspace, specifically around input reports. Let's see... a userspace program, like Syzkaller, starts by opening `/dev/uhid`. Makes sense. Then, the program issues a `UHID_CREATE2` call, which I know is going to trigger the creation of a `uhid->hid` structure and set a `running` flag to `true`, and of course schedule a worker (`uhid_device_add_worker`) β typical asynchronous setup.
Now, hereβs where it gets interesting. While all this is happening, the userspace program can immediately start firing off `write(fd, UHID_INPUT)` calls. I need to understand what happens on the kernel side when we receive that `UHID_INPUT` command. Ah, right, that's where `uhid_dev_input` comes into play. It appears that the key function within that function is `hid_safe_input_report`. That's where the magic probably happens. So, `hid_safe_input_report` calls `hid_input_report`. Time to look at the implementation of *both* `hid_safe_input_report` and `hid_input_report` and dissect what they're actually doing with that input data and the `uhid->hid` handle. Gotta dig into those reports and see how they are structured and handled!
|
| 226/4 |
2026/09/21 01:16 |
tool |
grepper |
0m
Args: map[Expression:hid_safe_input_report]
Results: map[Output:drivers/hid/hid-core.c=2123=static int __hid_input_report(struct hid_device *hid, enum hid_report_type type,
--
drivers/hid/hid-core.c-2197- * This is data entry for lower layers.
drivers/hid/hid-core.c:2198: * Legacy, please use hid_safe_input_report() instead.
drivers/hid/hid-core.c-2199- */
--
drivers/hid/hid-core.c=2207=EXPORT_SYMBOL_GPL(hid_input_report);
--
drivers/hid/hid-core.c-2209-/**
drivers/hid/hid-core.c:2210: * hid_safe_input_report - report data from lower layer (usb, bt...)
drivers/hid/hid-core.c-2211- *
--
drivers/hid/hid-core.c-2223- */
drivers/hid/hid-core.c:2224:int hid_safe_input_report(struct hid_device *hid, enum hid_report_type type, u8 *data,
drivers/hid/hid-core.c-2225- size_t bufsize, u32 size, int interrupt)
--
drivers/hid/hid-core.c-2230-}
drivers/hid/hid-core.c:2231:EXPORT_SYMBOL_GPL(hid_safe_input_report);
drivers/hid/hid-core.c-2232-
--
drivers/hid/i2c-hid/i2c-hid-core.c=528=static void i2c_hid_get_input(struct i2c_hid *ihid)
--
drivers/hid/i2c-hid/i2c-hid-core.c-580-
drivers/hid/i2c-hid/i2c-hid-core.c:581: hid_safe_input_report(ihid->hid, HID_INPUT_REPORT,
drivers/hid/i2c-hid/i2c-hid-core.c-582- ihid->inbuf + sizeof(__le16),
--
drivers/hid/uhid.c=593=static int uhid_dev_input(struct uhid_device *uhid, struct uhid_event *ev)
--
drivers/hid/uhid.c-597-
drivers/hid/uhid.c:598: hid_safe_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input.data, UHID_DATA_MAX,
drivers/hid/uhid.c-599- min_t(size_t, ev->u.input.size, UHID_DATA_MAX), 0);
--
drivers/hid/uhid.c=604=static int uhid_dev_input2(struct uhid_device *uhid, struct uhid_event *ev)
--
drivers/hid/uhid.c-608-
drivers/hid/uhid.c:609: hid_safe_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input2.data, UHID_DATA_MAX,
drivers/hid/uhid.c-610- min_t(size_t, ev->u.input2.size, UHID_DATA_MAX), 0);
--
drivers/hid/usbhid/hid-core.c=274=static void hid_irq_in(struct urb *urb)
--
drivers/hid/usbhid/hid-core.c-286- if (!test_bit(HID_RESUME_RUNNING, &usbhid->iofl)) {
drivers/hid/usbhid/hid-core.c:287: hid_safe_input_report(urb->context, HID_INPUT_REPORT,
drivers/hid/usbhid/hid-core.c-288- urb->transfer_buffer, urb->transfer_buffer_length,
--
drivers/hid/usbhid/hid-core.c=476=static void hid_ctrl(struct urb *urb)
--
drivers/hid/usbhid/hid-core.c-485- if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN)
drivers/hid/usbhid/hid-core.c:486: hid_safe_input_report(urb->context,
drivers/hid/usbhid/hid-core.c-487- usbhid->ctrl[usbhid->ctrltail].report->type,
--
include/linux/hid.h=1033=int hid_input_report(struct hid_device *hid, enum hid_report_type type, u8 *data, u32 size,
include/linux/hid.h-1034- int interrupt);
include/linux/hid.h:1035:int hid_safe_input_report(struct hid_device *hid, enum hid_report_type type, u8 *data,
include/linux/hid.h-1036- size_t bufsize, u32 size, int interrupt);
]
|
| 227/4 |
2026/09/21 01:16 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 58834
output: 38
thoughts: 34
Thoughts: Okay, let's dive into this. Here's how I'd approach this task, as if these were my internal thoughts:
**Analyzing HID Input Report Handling in hid-core.c**
Alright, time to get my hands dirty. I need to understand the input report handling within the HID subsystem, specifically focusing on how the kernel manages potentially unsafe input reports. The core of this logic, as I recall, lives within `drivers/hid/hid-core.c`. My primary interest lies in the functions that sanitize or validate these reports before they propagate further up the stack.
First up, I'll need to meticulously examine `hid_safe_input_report`. This function is likely the linchpin of safe handling, probably performing the checks that ensure the input data aligns with the expected HID descriptor structure and doesn't introduce any vulnerabilities. I'll need to understand what constitutes a "safe" report in this context β is it based on size, content, or both? Are there any whitelists, blacklists, or other validation mechanisms in place? I will try to see if it makes use of any of the descriptor parsing and handling functions, like `hid_parse_report`, which are very important in this context.
Then, I'll move on to `__hid_input_report`. This function is probably the lower-level function that actually takes the validated data and delivers it to the appropriate event handlers, perhaps after some final processing or transformation. The key here will be understanding how `hid_safe_input_report` protects it. Does it just trust the output of the "safe" function, or does it do additional checks? Are there any race conditions it might be susceptible to? I need to look closely at its interactions with the event layer and think about potential attack vectors. I need to be sure that it is handling errors and reporting invalid reports in an effective and safe manner.
Ultimately, I want to form a complete mental picture of the security posture of the HID input report handling system, and how the interaction between these two functions contributes to it. I want to see if this is a good practice or if there are any risks.
|
| 228/4 |
2026/09/21 01:16 |
tool |
read-file |
0m
Args: map[File:drivers/hid/hid-core.c FirstLine:2120 LineCount:80]
Results: map[Contents:2120: EXPORT_SYMBOL_GPL(hid_report_raw_event);
2121:
2122:
2123: static int __hid_input_report(struct hid_device *hid, enum hid_report_type type,
2124: u8 *data, size_t bufsize, u32 size, int interrupt, u64 source,
2125: bool from_bpf, bool lock_already_taken)
2126: {
2127: struct hid_report_enum *report_enum;
2128: struct hid_driver *hdrv;
2129: struct hid_report *report;
2130: int ret = 0;
2131:
2132: if (!hid)
2133: return -ENODEV;
2134:
2135: ret = down_trylock(&hid->driver_input_lock);
2136: if (lock_already_taken && !ret) {
2137: up(&hid->driver_input_lock);
2138: return -EINVAL;
2139: } else if (!lock_already_taken && ret) {
2140: return -EBUSY;
2141: }
2142:
2143: if (!hid->driver) {
2144: ret = -ENODEV;
2145: goto unlock;
2146: }
2147: report_enum = hid->report_enum + type;
2148: hdrv = hid->driver;
2149:
2150: data = dispatch_hid_bpf_device_event(hid, type, data, &bufsize, &size, interrupt,
2151: source, from_bpf);
2152: if (IS_ERR(data)) {
2153: ret = PTR_ERR(data);
2154: goto unlock;
2155: }
2156:
2157: if (!size) {
2158: dbg_hid("empty report\n");
2159: ret = -1;
2160: goto unlock;
2161: }
2162:
2163: /* Avoid unnecessary overhead if debugfs is disabled */
2164: if (!list_empty(&hid->debug_list))
2165: hid_dump_report(hid, type, data, size);
2166:
2167: report = hid_get_report(report_enum, data);
2168:
2169: if (!report) {
2170: ret = -1;
2171: goto unlock;
2172: }
2173:
2174: if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) {
2175: ret = hdrv->raw_event(hid, report, data, size);
2176: if (ret < 0)
2177: goto unlock;
2178: }
2179:
2180: ret = hid_report_raw_event(hid, type, data, bufsize, size, interrupt);
2181:
2182: unlock:
2183: if (!lock_already_taken)
2184: up(&hid->driver_input_lock);
2185: return ret;
2186: }
2187:
2188: /**
2189: * hid_input_report - report data from lower layer (usb, bt...)
2190: *
2191: * @hid: hid device
2192: * @type: HID report type (HID_*_REPORT)
2193: * @data: report contents
2194: * @size: size of data parameter
2195: * @interrupt: distinguish between interrupt and control transfers
2196: *
2197: * This is data entry for lower layers.
2198: * Legacy, please use hid_safe_input_report() instead.
2199: */
]
|
| 229/4 |
2026/09/21 01:16 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 60478
output: 19
thoughts: 269
Thoughts: **Analyzing `__hid_input_report()`**
Okay, so I'm looking at this `__hid_input_report()` function. Seems pretty standard for handling input reports in the HID subsystem. First thing that jumps out is the device check. Makes sense, ensuring a valid HID device is present before proceeding with any of these operations. Then, it dives into a lock, `driver_input_lock`. A quick `down_trylock` call with some error handling there. This looks like a basic attempt at preventing race conditions. There are a few different cases here, covering the lock being taken and not, and retrying if the try_lock fails. It's a standard pattern, but I'm trying to see if there's anything unusual. Next, a similar check to make sure there's actually a driver attached; that's good practice. Then it gets the report enumeration, and retrieves the report itself with `hid_get_report()`. If the driver has a `raw_event` handler, and the report matches, the data gets passed through that function.
Wait, hold on a second... where *exactly* is `driver_input_lock` taken? I see the attempt to grab it here, but I need to understand the full context. I'm going to need to track down all the calls to this lock in order to understand how this is used, the intended critical section, and to make sure this is actually correct from a concurrency perspective. Let's start searching for usage of that lock.
|
| 230/4 |
2026/09/21 01:17 |
tool |
grepper |
0m
Args: map[Expression:driver_input_lock]
Results: map[Output:drivers/hid/bpf/hid_bpf_dispatch.c=554=hid_bpf_input_report(struct hid_bpf_ctx *ctx, enum hid_report_type type, u8 *buf,
--
drivers/hid/bpf/hid_bpf_dispatch.c-558-
drivers/hid/bpf/hid_bpf_dispatch.c:559: ret = down_interruptible(&ctx->hid->driver_input_lock);
drivers/hid/bpf/hid_bpf_dispatch.c-560- if (ret)
--
drivers/hid/bpf/hid_bpf_dispatch.c-565-
drivers/hid/bpf/hid_bpf_dispatch.c:566: up(&ctx->hid->driver_input_lock);
drivers/hid/bpf/hid_bpf_dispatch.c-567-
--
drivers/hid/hid-asus.c=705=static void asus_kbd_wmi_fan(struct hid_device *hdev, struct hid_raw_event_data *data)
--
drivers/hid/hid-asus.c-732- */
drivers/hid/hid-asus.c:733: down(&hdev->driver_input_lock);
drivers/hid/hid-asus.c-734- hid_report_raw_event(hdev, HID_INPUT_REPORT,
--
drivers/hid/hid-asus.c-736- data->report_size, 1);
drivers/hid/hid-asus.c:737: up(&hdev->driver_input_lock);
drivers/hid/hid-asus.c-738-}
--
drivers/hid/hid-core.c=2123=static int __hid_input_report(struct hid_device *hid, enum hid_report_type type,
--
drivers/hid/hid-core.c-2134-
drivers/hid/hid-core.c:2135: ret = down_trylock(&hid->driver_input_lock);
drivers/hid/hid-core.c-2136- if (lock_already_taken && !ret) {
drivers/hid/hid-core.c:2137: up(&hid->driver_input_lock);
drivers/hid/hid-core.c-2138- return -EINVAL;
--
drivers/hid/hid-core.c-2183- if (!lock_already_taken)
drivers/hid/hid-core.c:2184: up(&hid->driver_input_lock);
drivers/hid/hid-core.c-2185- return ret;
--
drivers/hid/hid-core.c=2865=static int hid_device_probe(struct device *dev)
--
drivers/hid/hid-core.c-2870-
drivers/hid/hid-core.c:2871: if (down_interruptible(&hdev->driver_input_lock))
drivers/hid/hid-core.c-2872- return -EINTR;
--
drivers/hid/hid-core.c-2880- if (!hdev->io_started)
drivers/hid/hid-core.c:2881: up(&hdev->driver_input_lock);
drivers/hid/hid-core.c-2882-
--
drivers/hid/hid-core.c=2886=static void hid_device_remove(struct device *dev)
--
drivers/hid/hid-core.c-2890-
drivers/hid/hid-core.c:2891: down(&hdev->driver_input_lock);
drivers/hid/hid-core.c-2892- hdev->io_started = false;
--
drivers/hid/hid-core.c-2908- if (!hdev->io_started)
drivers/hid/hid-core.c:2909: up(&hdev->driver_input_lock);
drivers/hid/hid-core.c-2910-}
--
drivers/hid/hid-core.c=3084=struct hid_device *hid_allocate_device(void)
--
drivers/hid/hid-core.c-3102- spin_lock_init(&hdev->debug_list_lock);
drivers/hid/hid-core.c:3103: sema_init(&hdev->driver_input_lock, 1);
drivers/hid/hid-core.c-3104- mutex_init(&hdev->ll_open_lock);
--
drivers/hid/hid-debug.c=3654=static int hid_debug_rdesc_show(struct seq_file *f, void *p)
--
drivers/hid/hid-debug.c-3671- /* dump parsed data and input mappings */
drivers/hid/hid-debug.c:3672: if (down_interruptible(&hdev->driver_input_lock))
drivers/hid/hid-debug.c-3673- return 0;
--
drivers/hid/hid-debug.c-3678-
drivers/hid/hid-debug.c:3679: up(&hdev->driver_input_lock);
drivers/hid/hid-debug.c-3680-
--
drivers/hid/hid-magicmouse.c=893=static int magicmouse_probe(struct hid_device *hdev,
--
drivers/hid/hid-magicmouse.c-1007- * Query the Bluetooth Magic Trackpad USB-C battery as done for USB.
drivers/hid/hid-magicmouse.c:1008: * Start io first: probe holds driver_input_lock and the synchronous
drivers/hid/hid-magicmouse.c-1009- * GET_REPORT reply would otherwise be dropped.
--
include/linux/hid.h=674=struct hid_device {
--
include/linux/hid.h-694-
include/linux/hid.h:695: struct semaphore driver_input_lock; /* protects the current driver */
include/linux/hid.h-696- struct device dev; /* device */
--
include/linux/hid.h=1088=static inline void hid_device_io_start(struct hid_device *hid) {
--
include/linux/hid.h-1093- hid->io_started = true;
include/linux/hid.h:1094: up(&hid->driver_input_lock);
include/linux/hid.h-1095-}
--
include/linux/hid.h=1108=static inline void hid_device_io_stop(struct hid_device *hid) {
--
include/linux/hid.h-1113- hid->io_started = false;
include/linux/hid.h:1114: down(&hid->driver_input_lock);
include/linux/hid.h-1115-}
]
|
| 231/4 |
2026/09/21 01:17 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 62838
output: 38
thoughts: 56
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Initial Assessment: A Familiar Territory**
Well, well, well... *look at that*! My eyes immediately gravitated towards `hid_device_probe` within the HID core β specifically, the `hid-core.c` file under the drivers directory. Honestly, this is a familiar area, a vital piece of the puzzle for understanding how HID devices get initialized within the kernel. Time to dig in... I need to refresh myself, there is probably something there worth investigating.
Let's cut right to the heart of the matter and jump straight into lines 2860-2915. I'm already anticipating some of the usual suspects: the device ID matching, resource allocation, and, of course, the ever-so-critical device initialization flow. This section of the probe function likely handles the core device setup. I wonder if there are any recent changes to this code. I should also check the associated debug messages. My expertise allows me to navigate this area efficiently. I'm ready.
|
| 232/4 |
2026/09/21 01:17 |
tool |
read-file |
0m
Args: map[File:drivers/hid/hid-core.c FirstLine:2860 LineCount:60]
Results: map[Contents:2860: }
2861:
2862: return ret;
2863: }
2864:
2865: static int hid_device_probe(struct device *dev)
2866: {
2867: struct hid_device *hdev = to_hid_device(dev);
2868: struct hid_driver *hdrv = to_hid_driver(dev->driver);
2869: int ret = 0;
2870:
2871: if (down_interruptible(&hdev->driver_input_lock))
2872: return -EINTR;
2873:
2874: hdev->io_started = false;
2875: clear_bit(ffs(HID_STAT_REPROBED), &hdev->status);
2876:
2877: if (!hdev->driver)
2878: ret = __hid_device_probe(hdev, hdrv);
2879:
2880: if (!hdev->io_started)
2881: up(&hdev->driver_input_lock);
2882:
2883: return ret;
2884: }
2885:
2886: static void hid_device_remove(struct device *dev)
2887: {
2888: struct hid_device *hdev = to_hid_device(dev);
2889: struct hid_driver *hdrv;
2890:
2891: down(&hdev->driver_input_lock);
2892: hdev->io_started = false;
2893:
2894: hdrv = hdev->driver;
2895: if (hdrv) {
2896: if (hdrv->remove)
2897: hdrv->remove(hdev);
2898: else /* default remove */
2899: hid_hw_stop(hdev);
2900:
2901: /* Release all devres resources allocated by the driver */
2902: devres_release_group(&hdev->dev, hdev->devres_group_id);
2903:
2904: hid_close_report(hdev);
2905: hdev->driver = NULL;
2906: }
2907:
2908: if (!hdev->io_started)
2909: up(&hdev->driver_input_lock);
2910: }
2911:
2912: static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
2913: char *buf)
2914: {
2915: struct hid_device *hdev = container_of(dev, struct hid_device, dev);
2916:
2917: return sysfs_emit(buf, "hid:b%04Xg%04Xv%08Xp%08X\n",
2918: hdev->bus, hdev->group, hdev->vendor, hdev->product);
2919: }
]
|
| 233/4 |
2026/09/21 01:17 |
llm |
codeexpert |
1m
Model:
Error:
|