Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1497360

[PATCH 03/14] libnvdimm, namespace: refactor uuid_show() into a namespace_to_uuid() helper

From Dan Williams <dan.j.williams@intel.com>
Newsgroups linux.kernel
Subject [PATCH 03/14] libnvdimm, namespace: refactor uuid_show() into a namespace_to_uuid() helper
Date 2016-10-07 18:50 +0200
Message-ID <spGvp-3aK-83@gated-at.bofh.it> (permalink)
References <spGvn-3aK-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The ability to translate a generic struct device pointer into a
namespace uuid is a useful utility as we go to unify the blk and pmem
label scanning paths.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/nvdimm/namespace_devs.c |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 9f4188c78120..0e62f46755e7 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -1032,22 +1032,27 @@ static ssize_t size_show(struct device *dev,
 }
 static DEVICE_ATTR(size, S_IRUGO, size_show, size_store);
 
-static ssize_t uuid_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
+static u8 *namespace_to_uuid(struct device *dev)
 {
-	u8 *uuid;
-
 	if (is_namespace_pmem(dev)) {
 		struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
 
-		uuid = nspm->uuid;
+		return nspm->uuid;
 	} else if (is_namespace_blk(dev)) {
 		struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
 
-		uuid = nsblk->uuid;
+		return nsblk->uuid;
 	} else
-		return -ENXIO;
+		return ERR_PTR(-ENXIO);
+}
+
+static ssize_t uuid_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	u8 *uuid = namespace_to_uuid(dev);
 
+	if (IS_ERR(uuid))
+		return PTR_ERR(uuid);
 	if (uuid)
 		return sprintf(buf, "%pUb\n", uuid);
 	return sprintf(buf, "\n");

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/14] libnvdimm: support sub-divisions of pmem for 4.9 Dan Williams <dan.j.williams@intel.com> - 2016-10-07 18:50 +0200
  [PATCH 14/14] libnvdimm,  namespace: allow creation of multiple pmem-namespaces per region Dan Williams <dan.j.williams@intel.com> - 2016-10-07 18:50 +0200
  [PATCH 03/14] libnvdimm,  namespace: refactor uuid_show() into a namespace_to_uuid() helper Dan Williams <dan.j.williams@intel.com> - 2016-10-07 18:50 +0200
  Re: [PATCH 00/14] libnvdimm: support sub-divisions of pmem for 4.9 Linda Knippers <linda.knippers@hpe.com> - 2016-10-07 20:30 +0200
    Re: [PATCH 00/14] libnvdimm: support sub-divisions of pmem for 4.9 Dan Williams <dan.j.williams@intel.com> - 2016-10-07 22:00 +0200
      Re: [PATCH 00/14] libnvdimm: support sub-divisions of pmem for 4.9 Linda Knippers <linda.knippers@hpe.com> - 2016-10-07 23:50 +0200
        Re: [PATCH 00/14] libnvdimm: support sub-divisions of pmem for 4.9 Dan Williams <dan.j.williams@intel.com> - 2016-10-08 01:40 +0200

csiph-web