mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-01 08:04:22 +08:00
s390/pci: ioremap() align with generic code
Let's use the same signature and parameter names as in the generic ioremap() definition making the physical address' type explicit. Add a check against address wrap around as in the generic lib/ioremap.c:ioremap_prot() code. Finally use free_vm_area() instead of vunmap() as in the generic code. Besides being clearer free_vm_area() can also skip a few additional checks compared with vunmap(). Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> Reviewed-by: Gerald Schaefer <gerald.schaefer@de.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
This commit is contained in:
parent
bc4b295e87
commit
a999eb96fd
@ -26,7 +26,7 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);
|
||||
|
||||
#define IO_SPACE_LIMIT 0
|
||||
|
||||
void __iomem *ioremap(unsigned long offset, unsigned long size);
|
||||
void __iomem *ioremap(phys_addr_t addr, size_t size);
|
||||
void iounmap(volatile void __iomem *addr);
|
||||
|
||||
static inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
|
||||
|
@ -226,28 +226,29 @@ void __iowrite64_copy(void __iomem *to, const void *from, size_t count)
|
||||
zpci_memcpy_toio(to, from, count);
|
||||
}
|
||||
|
||||
void __iomem *ioremap(unsigned long ioaddr, unsigned long size)
|
||||
void __iomem *ioremap(phys_addr_t addr, size_t size)
|
||||
{
|
||||
unsigned long offset, vaddr;
|
||||
struct vm_struct *area;
|
||||
unsigned long offset;
|
||||
phys_addr_t last_addr;
|
||||
|
||||
if (!size)
|
||||
last_addr = addr + size - 1;
|
||||
if (!size || last_addr < addr)
|
||||
return NULL;
|
||||
|
||||
if (!static_branch_unlikely(&have_mio))
|
||||
return (void __iomem *) ioaddr;
|
||||
return (void __iomem *) addr;
|
||||
|
||||
offset = ioaddr & ~PAGE_MASK;
|
||||
ioaddr &= PAGE_MASK;
|
||||
offset = addr & ~PAGE_MASK;
|
||||
addr &= PAGE_MASK;
|
||||
size = PAGE_ALIGN(size + offset);
|
||||
area = get_vm_area(size, VM_IOREMAP);
|
||||
if (!area)
|
||||
return NULL;
|
||||
|
||||
if (ioremap_page_range((unsigned long) area->addr,
|
||||
(unsigned long) area->addr + size,
|
||||
ioaddr, PAGE_KERNEL)) {
|
||||
vunmap(area->addr);
|
||||
vaddr = (unsigned long) area->addr;
|
||||
if (ioremap_page_range(vaddr, vaddr + size, addr, PAGE_KERNEL)) {
|
||||
free_vm_area(area);
|
||||
return NULL;
|
||||
}
|
||||
return (void __iomem *) ((unsigned long) area->addr + offset);
|
||||
|
Loading…
Reference in New Issue
Block a user