Commit 1bd14f37 authored by Jes Sorensen's avatar Jes Sorensen Committed by Greg Kroah-Hartman

staging: unisys: memregion: Use proper errno for mapit()

Signed-off-by: default avatarJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: default avatarBenjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 670f56ca
...@@ -32,7 +32,7 @@ struct memregion { ...@@ -32,7 +32,7 @@ struct memregion {
BOOL requested; BOOL requested;
}; };
static BOOL mapit(struct memregion *memregion); static int mapit(struct memregion *memregion);
static void unmapit(struct memregion *memregion); static void unmapit(struct memregion *memregion);
struct memregion * struct memregion *
...@@ -47,7 +47,7 @@ visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes) ...@@ -47,7 +47,7 @@ visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes)
memregion->physaddr = physaddr; memregion->physaddr = physaddr;
memregion->nbytes = nbytes; memregion->nbytes = nbytes;
if (!mapit(memregion)) { if (mapit(memregion)) {
rc = NULL; rc = NULL;
goto cleanup; goto cleanup;
} }
...@@ -61,19 +61,24 @@ visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes) ...@@ -61,19 +61,24 @@ visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes)
} }
EXPORT_SYMBOL_GPL(visor_memregion_create); EXPORT_SYMBOL_GPL(visor_memregion_create);
static BOOL static int
mapit(struct memregion *memregion) mapit(struct memregion *memregion)
{ {
ulong physaddr = (ulong)(memregion->physaddr); ulong physaddr = (ulong)(memregion->physaddr);
ulong nbytes = memregion->nbytes; ulong nbytes = memregion->nbytes;
memregion->requested = FALSE; memregion->requested = FALSE;
if (request_mem_region(physaddr, nbytes, MYDRVNAME)) if (!request_mem_region(physaddr, nbytes, MYDRVNAME))
return -EBUSY;
memregion->requested = TRUE; memregion->requested = TRUE;
memregion->mapped = ioremap_cache(physaddr, nbytes); memregion->mapped = ioremap_cache(physaddr, nbytes);
if (!memregion->mapped) if (!memregion->mapped) {
return FALSE; memregion->requested = TRUE;
return TRUE; return -EFAULT;
}
return 0;
} }
static void static void
...@@ -114,15 +119,16 @@ EXPORT_SYMBOL_GPL(visor_memregion_get_pointer); ...@@ -114,15 +119,16 @@ EXPORT_SYMBOL_GPL(visor_memregion_get_pointer);
int int
visor_memregion_resize(struct memregion *memregion, ulong newsize) visor_memregion_resize(struct memregion *memregion, ulong newsize)
{ {
int rc;
if (newsize == memregion->nbytes) if (newsize == memregion->nbytes)
return 0; return 0;
unmapit(memregion); unmapit(memregion);
memregion->nbytes = newsize; memregion->nbytes = newsize;
if (!mapit(memregion)) rc = mapit(memregion);
return -EIO;
return 0; return rc;
} }
EXPORT_SYMBOL_GPL(visor_memregion_resize); EXPORT_SYMBOL_GPL(visor_memregion_resize);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment