All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yasunori Goto <y-goto@jp.fujitsu.com>
To: NVDIMM-ML <linux-nvdimm@lists.01.org>
Subject: [ndctl PATCH 2/5] ndctl: make interface to read device/nfit/dsm_mask
Date: Fri, 01 Sep 2017 22:17:22 +0900	[thread overview]
Message-ID: <20170901221719.C285.E1E9C6FF@jp.fujitsu.com> (raw)
In-Reply-To: <20170901221335.C27F.E1E9C6FF@jp.fujitsu.com>


To check what feature can be called via ND_CMD_CALL, ndctl need to read
device/nfit/dsm_mask.
Since direct pointer access is not permitted,
ndctl_bus_get_nfit_dsm_mask() is created to access nfit_dsm_mask.
It is used later patch.

Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
---
 ndctl/lib/libndctl.c   | 16 ++++++++++++++++
 ndctl/lib/libndctl.sym |  1 +
 ndctl/libndctl.h.in    |  1 +
 3 files changed, 18 insertions(+)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index f52ecfe..ea37ca4 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -104,6 +104,7 @@ struct ndctl_bus {
 	size_t buf_len;
 	char *wait_probe_path;
 	unsigned long dsm_mask;
+	unsigned long nfit_dsm_mask;
 };
 
 /**
@@ -793,6 +794,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->nfit_dsm_mask = 0;
+	else
+		bus->nfit_dsm_mask = strtoul(buf, NULL, 0);
+
 	sprintf(path, "%s/device/provider", ctl_base);
 	if (sysfs_read_attr(ctx, path, buf) < 0)
 		goto err_read;
@@ -1048,6 +1055,15 @@ NDCTL_EXPORT int ndctl_bus_is_cmd_supported(struct ndctl_bus *bus,
 	return !!(bus->dsm_mask & (1ULL << cmd));
 }
 
+/*
+ * This function is exported for only nfit.c.
+ * Please use ndctl_bus_is_nfit_cmd_supported() in nfit.c instead.
+ */
+NDCTL_EXPORT unsigned long ndctl_bus_get_nfit_dsm_mask(struct ndctl_bus *bus)
+{
+	return bus->nfit_dsm_mask;
+}
+
 NDCTL_EXPORT unsigned int ndctl_bus_get_revision(struct ndctl_bus *bus)
 {
 	return bus->revision;
diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym
index 4c1773d..3f9bf09 100644
--- a/ndctl/lib/libndctl.sym
+++ b/ndctl/lib/libndctl.sym
@@ -30,6 +30,7 @@ global:
 	ndctl_bus_get_by_provider;
 	ndctl_bus_get_cmd_name;
 	ndctl_bus_is_cmd_supported;
+	ndctl_bus_get_nfit_dsm_mask;
 	ndctl_bus_has_nfit;
 	ndctl_bus_get_revision;
 	ndctl_bus_get_id;
diff --git a/ndctl/libndctl.h.in b/ndctl/libndctl.h.in
index 2bbda04..bfee693 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);
+unsigned long ndctl_bus_get_nfit_dsm_mask(struct ndctl_bus *bus);
 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);



_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  parent reply	other threads:[~2017-09-01 13:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-01 13:13 [ndctl PATCH v4 0/5] ndctl: show broken dimm info with translate SPA feature Yasunori Goto
2017-09-01 13:16 ` [ndctl PATCH 1/5] ndctl: Introduce libndctl-nfit.h Yasunori Goto
2017-09-05 18:13   ` Dan Williams
2017-09-05 21:06     ` Dan Williams
2017-09-06  1:28       ` Yasunori Goto
2017-09-06  1:44         ` Dan Williams
2017-09-01 13:17 ` Yasunori Goto [this message]
2017-09-05 18:19   ` [ndctl PATCH 2/5] ndctl: make interface to read device/nfit/dsm_mask Dan Williams
2017-09-01 13:18 ` [ndctl PATCH 3/5] ndctl: allow ND_CMD_CALL for bus Yasunori Goto
2017-09-01 13:21 ` [ndctl PATCH 4/5] ndctl: Make new interfaces to get information by Physical Address Yasunori Goto
2017-09-05 18:43   ` Dan Williams
2017-09-06  2:21     ` Yasunori Goto
2017-09-06  3:08       ` Dan Williams
2017-09-06  4:54         ` Yasunori Goto
2017-09-01 13:22 ` [ndctl PATCH 5/5] ndctl: show bad dimm's name by ndctl list command Yasunori Goto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170901221719.C285.E1E9C6FF@jp.fujitsu.com \
    --to=y-goto@jp.fujitsu.com \
    --cc=linux-nvdimm@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.