October 2017
Intermediate to advanced
586 pages
14h 8m
English
device_register is the function provided by the LDM core to register a device with the bus. After this call, the bus list of drivers is iterated over to find the driver that supports this device, and then this device is added to the bus's list of devices. device_register() internally calls device_add():
int device_add(struct device *dev)
{
[...]
bus_probe_device(dev);
if (parent)
klist_add_tail(&dev->p->knode_parent,
&parent->p->klist_children);
[...]
}
The helper function provided by the kernel to iterate over the bus's list of devices is bus_for_each_dev:
int bus_for_each_dev(struct bus_type * bus,
struct device * start, void * data,
int (*fn)(struct device *, void *));
Whenever a device is added, the core invokes ...