drivers/hid/intel-ish-hid/ishtp-hid-client.c
Source file repositories/reference/linux-study-clean/drivers/hid/intel-ish-hid/ishtp-hid-client.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/intel-ish-hid/ishtp-hid-client.c- Extension
.c- Size
- 26695 bytes
- Lines
- 960
- Domain
- Driver Families
- Bucket
- drivers/hid
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/hid.hlinux/intel-ish-client-if.hlinux/sched.hishtp-hid.h
Detected Declarations
function report_bad_packetfunction process_recvfunction ish_cl_event_cbfunction hid_ishtp_set_featurefunction hid_ishtp_get_reportfunction ishtp_hid_link_ready_waitfunction ishtp_enum_enum_devicesfunction ishtp_get_hid_descriptorfunction ishtp_get_report_descriptorfunction hid_ishtp_cl_initfunction hid_ishtp_cl_deinitfunction hid_ishtp_cl_reset_handlerfunction hid_ishtp_cl_resume_handlerfunction hid_ishtp_cl_probefunction hid_ishtp_cl_removefunction hid_ishtp_cl_resetfunction hid_ishtp_cl_suspendfunction hid_ishtp_cl_resumefunction ish_hid_initfunction ish_hid_exit
Annotated Snippet
if (cur_pos + sizeof(struct hostif_msg) > total_len) {
dev_err(cl_data_to_dev(client_data),
"[hid-ish]: error, received %u which is less than data header %u\n",
(unsigned int)data_len,
(unsigned int)sizeof(struct hostif_msg_hdr));
++client_data->bad_recv_cnt;
ish_hw_reset(ishtp_get_ishtp_device(hid_ishtp_cl));
break;
}
recv_msg = (struct hostif_msg *)(recv_buf + cur_pos);
payload_len = recv_msg->hdr.size;
/* Sanity checks */
if (cur_pos + payload_len + sizeof(struct hostif_msg) >
total_len) {
++client_data->bad_recv_cnt;
report_bad_packet(hid_ishtp_cl, recv_msg, cur_pos,
payload_len);
ish_hw_reset(ishtp_get_ishtp_device(hid_ishtp_cl));
break;
}
hid_ishtp_trace(client_data, "%s %d\n",
__func__, recv_msg->hdr.command & CMD_MASK);
switch (recv_msg->hdr.command & CMD_MASK) {
case HOSTIF_DM_ENUM_DEVICES:
if ((!(recv_msg->hdr.command & ~CMD_MASK) ||
client_data->init_done)) {
++client_data->bad_recv_cnt;
report_bad_packet(hid_ishtp_cl, recv_msg,
cur_pos,
payload_len);
ish_hw_reset(ishtp_get_ishtp_device(hid_ishtp_cl));
break;
}
client_data->hid_dev_count = (unsigned int)*payload;
if (!client_data->hid_devices)
client_data->hid_devices = devm_kcalloc(
cl_data_to_dev(client_data),
client_data->hid_dev_count,
sizeof(struct device_info),
GFP_KERNEL);
if (!client_data->hid_devices) {
dev_err(cl_data_to_dev(client_data),
"Mem alloc failed for hid device info\n");
wake_up_interruptible(&client_data->init_wait);
break;
}
for (i = 0; i < client_data->hid_dev_count; ++i) {
if (1 + sizeof(struct device_info) * i >=
payload_len) {
dev_err(cl_data_to_dev(client_data),
"[hid-ish]: [ENUM_DEVICES]: content size %zu is bigger than payload_len %zu\n",
1 + sizeof(struct device_info)
* i, payload_len);
}
if (1 + sizeof(struct device_info) * i >=
data_len)
break;
dev_info = (struct device_info *)(payload + 1 +
sizeof(struct device_info) * i);
if (client_data->hid_devices)
memcpy(client_data->hid_devices + i,
dev_info,
sizeof(struct device_info));
}
client_data->enum_devices_done = true;
wake_up_interruptible(&client_data->init_wait);
break;
case HOSTIF_GET_HID_DESCRIPTOR:
if ((!(recv_msg->hdr.command & ~CMD_MASK) ||
client_data->init_done)) {
++client_data->bad_recv_cnt;
report_bad_packet(hid_ishtp_cl, recv_msg,
cur_pos,
payload_len);
ish_hw_reset(ishtp_get_ishtp_device(hid_ishtp_cl));
break;
}
if (!client_data->hid_descr[curr_hid_dev])
client_data->hid_descr[curr_hid_dev] =
devm_kmalloc(cl_data_to_dev(client_data),
payload_len, GFP_KERNEL);
Annotation
- Immediate include surface: `linux/module.h`, `linux/hid.h`, `linux/intel-ish-client-if.h`, `linux/sched.h`, `ishtp-hid.h`.
- Detected declarations: `function report_bad_packet`, `function process_recv`, `function ish_cl_event_cb`, `function hid_ishtp_set_feature`, `function hid_ishtp_get_report`, `function ishtp_hid_link_ready_wait`, `function ishtp_enum_enum_devices`, `function ishtp_get_hid_descriptor`, `function ishtp_get_report_descriptor`, `function hid_ishtp_cl_init`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.