summaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm/bus.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2015-04-25 03:56:17 -0400
committerDan Williams <dan.j.williams@intel.com>2015-06-24 21:24:10 -0400
commite6dfb2de47768efe8cc37c9a1863d2aff81440fb (patch)
treea1ad89328d88a37195f23ca9421071fc29e6722f /drivers/nvdimm/bus.c
parent45def22c1fab85764646746ce38d45b2f3281fa5 (diff)
downloadlinux-e6dfb2de47768efe8cc37c9a1863d2aff81440fb.tar.bz2
libnvdimm, nfit: dimm/memory-devices
Enable nvdimm devices to be registered on a nvdimm_bus. The kernel assigned device id for nvdimm devicesis dynamic. If userspace needs a more static identifier it should consult a provider-specific attribute. In the case where NFIT is the provider, the 'nmemX/nfit/handle' or 'nmemX/nfit/serial' attributes may be used for this purpose. Cc: Neil Brown <neilb@suse.de> Cc: <linux-acpi@vger.kernel.org> Cc: Greg KH <gregkh@linuxfoundation.org> Cc: Robert Moore <robert.moore@intel.com> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Christoph Hellwig <hch@lst.de> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Toshi Kani <toshi.kani@hp.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/bus.c')
-rw-r--r--drivers/nvdimm/bus.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 3f7c690a5d0c..a8802577fb55 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -13,6 +13,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/uaccess.h>
#include <linux/fcntl.h>
+#include <linux/async.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/io.h>
@@ -21,6 +22,10 @@
static int nvdimm_bus_major;
static struct class *nd_class;
+struct bus_type nvdimm_bus_type = {
+ .name = "nd",
+};
+
int nvdimm_bus_create_ndctl(struct nvdimm_bus *nvdimm_bus)
{
dev_t devt = MKDEV(nvdimm_bus_major, nvdimm_bus->id);
@@ -59,9 +64,13 @@ int __init nvdimm_bus_init(void)
{
int rc;
+ rc = bus_register(&nvdimm_bus_type);
+ if (rc)
+ return rc;
+
rc = register_chrdev(0, "ndctl", &nvdimm_bus_fops);
if (rc < 0)
- return rc;
+ goto err_chrdev;
nvdimm_bus_major = rc;
nd_class = class_create(THIS_MODULE, "nd");
@@ -72,6 +81,8 @@ int __init nvdimm_bus_init(void)
err_class:
unregister_chrdev(nvdimm_bus_major, "ndctl");
+ err_chrdev:
+ bus_unregister(&nvdimm_bus_type);
return rc;
}
@@ -80,4 +91,5 @@ void __exit nvdimm_bus_exit(void)
{
class_destroy(nd_class);
unregister_chrdev(nvdimm_bus_major, "ndctl");
+ bus_unregister(&nvdimm_bus_type);
}