title: Unknown symbol error when using sysfs from kernel module
body: <p>Hey,
  I'm trying to play around a with sysfs a little bit, to get some data from user space into my kernel module.
  Here is the code:</p>
  
  <pre><code>#include &lt;linux/kernel.h&gt;
  #include &lt;linux/module.h&gt;
  #include &lt;linux/init.h&gt;
  #include &lt;linux/elf.h&gt;
  #include &lt;linux/fs.h&gt;
  #include &lt;linux/slab.h&gt;
  #include &lt;linux/kobject.h&gt;
  #include &lt;linux/sysfs.h&gt;
  
  #define PRINT(x) printk(KERN_INFO x "\n")
  #define ERROR(fmt,arg...) printk(KERN_ALERT "Error - " fmt,##arg)
  
  
  
  ssize_t mystore (struct kobject *obj,
                      struct attribute *attr, const char *buff, size_t count)
  {
   /* doing a little bit */
          return count;
  }
  
  
  ssize_t myshow (struct kobject *obj, struct attribute *attr, char *buff)
  {
      return 0;
  }
  
  char file_name[] = "myfile";
  static struct attribute myattribute = {
      .name = file_name,
      .mode = S_IRUSR | S_IWUSR
  };
  static struct sysfs_ops mysysfs_ops = {
      .show = myshow,
      .store = mystore
  };
  static struct kobj_type mykobj_type = {
      .sysfs_ops = &amp;mysysfs_ops,
  };
  static struct kobject mykobject = {
      .name = "mykobject",
      .ktype = &amp;mykobj_type
  };
  
  static int __init start(void)
  {
      int tmp;
  
      PRINT("Initializing module\n");
  
      if (kobject_init_and_add(&amp;mykobject, &amp;mykobj_type, NULL, "mykobj") != 0) {
          ERROR ("Digsig key failed to register properly\n");
          return -1;
      }
      if ((tmp = sysfs_create_file(&amp;mykobject, &amp;myattribute)) != 0) {
          ERROR ("Create file failed\n");
          return -1;
      }
      PRINT("INIT CORRECT");
      return 0;
  }
  
  static void __exit close(void)
  {
      PRINT("Deinitializing module\n");
      sysfs_remove_file(&amp;mykobject, &amp;myattribute);
      kobject_del(&amp;mykobject);
  }
  
  module_init(start);
  module_exit(close);
  </code></pre>
  
  <p>When I compile my module, all works fine, but when I try to run it I get a 
  insmod: error inserting 'mytester.ko': -1 Unknown symbol in module</p>
  
  <p>Using dmesg I get more details:</p>
  
  <pre><code>[18335.892462] mytester: Unknown symbol sysfs_remove_file (err 0)
  [18335.892462] mytester: Unknown symbol sysfs_create_file (err 0)
  [18335.892646] mytester: Unknown symbol kobject_init_and_add (err 0)
  </code></pre>
  
  <p>And that's the point. I don't understand this message, because both kobject.h and sysfs.h are included. So I can't really understand what is happening here. Even if I comment out my whole function mystore to a simple return (as shown) the error is the same. So the error is not elsewhere....</p>