I'm following this guide on sysfs: https://embetronicx.com/tutorials/linux/device-drivers/sysfs-in-linux-kernel/
If I use kobject_create_and_add
to add a new kobject, the function will fail if the specified kobject already exists.
struct kobject *kobj_ref = kobject_create_and_add("my_object",kernel_kobj);
So I want to know how to get this kobject if it already exists, and create it otherwise.
I assumed that kobject_get
would allow me to do this but it doesn't accept a name and a parent as its arguments in the same way kobject_create_and_add
does, and I'm a little confused on how one would even use it.
struct kobject *kobject_get(struct kobject *kobj);