diff mbox

ndctl: convenience utilities for 'mapping' objects

Message ID 20151207173642.445.46895.stgit@dwillia2-desk3.jf.intel.com (mailing list archive)
State Accepted
Commit 669c50612f74
Headers show

Commit Message

Dan Williams Dec. 7, 2015, 5:36 p.m. UTC
Add implementations for:

    ndctl_mapping_get_ctx
    ndctl_mapping_get_bus
    ndctl_mapping_get_region

...to allow resolving ancestor objects for a 'mapping'.

Reported-by: Tomasz Rochumski <tomasz.rochumski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 lib/libndctl.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox

Patch

diff --git a/lib/libndctl.c b/lib/libndctl.c
index 6ebb4eb3d3cd..8693fb5268b8 100644
--- a/lib/libndctl.c
+++ b/lib/libndctl.c
@@ -2477,6 +2477,24 @@  NDCTL_EXPORT unsigned long long ndctl_mapping_get_length(struct ndctl_mapping *m
 	return mapping->length;
 }
 
+NDCTL_EXPORT struct ndctl_region *ndctl_mapping_get_region(
+		struct ndctl_mapping *mapping)
+{
+	return mapping->region;
+}
+
+NDCTL_EXPORT struct ndctl_bus *ndctl_mapping_get_bus(
+		struct ndctl_mapping *mapping)
+{
+	return ndctl_mapping_get_region(mapping)->bus;
+}
+
+NDCTL_EXPORT struct ndctl_ctx *ndctl_mapping_get_ctx(
+		struct ndctl_mapping *mapping)
+{
+	return ndctl_mapping_get_bus(mapping)->ctx;
+}
+
 static struct kmod_module *to_module(struct ndctl_ctx *ctx, const char *alias)
 {
 	struct kmod_list *list = NULL;