subr_bus.c (150265) | subr_bus.c (150521) |
---|---|
1/*- 2 * Copyright (c) 1997,1998,2003 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997,1998,2003 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/kern/subr_bus.c 150265 2005-09-18 01:32:09Z imp $"); | 28__FBSDID("$FreeBSD: head/sys/kern/subr_bus.c 150521 2005-09-24 19:31:10Z phk $"); |
29 30#include "opt_bus.h" 31 32#include <sys/param.h> 33#include <sys/conf.h> 34#include <sys/filio.h> 35#include <sys/lock.h> 36#include <sys/kernel.h> --- 3279 unchanged lines hidden (view full) --- 3316/* 3317 * Some convenience functions to make it easier for drivers to use the 3318 * resource-management functions. All these really do is hide the 3319 * indirection through the parent's method table, making for slightly 3320 * less-wordy code. In the future, it might make sense for this code 3321 * to maintain some sort of a list of resources allocated by each device. 3322 */ 3323 | 29 30#include "opt_bus.h" 31 32#include <sys/param.h> 33#include <sys/conf.h> 34#include <sys/filio.h> 35#include <sys/lock.h> 36#include <sys/kernel.h> --- 3279 unchanged lines hidden (view full) --- 3316/* 3317 * Some convenience functions to make it easier for drivers to use the 3318 * resource-management functions. All these really do is hide the 3319 * indirection through the parent's method table, making for slightly 3320 * less-wordy code. In the future, it might make sense for this code 3321 * to maintain some sort of a list of resources allocated by each device. 3322 */ 3323 |
3324int 3325bus_alloc_resources(device_t dev, struct resource_spec *rs, 3326 struct resource **res) 3327{ 3328 int i; 3329 3330 for (i = 0; rs[i].type != -1; i++) 3331 res[i] = NULL; 3332 for (i = 0; rs[i].type != -1; i++) { 3333 res[i] = bus_alloc_resource_any(dev, 3334 rs[i].type, &rs[i].rid, rs[i].flags); 3335 if (res[i] == NULL && !(rs[i].flags & RF_OPTIONAL)) { 3336 bus_release_resources(dev, rs, res); 3337 return (ENXIO); 3338 } 3339 } 3340 return (0); 3341} 3342 3343void 3344bus_release_resources(device_t dev, struct resource_spec *rs, 3345 struct resource **res) 3346{ 3347 int i; 3348 3349 for (i = 0; rs[i].type != -1; i++) 3350 if (res[i] != NULL) 3351 bus_release_resource( 3352 dev, rs[i].type, rs[i].rid, res[i]); 3353} 3354 |
|
3324/** 3325 * @brief Wrapper function for BUS_ALLOC_RESOURCE(). 3326 * 3327 * This function simply calls the BUS_ALLOC_RESOURCE() method of the 3328 * parent of @p dev. 3329 */ 3330struct resource * 3331bus_alloc_resource(device_t dev, int type, int *rid, u_long start, u_long end, --- 670 unchanged lines hidden --- | 3355/** 3356 * @brief Wrapper function for BUS_ALLOC_RESOURCE(). 3357 * 3358 * This function simply calls the BUS_ALLOC_RESOURCE() method of the 3359 * parent of @p dev. 3360 */ 3361struct resource * 3362bus_alloc_resource(device_t dev, int type, int *rid, u_long start, u_long end, --- 670 unchanged lines hidden --- |