drivers/slimbus/core.c
Source file repositories/reference/linux-study-clean/drivers/slimbus/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/slimbus/core.c- Extension
.c- Size
- 13076 bytes
- Lines
- 548
- Domain
- Driver Families
- Bucket
- drivers/slimbus
- 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.
- 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/kernel.hlinux/errno.hlinux/slab.hlinux/init.hlinux/idr.hlinux/of.hlinux/of_device.hlinux/pm_runtime.hlinux/slimbus.hslimbus.h
Detected Declarations
function slim_device_matchfunction slim_device_update_statusfunction slim_device_probefunction slim_device_removefunction slim_device_ueventfunction __slim_driver_registerfunction slim_driver_unregisterfunction slim_dev_releasefunction slim_add_devicefunction of_register_slim_devicesfunction for_each_child_of_nodefunction slim_register_controllerfunction slim_remove_devicefunction slim_ctrl_remove_devicefunction slim_unregister_controllerfunction slim_report_absentfunction slim_eaddr_equalfunction slim_match_devfunction slim_get_devicefunction of_slim_get_devicefunction slim_device_alloc_laddrfunction slim_device_report_presentfunction slim_get_logical_addrfunction slimbus_exitfunction slimbus_initexport slimbus_busexport __slim_driver_registerexport slim_driver_unregisterexport slim_register_controllerexport slim_unregister_controllerexport slim_report_absentexport slim_get_deviceexport of_slim_get_deviceexport slim_device_report_presentexport slim_get_logical_addr
Annotated Snippet
static int slim_device_match(struct device *dev, const struct device_driver *drv)
{
struct slim_device *sbdev = to_slim_device(dev);
const struct slim_driver *sbdrv = to_slim_driver(drv);
/* Attempt an OF style match first */
if (of_driver_match_device(dev, drv))
return 1;
return !!slim_match(sbdrv->id_table, sbdev);
}
static void slim_device_update_status(struct slim_device *sbdev,
enum slim_device_status status)
{
struct slim_driver *sbdrv;
if (sbdev->status == status)
return;
sbdev->status = status;
if (!sbdev->dev.driver)
return;
sbdrv = to_slim_driver(sbdev->dev.driver);
if (sbdrv->device_status)
sbdrv->device_status(sbdev, sbdev->status);
}
static int slim_device_probe(struct device *dev)
{
struct slim_device *sbdev = to_slim_device(dev);
struct slim_driver *sbdrv = to_slim_driver(dev->driver);
int ret;
ret = sbdrv->probe(sbdev);
if (ret)
return ret;
/* try getting the logical address after probe */
ret = slim_get_logical_addr(sbdev);
if (!ret) {
slim_device_update_status(sbdev, SLIM_DEVICE_STATUS_UP);
} else {
dev_err(&sbdev->dev, "Failed to get logical address\n");
ret = -EPROBE_DEFER;
}
return ret;
}
static void slim_device_remove(struct device *dev)
{
struct slim_device *sbdev = to_slim_device(dev);
struct slim_driver *sbdrv;
if (dev->driver) {
sbdrv = to_slim_driver(dev->driver);
if (sbdrv->remove)
sbdrv->remove(sbdev);
}
}
static int slim_device_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const struct slim_device *sbdev = to_slim_device(dev);
return add_uevent_var(env, "MODALIAS=slim:%s", dev_name(&sbdev->dev));
}
const struct bus_type slimbus_bus = {
.name = "slimbus",
.match = slim_device_match,
.probe = slim_device_probe,
.remove = slim_device_remove,
.uevent = slim_device_uevent,
};
EXPORT_SYMBOL_GPL(slimbus_bus);
/*
* __slim_driver_register() - Client driver registration with SLIMbus
*
* @drv:Client driver to be associated with client-device.
* @owner: owning module/driver
*
* This API will register the client driver with the SLIMbus
* It is called from the driver's module-init function.
*/
int __slim_driver_register(struct slim_driver *drv, struct module *owner)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/slab.h`, `linux/init.h`, `linux/idr.h`, `linux/of.h`, `linux/of_device.h`, `linux/pm_runtime.h`.
- Detected declarations: `function slim_device_match`, `function slim_device_update_status`, `function slim_device_probe`, `function slim_device_remove`, `function slim_device_uevent`, `function __slim_driver_register`, `function slim_driver_unregister`, `function slim_dev_release`, `function slim_add_device`, `function of_register_slim_devices`.
- Atlas domain: Driver Families / drivers/slimbus.
- Implementation status: pattern implementation candidate.
- 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.