[PATCH 046/141] staging: unisys: memregion: Use proper errno for mapit()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>

Signed-off-by: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>
Signed-off-by: Benjamin Romer <benjamin.romer@xxxxxxxxxx>
---
 .../staging/unisys/visorutil/memregion_direct.c    | 28 +++++++++++++---------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 93c10b4..7ba68bc 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -32,7 +32,7 @@ struct memregion {
 	BOOL requested;
 };
 
-static BOOL mapit(struct memregion *memregion);
+static int mapit(struct memregion *memregion);
 static void unmapit(struct memregion *memregion);
 
 struct memregion *
@@ -47,7 +47,7 @@ visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes)
 
 	memregion->physaddr = physaddr;
 	memregion->nbytes = nbytes;
-	if (!mapit(memregion)) {
+	if (mapit(memregion)) {
 		rc = NULL;
 		goto cleanup;
 	}
@@ -61,19 +61,24 @@ cleanup:
 }
 EXPORT_SYMBOL_GPL(visor_memregion_create);
 
-static BOOL
+static int
 mapit(struct memregion *memregion)
 {
 	ulong physaddr = (ulong)(memregion->physaddr);
 	ulong nbytes = memregion->nbytes;
 
 	memregion->requested = FALSE;
-	if (request_mem_region(physaddr, nbytes, MYDRVNAME))
-		memregion->requested = TRUE;
+	if (!request_mem_region(physaddr, nbytes, MYDRVNAME))
+		return -EBUSY;
+
+	memregion->requested = TRUE;
 	memregion->mapped = ioremap_cache(physaddr, nbytes);
-	if (!memregion->mapped)
-		return FALSE;
-	return TRUE;
+	if (!memregion->mapped) {
+		memregion->requested = TRUE;
+		return -EFAULT;
+	}
+
+	return 0;
 }
 
 static void
@@ -114,15 +119,16 @@ EXPORT_SYMBOL_GPL(visor_memregion_get_pointer);
 int
 visor_memregion_resize(struct memregion *memregion, ulong newsize)
 {
+	int rc;
+
 	if (newsize == memregion->nbytes)
 		return 0;
 
 	unmapit(memregion);
 	memregion->nbytes = newsize;
-	if (!mapit(memregion))
-		return -EIO;
+	rc = mapit(memregion);
 
-	return 0;
+	return rc;
 }
 EXPORT_SYMBOL_GPL(visor_memregion_resize);
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux