title: how is the correct way to use copy_from_user?
body: <p>I am trying to copy a value from user space to kernel space with the function:</p>
  
  <pre><code>static ssize_t device_write(struct file *filp, const char *buff, size_t len, loff_t  *off) 
  {
  
      unsigned long copy=0;
      int desp=0; 
  
      copy = copy_from_user(&amp;desp, &amp;len, 4);  
  
      printk(KERN_ALERT "copy: %lx\n", copy);      
      printk(KERN_ALERT "desp: %d\n", desp);
  }
  </code></pre>
  
  <p>where "len" is the variable that exists in the user space, and I want to copy it to "desp" in the kernel space</p>
  
  <p>the function call I make from the user space is (write is device_write according to file_operations struct):</p>
  
  <pre><code> write (fd,buffer,8, &amp;off);
  </code></pre>
  
  <p>when I print the value that should be stored in "desp" is always 0 (should be 8).
  What is the problem in my code? I've been seeing several examples and I implemented many variations but none works.</p>