/* NOTE! We need to allow non-page-aligned mappings too: we will obviously have to convert them into an offset in a page-aligned mapping, but the caller shouldn't need to know that small detail.  */
void __iomem* __ioremap_prot(unsigned long phys_addr, unsigned long size, pgprot_t prot)
/* NOTE! We need to allow non-page-aligned mappings too: we will obviously have to convert them into an offset in a page-aligned mapping, but the caller shouldn't need to know that small detail.  */
void __iomem* __ioremap_prot(unsigned long phys_addr, unsigned long size, pgprot_t prot)
{
	void __iomem * addr;
	struct vm_struct * area;
	unsigned long offset, last_addr;
	last_addr = phys_addr + size - 1;
	if (!size || last_addr < phys_addr)
		return NULL;
	offset = phys_addr & ~PAGE_MASK;
	phys_addr &= PAGE_MASK;
	size = PAGE_ALIGN(last_addr+1) - phys_addr;
	area = get_vm_area(size, VM_IOREMAP);
	if (!area)
		return NULL;
	addr = (void __iomem *)area->addr;
	if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
			       phys_addr, prot)) {
		vfree((void __force *)addr);
		return NULL;
	}
	return (void __iomem *) (offset + (char __iomem *)addr);
}