[rtems-libbsd commit] nexus: Fix resouce allocation

Sebastian Huber sebh at rtems.org
Wed Oct 8 12:57:37 UTC 2014


Module:    rtems-libbsd
Branch:    master
Commit:    d43544ef125eac9c7774ea92f69121be05f6a1fe
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=d43544ef125eac9c7774ea92f69121be05f6a1fe

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Oct  1 11:20:43 2014 +0200

nexus: Fix resouce allocation

---

 rtemsbsd/rtems/rtems-bsd-nexus.c |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/rtemsbsd/rtems/rtems-bsd-nexus.c b/rtemsbsd/rtems/rtems-bsd-nexus.c
index 9c39895..ce8f646 100644
--- a/rtemsbsd/rtems/rtems-bsd-nexus.c
+++ b/rtemsbsd/rtems/rtems-bsd-nexus.c
@@ -132,7 +132,6 @@ static struct resource *
 nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
     u_long start, u_long end, u_long count, u_int flags)
 {
-	struct resource *rv;
 	struct rman *rm;
 	size_t i;
 
@@ -152,21 +151,23 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
 
 		if (strcmp(device_get_name(child), nd->name) == 0
 		    && device_get_unit(child) == nd->unit) {
-			if (!nexus_get_start(nd, type, &start)) {
-				return (NULL);
+			struct resource *res = NULL;
+
+			if (nexus_get_start(nd, type, &start)) {
+				res = rman_reserve_resource(rm, start, end,
+				    count, flags, child);
+				if (res != NULL) {
+					rman_set_rid(res, *rid);
+					rman_set_bushandle(res,
+					    rman_get_start(res));
+				}
 			};
-		} else {
-			return (NULL);
-		}
-	}
 
-	rv = rman_reserve_resource(rm, start, end, count, flags, child);
-	if (rv != NULL) {
-		rman_set_rid(rv, *rid);
-		rman_set_bushandle(rv, rman_get_start(rv));
+			return (res);
+		}
 	}
 
-	return (rv);
+	return (NULL);
 }
 
 static int



More information about the vc mailing list