drivers/platform/surface/aggregator/bus.c
Source file repositories/reference/linux-study-clean/drivers/platform/surface/aggregator/bus.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/surface/aggregator/bus.c- Extension
.c- Size
- 16400 bytes
- Lines
- 528
- 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.
- 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/device.hlinux/of.hlinux/property.hlinux/slab.hlinux/surface_aggregator/controller.hlinux/surface_aggregator/device.hbus.hcontroller.h
Detected Declarations
function Copyrightfunction ssam_device_ueventfunction ssam_device_releasefunction ssam_device_allocfunction ssam_device_addfunction ssam_device_removefunction ssam_device_id_compatiblefunction ssam_device_id_is_nullfunction ssam_device_id_matchfunction ssam_device_get_matchfunction ssam_device_get_match_datafunction ssam_bus_matchfunction ssam_bus_probefunction ssam_bus_removefunction __ssam_device_driver_registerfunction ssam_device_driver_unregisterfunction ssam_bus_registerfunction ssam_bus_unregisterfunction ssam_device_uid_from_stringfunction ssam_get_uid_for_nodefunction ssam_add_client_devicefunction __ssam_register_clientsfunction fwnode_for_each_child_nodefunction ssam_remove_devicefunction ssam_remove_clientsexport ssam_device_typeexport ssam_device_allocexport ssam_device_addexport ssam_device_removeexport ssam_device_id_matchexport ssam_device_get_matchexport ssam_device_get_match_dataexport __ssam_device_driver_registerexport ssam_device_driver_unregisterexport __ssam_register_clientsexport ssam_remove_clients
Annotated Snippet
static const struct bus_type ssam_bus_type;
static int ssam_device_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const struct ssam_device *sdev = to_ssam_device(dev);
return add_uevent_var(env, "MODALIAS=ssam:d%02Xc%02Xt%02Xi%02Xf%02X",
sdev->uid.domain, sdev->uid.category,
sdev->uid.target, sdev->uid.instance,
sdev->uid.function);
}
static void ssam_device_release(struct device *dev)
{
struct ssam_device *sdev = to_ssam_device(dev);
ssam_controller_put(sdev->ctrl);
fwnode_handle_put(sdev->dev.fwnode);
kfree(sdev);
}
const struct device_type ssam_device_type = {
.name = "surface_aggregator_device",
.groups = ssam_device_groups,
.uevent = ssam_device_uevent,
.release = ssam_device_release,
};
EXPORT_SYMBOL_GPL(ssam_device_type);
/**
* ssam_device_alloc() - Allocate and initialize a SSAM client device.
* @ctrl: The controller under which the device should be added.
* @uid: The UID of the device to be added.
*
* Allocates and initializes a new client device. The parent of the device
* will be set to the controller device and the name will be set based on the
* UID. Note that the device still has to be added via ssam_device_add().
* Refer to that function for more details.
*
* Return: Returns the newly allocated and initialized SSAM client device, or
* %NULL if it could not be allocated.
*/
struct ssam_device *ssam_device_alloc(struct ssam_controller *ctrl,
struct ssam_device_uid uid)
{
struct ssam_device *sdev;
sdev = kzalloc_obj(*sdev);
if (!sdev)
return NULL;
device_initialize(&sdev->dev);
sdev->dev.bus = &ssam_bus_type;
sdev->dev.type = &ssam_device_type;
sdev->dev.parent = ssam_controller_device(ctrl);
sdev->ctrl = ssam_controller_get(ctrl);
sdev->uid = uid;
dev_set_name(&sdev->dev, "%02x:%02x:%02x:%02x:%02x",
sdev->uid.domain, sdev->uid.category, sdev->uid.target,
sdev->uid.instance, sdev->uid.function);
return sdev;
}
EXPORT_SYMBOL_GPL(ssam_device_alloc);
/**
* ssam_device_add() - Add a SSAM client device.
* @sdev: The SSAM client device to be added.
*
* Added client devices must be guaranteed to always have a valid and active
* controller. Thus, this function will fail with %-ENODEV if the controller
* of the device has not been initialized yet, has been suspended, or has been
* shut down.
*
* The caller of this function should ensure that the corresponding call to
* ssam_device_remove() is issued before the controller is shut down. If the
* added device is a direct child of the controller device (default), it will
* be automatically removed when the controller is shut down.
*
* By default, the controller device will become the parent of the newly
* created client device. The parent may be changed before ssam_device_add is
* called, but care must be taken that a) the correct suspend/resume ordering
* is guaranteed and b) the client device does not outlive the controller,
* i.e. that the device is removed before the controller is being shut down.
* In case these guarantees have to be manually enforced, please refer to the
* ssam_client_link() and ssam_client_bind() functions, which are intended to
* set up device-links for this purpose.
*
* Return: Returns zero on success, a negative error code on failure.
Annotation
- Immediate include surface: `linux/device.h`, `linux/of.h`, `linux/property.h`, `linux/slab.h`, `linux/surface_aggregator/controller.h`, `linux/surface_aggregator/device.h`, `bus.h`, `controller.h`.
- Detected declarations: `function Copyright`, `function ssam_device_uevent`, `function ssam_device_release`, `function ssam_device_alloc`, `function ssam_device_add`, `function ssam_device_remove`, `function ssam_device_id_compatible`, `function ssam_device_id_is_null`, `function ssam_device_id_match`, `function ssam_device_get_match`.
- Atlas domain: Driver Families / drivers/platform.
- 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.