Adding a kobject to a kset is usually done when the object is created; it is a two-step
process. The kobject’s kset field must be pointed at the kset of interest; then the
kobject should be passed to:
int kobject_add(struct kobject *kobj);
As always, programmers should be aware that this function can fail (in which case it
returns a negative error code) and respond accordingly. There is a convenience func-
tion provided by the kernel:
extern int kobject_register(struct kobject *kobj);

