summaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm/btt_devs.c
diff options
context:
space:
mode:
authorVishal Verma <vishal.l.verma@intel.com>2016-07-27 16:38:59 -0600
committerDan Williams <dan.j.williams@intel.com>2016-08-08 09:26:14 -0700
commitabe8b4e3cef88b8202641d63f5ad58141b970b0f (patch)
treeb52e23c0f87ac191907395db7d5fae85fd1383f7 /drivers/nvdimm/btt_devs.c
parent68202c9f0ad6e16ee806fbadbc5838d55fe5aa5c (diff)
downloadop-kernel-dev-abe8b4e3cef88b8202641d63f5ad58141b970b0f.zip
op-kernel-dev-abe8b4e3cef88b8202641d63f5ad58141b970b0f.tar.gz
nvdimm, btt: add a size attribute for BTTs
To be consistent with other namespaces, expose a 'size' attribute for BTT devices also. Cc: Dan Williams <dan.j.williams@intel.com> Reported-by: Linda Knippers <linda.knippers@hpe.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/btt_devs.c')
-rw-r--r--drivers/nvdimm/btt_devs.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index 3fa7919..97dd292 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -140,10 +140,30 @@ static ssize_t namespace_store(struct device *dev,
}
static DEVICE_ATTR_RW(namespace);
+static ssize_t size_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct nd_btt *nd_btt = to_nd_btt(dev);
+ ssize_t rc;
+
+ device_lock(dev);
+ if (dev->driver)
+ rc = sprintf(buf, "%llu\n", nd_btt->size);
+ else {
+ /* no size to convey if the btt instance is disabled */
+ rc = -ENXIO;
+ }
+ device_unlock(dev);
+
+ return rc;
+}
+static DEVICE_ATTR_RO(size);
+
static struct attribute *nd_btt_attributes[] = {
&dev_attr_sector_size.attr,
&dev_attr_namespace.attr,
&dev_attr_uuid.attr,
+ &dev_attr_size.attr,
NULL,
};
OpenPOWER on IntegriCloud