aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Hibbits <jhibbits@FreeBSD.org>2016-02-27 03:35:28 +0000
committerJustin Hibbits <jhibbits@FreeBSD.org>2016-02-27 03:35:28 +0000
commitac6c1372f4ebb24615370e358640100e663f6746 (patch)
tree973001bd07c056ca7c10f23894d1ed692af0e054
parenteff83876b694c469eb9385a3bc106c8f66c72e75 (diff)
downloadsrc-ac6c1372f4ebb24615370e358640100e663f6746.tar.gz
src-ac6c1372f4ebb24615370e358640100e663f6746.zip
Add the bus_alloc_resource_anywhere() convenience function.
Summary: Many instances of bus_alloc_resource() simply use 0 and ~0 for start and end to denote 'anywhere' with a given count. To clean this up, introduce a bus_alloc_resource_anywhere() convenience function. Bump __FreeBSD_version for the new API. Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D5370
Notes
Notes: svn path=/head/; revision=296136
-rw-r--r--share/man/man9/bus_alloc_resource.920
-rw-r--r--sys/sys/bus.h7
-rw-r--r--sys/sys/param.h2
3 files changed, 26 insertions, 3 deletions
diff --git a/share/man/man9/bus_alloc_resource.9 b/share/man/man9/bus_alloc_resource.9
index d579f9a7eee7..92c589d6f81a 100644
--- a/share/man/man9/bus_alloc_resource.9
+++ b/share/man/man9/bus_alloc_resource.9
@@ -34,6 +34,7 @@
.Sh NAME
.Nm bus_alloc_resource ,
.Nm bus_alloc_resource_any
+.Nm bus_alloc_resource_anywhere
.Nd allocate resources from a parent bus
.Sh SYNOPSIS
.In sys/param.h
@@ -49,6 +50,10 @@
.Fc
.Ft struct resource *
.Fn bus_alloc_resource_any "device_t dev" "int type" "int *rid" "u_int flags"
+.Fc
+.Ft struct resource *
+.Fn bus_alloc_resource_anywhere
+.Fa "device_t dev" "int type" "int *rid" "rman_res_t count" "u_int flags"
.Sh DESCRIPTION
This is an easy interface to the resource-management functions.
It hides the indirection through the parent's method table.
@@ -57,9 +62,12 @@ rare cases) never earlier.
.Pp
The
.Fn bus_alloc_resource_any
-function is a convenience wrapper for
+and
+.Fn bus_alloc_resource_anywhere
+functions are convenience wrappers for
.Fn bus_alloc_resource .
-It sets the values for
+.Fn bus_alloc_resource_any
+sets
.Fa start ,
.Fa end ,
and
@@ -67,6 +75,14 @@ and
to the default resource (see description of
.Fa start
below).
+.Fn bus_alloc_resource_anywhere
+sets
+.Fa start
+and
+.Fa end
+to the default resource and uses the provided
+.Fa count
+argument.
.Pp
The arguments are as follows:
.Bl -item
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index 15f5c0674d7d..0e408446f3c6 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -481,6 +481,13 @@ bus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags)
return (bus_alloc_resource(dev, type, rid, 0ul, ~0ul, 1, flags));
}
+static __inline struct resource *
+bus_alloc_resource_anywhere(device_t dev, int type, int *rid,
+ rman_res_t count, u_int flags)
+{
+ return (bus_alloc_resource(dev, type, rid, 0ul, ~0ul, count, flags));
+}
+
/*
* Access functions for device.
*/
diff --git a/sys/sys/param.h b/sys/sys/param.h
index f9b4b280d2bd..65c9cc4a8884 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -58,7 +58,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1100099 /* Master, propagated to newvers */
+#define __FreeBSD_version 1100100 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,