summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2005-04-12 15:20:36 +0000
committerimp <imp@FreeBSD.org>2005-04-12 15:20:36 +0000
commita404b5c683f61145c45d4eff583ed72f34d0db29 (patch)
treeb356fb795a860c64d46e69adfa9a3f1dd7ef94f9
parent9221188604a55095a57f3a21a7fcfd43983e8bcf (diff)
downloadFreeBSD-src-a404b5c683f61145c45d4eff583ed72f34d0db29.zip
FreeBSD-src-a404b5c683f61145c45d4eff583ed72f34d0db29.tar.gz
resource_list_purge: release the resources in this list, and purge the
elements of this list (eg, reset it). Man page to follow
-rw-r--r--sys/kern/subr_bus.c21
-rw-r--r--sys/sys/bus.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index c08d66b..531eaf9 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -2805,6 +2805,27 @@ resource_list_print_type(struct resource_list *rl, const char *name, int type,
}
/**
+ * @brief Releases all the resources in a list.
+ *
+ * @param rl The resource list to purge.
+ *
+ * @returns nothing
+ */
+void
+resource_list_purge(struct resource_list *rl)
+{
+ struct resource_list_entry *rle;
+
+ STAILQ_FOREACH(rle, rl, link) {
+ if (rle->res)
+ bus_release_resource(rman_get_device(rle->res),
+ rle->type, rle->rid, rle->res);
+ STAILQ_REMOVE_HEAD(rl, link);
+ free(rle, M_BUS);
+ }
+}
+
+/**
* @brief Helper function for implementing DEVICE_PROBE()
*
* This function can be used to help implement the DEVICE_PROBE() for
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index 6a54a72..b811b14 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -227,6 +227,7 @@ struct resource *
int resource_list_release(struct resource_list *rl,
device_t bus, device_t child,
int type, int rid, struct resource *res);
+void resource_list_purge(struct resource_list *rl);
int resource_list_print_type(struct resource_list *rl,
const char *name, int type,
const char *format);
OpenPOWER on IntegriCloud