From patchwork Thu Jul 20 04:50:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9853783 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C587160392 for ; Thu, 20 Jul 2017 04:57:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B461B28737 for ; Thu, 20 Jul 2017 04:57:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A928828747; Thu, 20 Jul 2017 04:57:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B294328737 for ; Thu, 20 Jul 2017 04:57:18 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5235021CB0317; Wed, 19 Jul 2017 21:55:22 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 69B4621D1B2B4 for ; Wed, 19 Jul 2017 21:55:21 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 19 Jul 2017 21:57:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,382,1496127600"; d="scan'208";a="994991324" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by orsmga003.jf.intel.com with ESMTP; 19 Jul 2017 21:57:16 -0700 Subject: [ndctl PATCH] ndctl: allow bus device names as a filter option From: Dan Williams To: linux-nvdimm@lists.01.org Date: Wed, 19 Jul 2017 21:50:51 -0700 Message-ID: <150052625182.6153.8007089681147602446.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reported-by: Dave Jiang Signed-off-by: Dan Williams --- util/filter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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;