summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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