title: What does request_mem_region() actually do and when it is needed?
body: <p>I'm studying on writing embedded linux driver, and decided to fire a few GPIOs to make sure I understand the book <a href="https://static.lwn.net/images/pdf/LDD3/ch09.pdf" rel="nofollow noreferrer">(LDD3, chap9.4.1)</a> correctly.</p>
  <p>I am able to control the correct GPIO pins as intended (making it high and low, I probed with a multimeter); however, I tested 2 pieces of code, one with <code>request_mem_region()</code>, and one without. I'm expecting the one without will fail, but both is working just fine.</p>
  <p>Code with <code>request_mem_region</code>:</p>
  <pre><code>if( request_mem_region( PIN3_CONF_PHYS, MAPPED_SIZE_GPIO_CONF,DEVICE_NAME ) == NULL )
    {
      printk( KERN_ALERT
              &quot;GPIO_140_141_conf_phys error:%s: unable to obtain I/O memory address 0x%08llX\n&quot;,
              DEVICE_NAME, PIN3_CONF_PHYS );
  
      return -EBUSY;
    }
  
  pin3_conf = (u32)ioremap( PIN3_CONF_PHYS, MAPPED_SIZE_GPIO_CONF);
  pin4_conf = (u32)ioremap( PIN4_CONF_PHYS, MAPPED_SIZE_GPIO_CONF);
  pin5_conf = (u32)ioremap( PIN5_CONF_PHYS, MAPPED_SIZE_GPIO_CONF);
  pin6_conf = (u32)ioremap( PIN6_CONF_PHYS, MAPPED_SIZE_GPIO_CONF);
  //-----------------------------------------------------------------
  if( request_mem_region( GPIO_BANK5_PHYS, MAPPED_SIZE_GPIO_5,DEVICE_NAME ) == NULL )
    {
      printk( KERN_ALERT
              &quot;error:%s: unable to obtain I/O memory address 0x%08llX\n&quot;,
              DEVICE_NAME, GPIO_BANK5_PHYS );
   
      return -EBUSY;
    }
      
  gpio_virt = (u32)ioremap( GPIO_BANK5_PHYS, MAPPED_SIZE_GPIO_5 );
  
  //some iowrite32() functions continue...
  </code></pre>
  <p>Code without <code>request_mem_region()</code>:</p>
  <pre><code>pin3_conf = (u32)ioremap( PIN3_CONF_PHYS, MAPPED_SIZE_GPIO_CONF);
  pin4_conf = (u32)ioremap( PIN4_CONF_PHYS, MAPPED_SIZE_GPIO_CONF);
  pin5_conf = (u32)ioremap( PIN5_CONF_PHYS, MAPPED_SIZE_GPIO_CONF);
  pin6_conf = (u32)ioremap( PIN6_CONF_PHYS, MAPPED_SIZE_GPIO_CONF);
  gpio_virt = (u32)ioremap( GPIO_BANK5_PHYS, MAPPED_SIZE_GPIO_5 );
  //some iowrite32() functions continue...
  </code></pre>
  <p>The only difference I can observe from both cases is the result of doing a <code>cat /proc/iomem</code>, the one with <code>request_mem_region()</code> will display an additional line showing <code>49056000-49056097 : GPIO3</code>.</p>
  <p>My question is why <code>request_mem_region()</code> is needed since I can still communicate with the hardware address with only <code>ioremap()</code>? So when do we actually need to use <code>request_mem_region()</code>?</p>
  <p>Thanks for any replies!</p>