From d43544ef125eac9c7774ea92f69121be05f6a1fe Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 1 Oct 2014 11:20:43 +0200 Subject: nexus: Fix resouce allocation --- rtemsbsd/rtems/rtems-bsd-nexus.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/rtemsbsd/rtems/rtems-bsd-nexus.c b/rtemsbsd/rtems/rtems-bsd-nexus.c index 9c398957..ce8f646b 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 -- cgit v1.2.3