FreeBSD/sys/kern/subr_bus.c
/*
 * Some convenience functions to make it easier for drivers to use the
 * resource-management functions.  All these really do is hide the
 * indirection through the parent's method table, making for slightly
 * less-wordy code.  In the future, it might make sense for this code
 * to maintain some sort of a list of resources allocated by each device.
 */
Some convenience functions to make it easier for drivers to use the
resource-management functions.  All these really do is hide the
indirection through the parent's method table, making for slightly
less-wordy code.  In the future, it might make sense for this code
to maintain some sort of a list of resources allocated by each device.
Some convenience functions to make it easier for drivers to use the resource - management functions . All these really do is hide the indirection through the parent ' s method table making for slightly less - wordy code . In the future it might make sense for this code to maintain some sort of a list of resources allocated by each device .
int
bus_alloc_resources(device_t dev, struct resource_spec *rs,
    struct resource **res)
{
	int i;
	for (i = 0; rs[i].type != -1; i++)
		res[i] = NULL;
	for (i = 0; rs[i].type != -1; i++) {
		res[i] = bus_alloc_resource_any(dev,
		    rs[i].type, &rs[i].rid, rs[i].flags);
		if (res[i] == NULL && !(rs[i].flags & RF_OPTIONAL)) {
			bus_release_resources(dev, rs, res);
			return (ENXIO);
		}
	}
	return (0);
}
int bus_alloc_resources ( device_t dev , struct resource_spec * rs , struct resource * * res ) { int i ; for ( i = 0 ; rs [ i ] . type != -1 ; i ++ ) res [ i ] = NULL ; for ( i = 0 ; rs [ i ] . type != -1 ; i ++ ) { res [ i ] = bus_alloc_resource_any ( dev , rs [ i ] . type , & rs [ i ] . rid , rs [ i ] . flags ) ; if ( res [ i ] == NULL && ! ( rs [ i ] . flags & RF_OPTIONAL ) ) { bus_release_resources ( dev , rs , res ) ; return ( ENXIO ) ; } } return ( 0 ) ; }
Some convenience functions to make it easier for drivers to use the
 resource-management functions.
Some convenience functions to make it easier for drivers to use the resource - management functions .