drivers/base/auxiliary.c
Source file repositories/reference/linux-study-clean/drivers/base/auxiliary.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/auxiliary.c- Extension
.c- Size
- 16735 bytes
- Lines
- 513
- Domain
- Driver Families
- Bucket
- drivers/base
- 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/init.hlinux/slab.hlinux/module.hlinux/pm_domain.hlinux/pm_runtime.hlinux/string.hlinux/auxiliary_bus.hbase.h
Detected Declarations
function auxiliary_matchfunction auxiliary_ueventfunction auxiliary_bus_probefunction auxiliary_bus_removefunction auxiliary_bus_shutdownfunction auxiliary_device_uninitfunction auxiliary_device_initfunction __auxiliary_driver_registerfunction auxiliary_driver_unregisterfunction auxiliary_device_releasefunction auxiliary_device_createfunction dev_is_auxiliaryfunction auxiliary_bus_initexport auxiliary_device_initexport __auxiliary_device_addexport __auxiliary_driver_registerexport auxiliary_driver_unregisterexport auxiliary_device_createexport auxiliary_device_destroyexport __devm_auxiliary_device_createexport dev_is_auxiliary
Annotated Snippet
static int auxiliary_match(struct device *dev, const struct device_driver *drv)
{
struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
const struct auxiliary_driver *auxdrv = to_auxiliary_drv(drv);
return !!auxiliary_match_id(auxdrv->id_table, auxdev);
}
static int auxiliary_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const char *name, *p;
name = dev_name(dev);
p = strrchr(name, '.');
return add_uevent_var(env, "MODALIAS=%s%.*s", AUXILIARY_MODULE_PREFIX,
(int)(p - name), name);
}
static int auxiliary_bus_probe(struct device *dev)
{
const struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
int ret;
ret = dev_pm_domain_attach(dev, PD_FLAG_ATTACH_POWER_ON |
PD_FLAG_DETACH_POWER_OFF);
if (ret) {
dev_warn(dev, "Failed to attach to PM Domain : %d\n", ret);
return ret;
}
return auxdrv->probe(auxdev, auxiliary_match_id(auxdrv->id_table, auxdev));
}
static void auxiliary_bus_remove(struct device *dev)
{
const struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
if (auxdrv->remove)
auxdrv->remove(auxdev);
}
static void auxiliary_bus_shutdown(struct device *dev)
{
const struct auxiliary_driver *auxdrv = NULL;
struct auxiliary_device *auxdev;
if (dev->driver) {
auxdrv = to_auxiliary_drv(dev->driver);
auxdev = to_auxiliary_dev(dev);
}
if (auxdrv && auxdrv->shutdown)
auxdrv->shutdown(auxdev);
}
static const struct bus_type auxiliary_bus_type = {
.name = "auxiliary",
.probe = auxiliary_bus_probe,
.remove = auxiliary_bus_remove,
.shutdown = auxiliary_bus_shutdown,
.match = auxiliary_match,
.uevent = auxiliary_uevent,
};
/**
* auxiliary_device_init - check auxiliary_device and initialize
* @auxdev: auxiliary device struct
*
* This is the second step in the three-step process to register an
* auxiliary_device.
*
* When this function returns an error code, then the device_initialize will
* *not* have been performed, and the caller will be responsible to free any
* memory allocated for the auxiliary_device in the error path directly.
*
* It returns 0 on success. On success, the device_initialize has been
* performed. After this point any error unwinding will need to include a call
* to auxiliary_device_uninit(). In this post-initialize error scenario, a call
* to the device's .release callback will be triggered, and all memory clean-up
* is expected to be handled there.
*/
int auxiliary_device_init(struct auxiliary_device *auxdev)
{
struct device *dev = &auxdev->dev;
if (!dev->parent) {
pr_err("auxiliary_device has a NULL dev->parent\n");
Annotation
- Immediate include surface: `linux/device.h`, `linux/init.h`, `linux/slab.h`, `linux/module.h`, `linux/pm_domain.h`, `linux/pm_runtime.h`, `linux/string.h`, `linux/auxiliary_bus.h`.
- Detected declarations: `function auxiliary_match`, `function auxiliary_uevent`, `function auxiliary_bus_probe`, `function auxiliary_bus_remove`, `function auxiliary_bus_shutdown`, `function auxiliary_device_uninit`, `function auxiliary_device_init`, `function __auxiliary_driver_register`, `function auxiliary_driver_unregister`, `function auxiliary_device_release`.
- Atlas domain: Driver Families / drivers/base.
- 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.