Deep inside LDM
Under the hood, the LDM relies on three important structures, which are kobject
, kobj_type
, and kset
. Let us see how each of these structures is involved in the device model.
kobject structure
kobject is the core of the device model, running behind the scenes. It brings an OO-like programming style to the kernel, and is mainly used for reference counting and to expose devices hierarchies and relationships between them. kobjects introduce the concept of encapsulation of common object properties, such as usage reference counts:
struct kobject { const char *name; struct list_head entry; struct kobject *parent; struct kset *kset; struct kobj_type *ktype; struct sysfs_dirent *sd; struct kref kref; /* Fields out of our interest have been removed */ };
name
points to the name of thiskobject
. One can change this using thekobject_set_name(struct kobject *kobj, const char *name)
function.parent
is a pointer to this kobject's parent. It is used...