From patchwork Fri Aug 18 04:33:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?R290b3UsIFlhc3Vub3JpL+S6lOWztiDlurfmloc=?= X-Patchwork-Id: 9907585 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 C66E760385 for ; Fri, 18 Aug 2017 04:34:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7E3A28B93 for ; Fri, 18 Aug 2017 04:34:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABA5028BD0; Fri, 18 Aug 2017 04:34:00 +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 43A0928B93 for ; Fri, 18 Aug 2017 04:33:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A5C412095B9EC; Thu, 17 Aug 2017 21:31:31 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mgwkm03.jp.fujitsu.com (mgwkm03.jp.fujitsu.com [202.219.69.170]) (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 CB94E21E7903C for ; Thu, 17 Aug 2017 21:31:29 -0700 (PDT) Received: from kw-mxauth.gw.nic.fujitsu.com (unknown [192.168.231.132]) by mgwkm03.jp.fujitsu.com with smtp id 57f4_6517_9a009ab6_76f9_4e33_bc48_ebd0e425517f; Fri, 18 Aug 2017 13:33:53 +0900 Received: from m3050.s.css.fujitsu.com (msm.b.css.fujitsu.com [10.134.21.208]) by kw-mxauth.gw.nic.fujitsu.com (Postfix) with ESMTP id A3EC0AC00CD for ; Fri, 18 Aug 2017 13:33:53 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.5.2 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20170217-enc X-SHieldMailCheckerMailID: abb5b4d7265f4f8382fd2051f3633c70 Date: Fri, 18 Aug 2017 13:33:49 +0900 From: Yasunori Goto To: NVDIMM-ML Subject: [ndctl PATCH 1/4] make interface to check device/nfit/dsm_mask flags In-Reply-To: <20170818133124.8EAB.E1E9C6FF@jp.fujitsu.com> References: <20170818133124.8EAB.E1E9C6FF@jp.fujitsu.com> Message-Id: <20170818133348.8EAE.E1E9C6FF@jp.fujitsu.com> MIME-Version: 1.0 X-Mailer: Becky! ver. 2.73 [ja] X-TM-AS-MML: disable 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 To check what feature can be called via ND_CMD_CALL, ndctl need to read device/nfit/dsm_mask. This patch make an interface to check it in libndctl.c Signed-off-by: Yasunori Goto --- ndctl/lib/libndctl.c | 13 +++++++++++++ ndctl/libndctl.h.in | 1 + 2 files changed, 14 insertions(+) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index c2e0efb..93692e5 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -102,6 +102,7 @@ struct ndctl_bus { size_t buf_len; char *wait_probe_path; unsigned long dsm_mask; + unsigned long bus_dsm_mask; }; /** @@ -846,6 +847,12 @@ static void *add_bus(void *parent, int id, const char *ctl_base) bus->revision = strtoul(buf, NULL, 0); } + sprintf(path, "%s/device/nfit/dsm_mask", ctl_base); + if (sysfs_read_attr(ctx, path, buf) < 0) + bus->bus_dsm_mask = 0; + else + bus->bus_dsm_mask = strtoul(buf, NULL, 16); + sprintf(path, "%s/device/provider", ctl_base); if (sysfs_read_attr(ctx, path, buf) < 0) goto err_read; @@ -1101,6 +1108,12 @@ NDCTL_EXPORT int ndctl_bus_is_cmd_supported(struct ndctl_bus *bus, return !!(bus->dsm_mask & (1ULL << cmd)); } +NDCTL_EXPORT int ndctl_bus_is_sub_cmd_supported(struct ndctl_bus *bus, + int cmd) +{ + return !!(bus->bus_dsm_mask & (1ULL << cmd)); +} + NDCTL_EXPORT unsigned int ndctl_bus_get_revision(struct ndctl_bus *bus) { return bus->revision; diff --git a/ndctl/libndctl.h.in b/ndctl/libndctl.h.in index 855d883..206c441 100644 --- a/ndctl/libndctl.h.in +++ b/ndctl/libndctl.h.in @@ -109,6 +109,7 @@ struct ndctl_bus *ndctl_bus_get_by_provider(struct ndctl_ctx *ctx, const char *provider); const char *ndctl_bus_get_cmd_name(struct ndctl_bus *bus, int cmd); int ndctl_bus_is_cmd_supported(struct ndctl_bus *bus, int cmd); +int ndctl_bus_is_sub_cmd_supported(struct ndctl_bus *bus, int cmd); unsigned int ndctl_bus_get_revision(struct ndctl_bus *bus); unsigned int ndctl_bus_get_id(struct ndctl_bus *bus); const char *ndctl_bus_get_provider(struct ndctl_bus *bus);