LDD3 notes: Driver Model
My notes while reading Linux Device Drivers 3rd edition . 2.6 device model addresses aspects common to all types of devices: Power management Userspace communications /sysfs Hotplugging w/ udev Device classes Object lifecycle Kobject, Kset, Subsystem kobject per object, belongs to a ktype. kset for a collection of kobjects of same type Subsystem as a high-level portion of the kernel as a whole: block, devices, usb, pci Class as high-level view of what a device does Kobject embed struct kobject in your structure initialize name, ktype, kset and parent implement a destructor (release) implement reference counting by wrapping kobject_{get|put} back-cast kobject references to your structure using using container_of() Adding a Kobject to a Kset point kobject.kset to set point kobject.parent to the set kobject_register() Subsystem a kset with a semaphore rooted at the top of the sysfs hierarchy subsystem_{init|register|unregister|get|put} Bus, Device , Driver , Class , Class device Bus as a