drivers/platform/surface/surface_aggregator_cdev.c
Source file repositories/reference/linux-study-clean/drivers/platform/surface/surface_aggregator_cdev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/surface/surface_aggregator_cdev.c- Extension
.c- Size
- 20884 bytes
- Lines
- 809
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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/fs.hlinux/ioctl.hlinux/kernel.hlinux/kfifo.hlinux/kref.hlinux/miscdevice.hlinux/module.hlinux/platform_device.hlinux/poll.hlinux/rwsem.hlinux/slab.hlinux/uaccess.hlinux/vmalloc.hlinux/surface_aggregator/cdev.hlinux/surface_aggregator/controller.hlinux/surface_aggregator/serial_hub.h
Detected Declarations
struct ssam_cdevstruct ssam_cdev_clientstruct ssam_cdev_notifierstruct ssam_cdev_clientenum ssam_cdev_device_statefunction __ssam_cdev_releasefunction ssam_cdev_putfunction ssam_cdev_notifierfunction ssam_cdev_notifier_registerfunction ssam_cdev_notifier_unregisterfunction ssam_cdev_notifier_unregister_allfunction ssam_cdev_requestfunction ssam_cdev_notif_registerfunction ssam_cdev_notif_unregisterfunction ssam_cdev_event_enablefunction ssam_cdev_event_disablefunction ssam_cdev_device_openfunction ssam_cdev_device_releasefunction __ssam_cdev_device_ioctlfunction ssam_cdev_device_ioctlfunction ssam_cdev_readfunction ssam_cdev_pollfunction ssam_cdev_fasyncfunction ssam_dbg_device_probefunction ssam_dbg_device_removefunction ssam_debug_initfunction ssam_debug_exitmodule init ssam_debug_init
Annotated Snippet
static const struct file_operations ssam_controller_fops = {
.owner = THIS_MODULE,
.open = ssam_cdev_device_open,
.release = ssam_cdev_device_release,
.read = ssam_cdev_read,
.poll = ssam_cdev_poll,
.fasync = ssam_cdev_fasync,
.unlocked_ioctl = ssam_cdev_device_ioctl,
.compat_ioctl = ssam_cdev_device_ioctl,
};
/* -- Device and driver setup ----------------------------------------------- */
static int ssam_dbg_device_probe(struct platform_device *pdev)
{
struct ssam_controller *ctrl;
struct ssam_cdev *cdev;
int status;
ctrl = ssam_client_bind(&pdev->dev);
if (IS_ERR(ctrl))
return PTR_ERR(ctrl) == -ENODEV ? -EPROBE_DEFER : PTR_ERR(ctrl);
cdev = kzalloc_obj(*cdev);
if (!cdev)
return -ENOMEM;
kref_init(&cdev->kref);
init_rwsem(&cdev->lock);
cdev->ctrl = ctrl;
cdev->dev = &pdev->dev;
cdev->mdev.parent = &pdev->dev;
cdev->mdev.minor = MISC_DYNAMIC_MINOR;
cdev->mdev.name = "surface_aggregator";
cdev->mdev.nodename = "surface/aggregator";
cdev->mdev.fops = &ssam_controller_fops;
init_rwsem(&cdev->client_lock);
INIT_LIST_HEAD(&cdev->client_list);
status = misc_register(&cdev->mdev);
if (status) {
kfree(cdev);
return status;
}
platform_set_drvdata(pdev, cdev);
return 0;
}
static void ssam_dbg_device_remove(struct platform_device *pdev)
{
struct ssam_cdev *cdev = platform_get_drvdata(pdev);
struct ssam_cdev_client *client;
/*
* Mark device as shut-down. Prevent new clients from being added and
* new operations from being executed.
*/
set_bit(SSAM_CDEV_DEVICE_SHUTDOWN_BIT, &cdev->flags);
down_write(&cdev->client_lock);
/* Remove all notifiers registered by us. */
list_for_each_entry(client, &cdev->client_list, node) {
ssam_cdev_notifier_unregister_all(client);
}
/* Wake up async clients. */
list_for_each_entry(client, &cdev->client_list, node) {
kill_fasync(&client->fasync, SIGIO, POLL_HUP);
}
/* Wake up blocking clients. */
list_for_each_entry(client, &cdev->client_list, node) {
wake_up_interruptible(&client->waitq);
}
up_write(&cdev->client_lock);
/*
* The controller is only guaranteed to be valid for as long as the
* driver is bound. Remove controller so that any lingering open files
* cannot access it any more after we're gone.
*/
down_write(&cdev->lock);
cdev->ctrl = NULL;
cdev->dev = NULL;
Annotation
- Immediate include surface: `linux/fs.h`, `linux/ioctl.h`, `linux/kernel.h`, `linux/kfifo.h`, `linux/kref.h`, `linux/miscdevice.h`, `linux/module.h`, `linux/platform_device.h`.
- Detected declarations: `struct ssam_cdev`, `struct ssam_cdev_client`, `struct ssam_cdev_notifier`, `struct ssam_cdev_client`, `enum ssam_cdev_device_state`, `function __ssam_cdev_release`, `function ssam_cdev_put`, `function ssam_cdev_notifier`, `function ssam_cdev_notifier_register`, `function ssam_cdev_notifier_unregister`.
- Atlas domain: Driver Families / drivers/platform.
- 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.