diff mbox

[ndctl] ndctl: allow bus device names as a filter option

Message ID 150052625182.6153.8007089681147602446.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit b864641e55c5
Headers show

Commit Message

Dan Williams July 20, 2017, 4:50 a.m. UTC
For example, allow:

    ndctl list -b ndbus0

...in addition to the existing provider based method:

    ndctl list -b ACPI.NFIT

...or the id based method:

    ndctl list -b 0

Cc: Vishal Verma <vishal.l.verma@intel.com>
Reported-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 util/filter.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/util/filter.c b/util/filter.c
index 74ab3535c98e..93d56928a3dc 100644
--- a/util/filter.c
+++ b/util/filter.c
@@ -21,8 +21,8 @@ 
 struct ndctl_bus *util_bus_filter(struct ndctl_bus *bus, const char *ident)
 {
 	char *end = NULL;
-	const char *provider;
 	unsigned long bus_id, id;
+	const char *provider, *devname;
 
 	if (!ident || strcmp(ident, "all") == 0)
 		return bus;
@@ -32,12 +32,14 @@  struct ndctl_bus *util_bus_filter(struct ndctl_bus *bus, const char *ident)
 		bus_id = ULONG_MAX;
 
 	provider = ndctl_bus_get_provider(bus);
+	devname = ndctl_bus_get_devname(bus);
 	id = ndctl_bus_get_id(bus);
 
 	if (bus_id < ULONG_MAX && bus_id == id)
 		return bus;
 
-	if (bus_id == ULONG_MAX && strcmp(ident, provider) == 0)
+	if (bus_id == ULONG_MAX && (strcmp(ident, provider) == 0
+				|| strcmp(ident, devname) == 0))
 		return bus;
 
 	return NULL;