title: Writing a Sysfs module
body: <p>I'm attempting to learn how to write a sysfs module, and am confused at the basic initialization. In <a href="http://lxr.free-electrons.com/source/include/linux/kobject.h?v=3.10#L108" rel="nofollow noreferrer">this</a> document looking at the kobject.h file, there are several different functions related to creating a sysfs entry.</p>
  
  <p>From the looks of it, the function "kobject_init_and_add" seems like the right thing to use, which takes the following:</p>
  
  <pre><code> 90 int kobject_init_and_add(struct kobject *kobj,
   91                          struct kobj_type *ktype, struct kobject *parent,
   92                          const char *fmt, ...);
  </code></pre>
  
  <p>struct kobject and struct kobj_type are straightforward enough, but I don't understand what the *parent kobject and *fmt cstring are supposed to be.</p>
  
  <p>Further, after initializing these objects, I would need to remove them at the exit_module function, but there are two options that seem possible: kobject_del and kobject_puts. What are the differences between these?</p>
  
  <p>Part of my confusion comes from the fact that while googling for the answer, I see tutorials which says to use functions like kobject_register instead, but that function doesn't actually exist. </p>