drivers/macintosh/adb.c
Source file repositories/reference/linux-study-clean/drivers/macintosh/adb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/macintosh/adb.c- Extension
.c- Size
- 20307 bytes
- Lines
- 899
- Domain
- Driver Families
- Bucket
- drivers/macintosh
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/types.hlinux/errno.hlinux/kernel.hlinux/slab.hlinux/module.hlinux/fs.hlinux/mm.hlinux/sched/signal.hlinux/adb.hlinux/cuda.hlinux/pmu.hlinux/notifier.hlinux/wait.hlinux/init.hlinux/delay.hlinux/spinlock.hlinux/completion.hlinux/device.hlinux/kthread.hlinux/platform_device.hlinux/mutex.hlinux/of.hlinux/uaccess.hasm/machdep.h
Detected Declarations
struct adbdev_statefunction printADBreplyfunction adb_scan_busfunction adb_probe_taskfunction __adb_probe_taskfunction adb_reset_busfunction __adb_suspendfunction adb_suspendfunction adb_freezefunction adb_powerofffunction __adb_resumefunction adb_resumefunction adb_initfunction do_adb_reset_busfunction adb_pollfunction adb_sync_req_donefunction adb_requestfunction adb_registerfunction adb_unregisterfunction adb_inputfunction try_handler_changefunction adb_try_handler_changefunction adb_get_infosfunction adb_write_donefunction do_adb_queryfunction adb_openfunction adb_releasefunction adb_readfunction adb_writefunction adb_dummy_probefunction adbdev_initmodule init adb_initexport adb_client_listexport adb_pollexport adb_requestexport adb_registerexport adb_unregisterexport adb_try_handler_change
Annotated Snippet
static const struct file_operations adb_fops = {
.owner = THIS_MODULE,
.read = adb_read,
.write = adb_write,
.open = adb_open,
.release = adb_release,
};
#ifdef CONFIG_PM
static const struct dev_pm_ops adb_dev_pm_ops = {
.suspend = adb_suspend,
.resume = adb_resume,
/* Hibernate hooks */
.freeze = adb_freeze,
.thaw = adb_resume,
.poweroff = adb_poweroff,
.restore = adb_resume,
};
#endif
static struct platform_driver adb_pfdrv = {
.driver = {
.name = "adb",
#ifdef CONFIG_PM
.pm = &adb_dev_pm_ops,
#endif
},
};
static struct platform_device adb_pfdev = {
.name = "adb",
};
static int __init
adb_dummy_probe(struct platform_device *dev)
{
if (dev == &adb_pfdev)
return 0;
return -ENODEV;
}
static void __init
adbdev_init(void)
{
if (register_chrdev(ADB_MAJOR, "adb", &adb_fops)) {
pr_err("adb: unable to get major %d\n", ADB_MAJOR);
return;
}
if (class_register(&adb_dev_class))
return;
device_create(&adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
platform_device_register(&adb_pfdev);
platform_driver_probe(&adb_pfdrv, adb_dummy_probe);
}
Annotation
- Immediate include surface: `linux/types.h`, `linux/errno.h`, `linux/kernel.h`, `linux/slab.h`, `linux/module.h`, `linux/fs.h`, `linux/mm.h`, `linux/sched/signal.h`.
- Detected declarations: `struct adbdev_state`, `function printADBreply`, `function adb_scan_bus`, `function adb_probe_task`, `function __adb_probe_task`, `function adb_reset_bus`, `function __adb_suspend`, `function adb_suspend`, `function adb_freeze`, `function adb_poweroff`.
- Atlas domain: Driver Families / drivers/macintosh.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.