STRUCT AUXILIARY_DEVICE(9)
π struct auxiliary_device(9) π
okay bestie, welcome to the Kernel API Manual π
. This page is all about struct auxiliary_device β the auxiliary device object, no cap.
β¨ NAME β¨
struct auxiliary_device β auxiliary device object. That's literally the whole name bit π«Ά.
π¦ SYNOPSIS π¦
struct auxiliary_device {
struct device dev;
const char *name;
u32 id;
struct {
struct xarray irqs;
struct mutex lock;
bool irq_dir_exists;
} sysfs;
void *registration_data_rust;
};
π Members π
devβDevice; thereleaseandparentfields of the device structure must be filled in.nameβ match name found by the auxiliary device driver,idβ unique identitier if multiple devices of the same name are exported,sysfsβ embedded struct which hold all sysfs related fields,sysfs.irqsβirqsxarray contains irq indices which are used by the device,sysfs.lockβ synchronize irq sysfs creation,sysfs.irq_dir_existsβ whether"irqs"directory exists,
registration_data_rustβ private data owned by the registering (parent) driver; valid for as long as the device is registered with the driver core,
πΈ Description πΈ
An auxiliary_device represents a part of its parent device's functionality. The way it works: it gets a name that, combined with the registering driver's KBUILD_MODNAME, creates a match_name that's used for driver binding, plus an id that combined with the match_name provides a unique name to register with the bus subsystem. Example time: a driver registering an auxiliary device is named 'foo_mod.ko' and the subdevice is named 'foo_dev'. So the match name is therefore 'foo_mod.foo_dev'. slay.
Registering an auxiliary_device is a three-step process π
First, a 'struct auxiliary_device' needs to be defined or allocated for each sub-device desired. The name, id, dev.release, and dev.parent fields of this structure must be filled in as follows.
The 'name' field is to be given a name that is recognized by the auxiliary driver. If two auxiliary_devices with the same match_name, eg "foo_mod.foo_dev", are registered onto the bus, they must have unique id values (e.g. "x" and "y") so that the registered devices names are "foo_mod.foo_dev.x" and "foo_mod.foo_dev.y". If match_name + id are not unique, then device_add fails and generates an error message. π
The auxiliary_device.dev.type.release or auxiliary_device.dev.release must be populated with a non-NULL pointer to successfully register the auxiliary_device. This release call is where resources associated with the auxiliary device must be free'ed. Because once the device is placed on the bus the parent driver can not tell what other code may have a reference to this data.
The auxiliary_device.dev.parent should be set. Typically to the registering driver's device.
Second, call auxiliary_device_init, which checks several aspects of the auxiliary_device struct and performs a device_initialize. After this step completes, any error state must have a call to auxiliary_device_uninit in its resolution path.
The third and final step in registering an auxiliary_device is to perform a call to auxiliary_device_add, which sets the name of the device and adds the device to the bus. main character energy fr.
#define MY_DEVICE_NAME "foo_dev"
...
struct auxiliary_device *my_aux_dev = my_aux_dev_alloc(xxx);
// Step 1:
my_aux_dev->name = MY_DEVICE_NAME;
my_aux_dev->id = my_unique_id_alloc(xxx);
my_aux_dev->dev.release = my_aux_dev_release;
my_aux_dev->dev.parent = my_dev;
// Step 2:
if (auxiliary_device_init(my_aux_dev))
goto fail;
// Step 3:
if (auxiliary_device_add(my_aux_dev)) {
auxiliary_device_uninit(my_aux_dev);
goto fail;
}
...
Unregistering an auxiliary_device is a two-step process to mirror the register process. First call auxiliary_device_delete, then call auxiliary_device_uninit.
auxiliary_device_delete(my_dev->my_aux_dev);
auxiliary_device_uninit(my_dev->my_aux_dev);
π₯ SEE ALSO π₯
Kernel file ./include/linux/auxiliary_bus.h; also peep DEVICE_LIFESPAN(9), struct auxiliary_driver(9), and module_auxiliary_driver(9) π
This cutie came from ./include/linux, dated October 2026, and it's the struct auxiliary_device(9) page. Bye bestie, go forth and register responsibly π
β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms