title: Questions about register_chrdev_region() in linux device driver
body: <p>I'm learning about the registration of a kernel module using <code>register_chrdev_region(dev_t from,    unsigned count, const char * name);</code>.</p>
  
  <p>I notice that with or without this function, my kernel module worked as expected. The code I used for testing:</p>
  
  <pre><code>first = MKDEV(MAJOR_NUM, MINOR_NUM);
  register_chrdev_region(first, count, DEVICE_NAME);//&lt;---with and without
  
  mycdev=cdev_alloc();
  mycdev-&gt;ops= &amp;fops;
  mycdev-&gt;owner = THIS_MODULE;
  
  if (cdev_add(mycdev,first, count) == 0)
  {printk(KERN_ALERT "driver loaded\n");}
  </code></pre>
  
  <p>I commented out the line <code>register_chrdev_region(first, count, DEVICE_NAME);</code>, and the <code>printk</code> message still appeared. I tried to communicate with the driver with or without this from user space, and both are successful. </p>
  
  <p>So my question is, is this function <code>register_chrdev_region()</code> only used to make my driver a good kernel citizen, just like telling the others that "I'm using up the major number, please don't use"?</p>
  
  <p>I tried to have a look in the kernel source <code>char_dev.c</code> to understand the function, but I find it too difficult to understand, anyone that's familiar with this? </p>
  
  <p>Thanks!</p>