drivers/hid/hid-generic.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-generic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-generic.c- Extension
.c- Size
- 2187 bytes
- Lines
- 99
- Domain
- Driver Families
- Bucket
- drivers/hid
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/slab.hlinux/kernel.hlinux/unaligned.hasm/byteorder.hlinux/hid.h
Detected Declarations
function __check_hid_genericfunction hid_generic_matchfunction hid_generic_probefunction hid_generic_reset_resume
Annotated Snippet
static int __check_hid_generic(struct device_driver *drv, void *data)
{
struct hid_driver *hdrv = to_hid_driver(drv);
struct hid_device *hdev = data;
if (hdrv == &hid_generic)
return 0;
return hid_match_device(hdev, hdrv) != NULL;
}
static bool hid_generic_match(struct hid_device *hdev,
bool ignore_special_driver)
{
if (ignore_special_driver)
return true;
if (hdev->quirks & HID_QUIRK_IGNORE_SPECIAL_DRIVER)
return true;
if (hdev->quirks & HID_QUIRK_HAVE_SPECIAL_DRIVER)
return false;
/*
* If any other driver wants the device, leave the device to this other
* driver.
*/
if (bus_for_each_drv(&hid_bus_type, NULL, hdev, __check_hid_generic))
return false;
return true;
}
static int hid_generic_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{
int ret;
hdev->quirks |= HID_QUIRK_INPUT_PER_APP;
ret = hid_parse(hdev);
if (ret)
return ret;
return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
}
static int hid_generic_reset_resume(struct hid_device *hdev)
{
if (hdev->claimed & HID_CLAIMED_INPUT)
hidinput_reset_resume(hdev);
return 0;
}
static const struct hid_device_id hid_table[] = {
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, HID_ANY_ID, HID_ANY_ID) },
{ }
};
MODULE_DEVICE_TABLE(hid, hid_table);
static struct hid_driver hid_generic = {
.name = "hid-generic",
.id_table = hid_table,
.match = hid_generic_match,
.probe = hid_generic_probe,
.reset_resume = hid_generic_reset_resume,
};
module_hid_driver(hid_generic);
MODULE_AUTHOR("Henrik Rydberg");
MODULE_DESCRIPTION("HID generic driver");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/kernel.h`, `linux/unaligned.h`, `asm/byteorder.h`, `linux/hid.h`.
- Detected declarations: `function __check_hid_generic`, `function hid_generic_match`, `function hid_generic_probe`, `function hid_generic_reset_resume`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: pattern 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.