2 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 #include <linux/vmalloc.h>
15 #include <linux/uaccess.h>
16 #include <linux/module.h>
17 #include <linux/blkdev.h>
18 #include <linux/fcntl.h>
19 #include <linux/async.h>
20 #include <linux/genhd.h>
21 #include <linux/ndctl.h>
22 #include <linux/sched.h>
23 #include <linux/slab.h>
32 static int nvdimm_bus_major;
33 static struct class *nd_class;
35 static int to_nd_device_type(struct device *dev)
38 return ND_DEVICE_DIMM;
39 else if (is_nd_pmem(dev))
40 return ND_DEVICE_REGION_PMEM;
41 else if (is_nd_blk(dev))
42 return ND_DEVICE_REGION_BLK;
43 else if (is_nd_dax(dev))
44 return ND_DEVICE_DAX_PMEM;
45 else if (is_nd_pmem(dev->parent) || is_nd_blk(dev->parent))
46 return nd_region_to_nstype(to_nd_region(dev->parent));
51 static int nvdimm_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
54 * Ensure that region devices always have their numa node set as
57 if (is_nd_pmem(dev) || is_nd_blk(dev))
58 set_dev_node(dev, to_nd_region(dev)->numa_node);
59 return add_uevent_var(env, "MODALIAS=" ND_DEVICE_MODALIAS_FMT,
60 to_nd_device_type(dev));
63 static int nvdimm_bus_match(struct device *dev, struct device_driver *drv)
65 struct nd_device_driver *nd_drv = to_nd_device_driver(drv);
67 return !!test_bit(to_nd_device_type(dev), &nd_drv->type);
70 static struct module *to_bus_provider(struct device *dev)
72 /* pin bus providers while regions are enabled */
73 if (is_nd_pmem(dev) || is_nd_blk(dev)) {
74 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
76 return nvdimm_bus->module;
81 static void nvdimm_bus_probe_start(struct nvdimm_bus *nvdimm_bus)
83 nvdimm_bus_lock(&nvdimm_bus->dev);
84 nvdimm_bus->probe_active++;
85 nvdimm_bus_unlock(&nvdimm_bus->dev);
88 static void nvdimm_bus_probe_end(struct nvdimm_bus *nvdimm_bus)
90 nvdimm_bus_lock(&nvdimm_bus->dev);
91 if (--nvdimm_bus->probe_active == 0)
92 wake_up(&nvdimm_bus->probe_wait);
93 nvdimm_bus_unlock(&nvdimm_bus->dev);
96 static int nvdimm_bus_probe(struct device *dev)
98 struct nd_device_driver *nd_drv = to_nd_device_driver(dev->driver);
99 struct module *provider = to_bus_provider(dev);
100 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
103 if (!try_module_get(provider))
106 nvdimm_bus_probe_start(nvdimm_bus);
107 rc = nd_drv->probe(dev);
109 nd_region_probe_success(nvdimm_bus, dev);
111 nd_region_disable(nvdimm_bus, dev);
112 nvdimm_bus_probe_end(nvdimm_bus);
114 dev_dbg(&nvdimm_bus->dev, "%s.probe(%s) = %d\n", dev->driver->name,
118 module_put(provider);
122 static int nvdimm_bus_remove(struct device *dev)
124 struct nd_device_driver *nd_drv = to_nd_device_driver(dev->driver);
125 struct module *provider = to_bus_provider(dev);
126 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
129 rc = nd_drv->remove(dev);
130 nd_region_disable(nvdimm_bus, dev);
132 dev_dbg(&nvdimm_bus->dev, "%s.remove(%s) = %d\n", dev->driver->name,
134 module_put(provider);
138 void nd_device_notify(struct device *dev, enum nvdimm_event event)
142 struct nd_device_driver *nd_drv;
144 nd_drv = to_nd_device_driver(dev->driver);
146 nd_drv->notify(dev, event);
150 EXPORT_SYMBOL(nd_device_notify);
152 void nvdimm_region_notify(struct nd_region *nd_region, enum nvdimm_event event)
154 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(&nd_region->dev);
159 /* caller is responsible for holding a reference on the device */
160 nd_device_notify(&nd_region->dev, event);
162 EXPORT_SYMBOL_GPL(nvdimm_region_notify);
164 long nvdimm_clear_poison(struct device *dev, phys_addr_t phys,
167 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
168 struct nvdimm_bus_descriptor *nd_desc;
169 struct nd_cmd_clear_error clear_err;
170 struct nd_cmd_ars_cap ars_cap;
171 u32 clear_err_unit, mask;
177 nd_desc = nvdimm_bus->nd_desc;
181 memset(&ars_cap, 0, sizeof(ars_cap));
182 ars_cap.address = phys;
183 ars_cap.length = len;
184 rc = nd_desc->ndctl(nd_desc, NULL, ND_CMD_ARS_CAP, &ars_cap,
185 sizeof(ars_cap), &cmd_rc);
190 clear_err_unit = ars_cap.clear_err_unit;
191 if (!clear_err_unit || !is_power_of_2(clear_err_unit))
194 mask = clear_err_unit - 1;
195 if ((phys | len) & mask)
197 memset(&clear_err, 0, sizeof(clear_err));
198 clear_err.address = phys;
199 clear_err.length = len;
200 rc = nd_desc->ndctl(nd_desc, NULL, ND_CMD_CLEAR_ERROR, &clear_err,
201 sizeof(clear_err), &cmd_rc);
206 return clear_err.cleared;
208 EXPORT_SYMBOL_GPL(nvdimm_clear_poison);
210 static struct bus_type nvdimm_bus_type = {
212 .uevent = nvdimm_bus_uevent,
213 .match = nvdimm_bus_match,
214 .probe = nvdimm_bus_probe,
215 .remove = nvdimm_bus_remove,
218 static ASYNC_DOMAIN_EXCLUSIVE(nd_async_domain);
220 void nd_synchronize(void)
222 async_synchronize_full_domain(&nd_async_domain);
224 EXPORT_SYMBOL_GPL(nd_synchronize);
226 static void nd_async_device_register(void *d, async_cookie_t cookie)
228 struct device *dev = d;
230 if (device_add(dev) != 0) {
231 dev_err(dev, "%s: failed\n", __func__);
237 static void nd_async_device_unregister(void *d, async_cookie_t cookie)
239 struct device *dev = d;
241 /* flush bus operations before delete */
242 nvdimm_bus_lock(dev);
243 nvdimm_bus_unlock(dev);
245 device_unregister(dev);
249 void __nd_device_register(struct device *dev)
253 dev->bus = &nvdimm_bus_type;
255 async_schedule_domain(nd_async_device_register, dev,
259 void nd_device_register(struct device *dev)
261 device_initialize(dev);
262 __nd_device_register(dev);
264 EXPORT_SYMBOL(nd_device_register);
266 void nd_device_unregister(struct device *dev, enum nd_async_mode mode)
271 async_schedule_domain(nd_async_device_unregister, dev,
276 device_unregister(dev);
280 EXPORT_SYMBOL(nd_device_unregister);
283 * __nd_driver_register() - register a region or a namespace driver
284 * @nd_drv: driver to register
285 * @owner: automatically set by nd_driver_register() macro
286 * @mod_name: automatically set by nd_driver_register() macro
288 int __nd_driver_register(struct nd_device_driver *nd_drv, struct module *owner,
289 const char *mod_name)
291 struct device_driver *drv = &nd_drv->drv;
294 pr_debug("driver type bitmask not set (%pf)\n",
295 __builtin_return_address(0));
299 if (!nd_drv->probe || !nd_drv->remove) {
300 pr_debug("->probe() and ->remove() must be specified\n");
304 drv->bus = &nvdimm_bus_type;
306 drv->mod_name = mod_name;
308 return driver_register(drv);
310 EXPORT_SYMBOL(__nd_driver_register);
312 int nvdimm_revalidate_disk(struct gendisk *disk)
314 struct device *dev = disk->driverfs_dev;
315 struct nd_region *nd_region = to_nd_region(dev->parent);
316 const char *pol = nd_region->ro ? "only" : "write";
318 if (nd_region->ro == get_disk_ro(disk))
321 dev_info(dev, "%s read-%s, marking %s read-%s\n",
322 dev_name(&nd_region->dev), pol, disk->disk_name, pol);
323 set_disk_ro(disk, nd_region->ro);
328 EXPORT_SYMBOL(nvdimm_revalidate_disk);
330 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
333 return sprintf(buf, ND_DEVICE_MODALIAS_FMT "\n",
334 to_nd_device_type(dev));
336 static DEVICE_ATTR_RO(modalias);
338 static ssize_t devtype_show(struct device *dev, struct device_attribute *attr,
341 return sprintf(buf, "%s\n", dev->type->name);
343 static DEVICE_ATTR_RO(devtype);
345 static struct attribute *nd_device_attributes[] = {
346 &dev_attr_modalias.attr,
347 &dev_attr_devtype.attr,
352 * nd_device_attribute_group - generic attributes for all devices on an nd bus
354 struct attribute_group nd_device_attribute_group = {
355 .attrs = nd_device_attributes,
357 EXPORT_SYMBOL_GPL(nd_device_attribute_group);
359 static ssize_t numa_node_show(struct device *dev,
360 struct device_attribute *attr, char *buf)
362 return sprintf(buf, "%d\n", dev_to_node(dev));
364 static DEVICE_ATTR_RO(numa_node);
366 static struct attribute *nd_numa_attributes[] = {
367 &dev_attr_numa_node.attr,
371 static umode_t nd_numa_attr_visible(struct kobject *kobj, struct attribute *a,
374 if (!IS_ENABLED(CONFIG_NUMA))
381 * nd_numa_attribute_group - NUMA attributes for all devices on an nd bus
383 struct attribute_group nd_numa_attribute_group = {
384 .attrs = nd_numa_attributes,
385 .is_visible = nd_numa_attr_visible,
387 EXPORT_SYMBOL_GPL(nd_numa_attribute_group);
389 int nvdimm_bus_create_ndctl(struct nvdimm_bus *nvdimm_bus)
391 dev_t devt = MKDEV(nvdimm_bus_major, nvdimm_bus->id);
394 dev = device_create(nd_class, &nvdimm_bus->dev, devt, nvdimm_bus,
395 "ndctl%d", nvdimm_bus->id);
398 dev_dbg(&nvdimm_bus->dev, "failed to register ndctl%d: %ld\n",
399 nvdimm_bus->id, PTR_ERR(dev));
405 void nvdimm_bus_destroy_ndctl(struct nvdimm_bus *nvdimm_bus)
407 device_destroy(nd_class, MKDEV(nvdimm_bus_major, nvdimm_bus->id));
410 static const struct nd_cmd_desc __nd_cmd_dimm_descs[] = {
411 [ND_CMD_IMPLEMENTED] = { },
414 .out_sizes = { 4, 128, },
416 [ND_CMD_SMART_THRESHOLD] = {
418 .out_sizes = { 4, 8, },
420 [ND_CMD_DIMM_FLAGS] = {
422 .out_sizes = { 4, 4 },
424 [ND_CMD_GET_CONFIG_SIZE] = {
426 .out_sizes = { 4, 4, 4, },
428 [ND_CMD_GET_CONFIG_DATA] = {
430 .in_sizes = { 4, 4, },
432 .out_sizes = { 4, UINT_MAX, },
434 [ND_CMD_SET_CONFIG_DATA] = {
436 .in_sizes = { 4, 4, UINT_MAX, },
442 .in_sizes = { 4, 4, UINT_MAX, },
444 .out_sizes = { 4, 4, UINT_MAX, },
448 .in_sizes = { sizeof(struct nd_cmd_pkg), UINT_MAX, },
450 .out_sizes = { UINT_MAX, },
454 const struct nd_cmd_desc *nd_cmd_dimm_desc(int cmd)
456 if (cmd < ARRAY_SIZE(__nd_cmd_dimm_descs))
457 return &__nd_cmd_dimm_descs[cmd];
460 EXPORT_SYMBOL_GPL(nd_cmd_dimm_desc);
462 static const struct nd_cmd_desc __nd_cmd_bus_descs[] = {
463 [ND_CMD_IMPLEMENTED] = { },
466 .in_sizes = { 8, 8, },
468 .out_sizes = { 4, 4, 4, 4, },
470 [ND_CMD_ARS_START] = {
472 .in_sizes = { 8, 8, 2, 1, 5, },
474 .out_sizes = { 4, 4, },
476 [ND_CMD_ARS_STATUS] = {
478 .out_sizes = { 4, 4, UINT_MAX, },
480 [ND_CMD_CLEAR_ERROR] = {
482 .in_sizes = { 8, 8, },
484 .out_sizes = { 4, 4, 8, },
488 .in_sizes = { sizeof(struct nd_cmd_pkg), UINT_MAX, },
490 .out_sizes = { UINT_MAX, },
494 const struct nd_cmd_desc *nd_cmd_bus_desc(int cmd)
496 if (cmd < ARRAY_SIZE(__nd_cmd_bus_descs))
497 return &__nd_cmd_bus_descs[cmd];
500 EXPORT_SYMBOL_GPL(nd_cmd_bus_desc);
502 u32 nd_cmd_in_size(struct nvdimm *nvdimm, int cmd,
503 const struct nd_cmd_desc *desc, int idx, void *buf)
505 if (idx >= desc->in_num)
508 if (desc->in_sizes[idx] < UINT_MAX)
509 return desc->in_sizes[idx];
511 if (nvdimm && cmd == ND_CMD_SET_CONFIG_DATA && idx == 2) {
512 struct nd_cmd_set_config_hdr *hdr = buf;
514 return hdr->in_length;
515 } else if (nvdimm && cmd == ND_CMD_VENDOR && idx == 2) {
516 struct nd_cmd_vendor_hdr *hdr = buf;
518 return hdr->in_length;
519 } else if (cmd == ND_CMD_CALL) {
520 struct nd_cmd_pkg *pkg = buf;
522 return pkg->nd_size_in;
527 EXPORT_SYMBOL_GPL(nd_cmd_in_size);
529 u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd,
530 const struct nd_cmd_desc *desc, int idx, const u32 *in_field,
531 const u32 *out_field)
533 if (idx >= desc->out_num)
536 if (desc->out_sizes[idx] < UINT_MAX)
537 return desc->out_sizes[idx];
539 if (nvdimm && cmd == ND_CMD_GET_CONFIG_DATA && idx == 1)
541 else if (nvdimm && cmd == ND_CMD_VENDOR && idx == 2)
543 else if (!nvdimm && cmd == ND_CMD_ARS_STATUS && idx == 2)
544 return out_field[1] - 8;
545 else if (cmd == ND_CMD_CALL) {
546 struct nd_cmd_pkg *pkg = (struct nd_cmd_pkg *) in_field;
548 return pkg->nd_size_out;
554 EXPORT_SYMBOL_GPL(nd_cmd_out_size);
556 void wait_nvdimm_bus_probe_idle(struct device *dev)
558 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
561 if (nvdimm_bus->probe_active == 0)
563 nvdimm_bus_unlock(&nvdimm_bus->dev);
564 wait_event(nvdimm_bus->probe_wait,
565 nvdimm_bus->probe_active == 0);
566 nvdimm_bus_lock(&nvdimm_bus->dev);
570 static int pmem_active(struct device *dev, void *data)
572 if (is_nd_pmem(dev) && dev->driver)
577 /* set_config requires an idle interleave set */
578 static int nd_cmd_clear_to_send(struct nvdimm_bus *nvdimm_bus,
579 struct nvdimm *nvdimm, unsigned int cmd)
581 struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc;
583 /* ask the bus provider if it would like to block this request */
584 if (nd_desc->clear_to_send) {
585 int rc = nd_desc->clear_to_send(nd_desc, nvdimm, cmd);
591 /* require clear error to go through the pmem driver */
592 if (!nvdimm && cmd == ND_CMD_CLEAR_ERROR)
593 return device_for_each_child(&nvdimm_bus->dev, NULL,
596 if (!nvdimm || cmd != ND_CMD_SET_CONFIG_DATA)
599 /* prevent label manipulation while the kernel owns label updates */
600 wait_nvdimm_bus_probe_idle(&nvdimm_bus->dev);
601 if (atomic_read(&nvdimm->busy))
606 static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
607 int read_only, unsigned int ioctl_cmd, unsigned long arg)
609 struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc;
610 size_t buf_len = 0, in_len = 0, out_len = 0;
611 static char out_env[ND_CMD_MAX_ENVELOPE];
612 static char in_env[ND_CMD_MAX_ENVELOPE];
613 const struct nd_cmd_desc *desc = NULL;
614 unsigned int cmd = _IOC_NR(ioctl_cmd);
615 void __user *p = (void __user *) arg;
616 struct device *dev = &nvdimm_bus->dev;
617 struct nd_cmd_pkg pkg;
618 const char *cmd_name, *dimm_name;
619 unsigned long cmd_mask;
624 desc = nd_cmd_dimm_desc(cmd);
625 cmd_name = nvdimm_cmd_name(cmd);
626 cmd_mask = nvdimm->cmd_mask;
627 dimm_name = dev_name(&nvdimm->dev);
629 desc = nd_cmd_bus_desc(cmd);
630 cmd_name = nvdimm_bus_cmd_name(cmd);
631 cmd_mask = nd_desc->cmd_mask;
635 if (cmd == ND_CMD_CALL) {
636 if (copy_from_user(&pkg, p, sizeof(pkg)))
640 if (!desc || (desc->out_num + desc->in_num == 0) ||
641 !test_bit(cmd, &cmd_mask))
644 /* fail write commands (when read-only) */
648 case ND_CMD_SET_CONFIG_DATA:
649 case ND_CMD_ARS_START:
650 case ND_CMD_CLEAR_ERROR:
652 dev_dbg(&nvdimm_bus->dev, "'%s' command while read-only.\n",
653 nvdimm ? nvdimm_cmd_name(cmd)
654 : nvdimm_bus_cmd_name(cmd));
660 /* process an input envelope */
661 for (i = 0; i < desc->in_num; i++) {
664 in_size = nd_cmd_in_size(nvdimm, cmd, desc, i, in_env);
665 if (in_size == UINT_MAX) {
666 dev_err(dev, "%s:%s unknown input size cmd: %s field: %d\n",
667 __func__, dimm_name, cmd_name, i);
670 if (in_len < sizeof(in_env))
671 copy = min_t(u32, sizeof(in_env) - in_len, in_size);
674 if (copy && copy_from_user(&in_env[in_len], p + in_len, copy))
679 if (cmd == ND_CMD_CALL) {
680 dev_dbg(dev, "%s:%s, idx: %llu, in: %zu, out: %zu, len %zu\n",
681 __func__, dimm_name, pkg.nd_command,
682 in_len, out_len, buf_len);
684 for (i = 0; i < ARRAY_SIZE(pkg.nd_reserved2); i++)
685 if (pkg.nd_reserved2[i])
689 /* process an output envelope */
690 for (i = 0; i < desc->out_num; i++) {
691 u32 out_size = nd_cmd_out_size(nvdimm, cmd, desc, i,
692 (u32 *) in_env, (u32 *) out_env);
695 if (out_size == UINT_MAX) {
696 dev_dbg(dev, "%s:%s unknown output size cmd: %s field: %d\n",
697 __func__, dimm_name, cmd_name, i);
700 if (out_len < sizeof(out_env))
701 copy = min_t(u32, sizeof(out_env) - out_len, out_size);
704 if (copy && copy_from_user(&out_env[out_len],
705 p + in_len + out_len, copy))
710 buf_len = out_len + in_len;
711 if (buf_len > ND_IOCTL_MAX_BUFLEN) {
712 dev_dbg(dev, "%s:%s cmd: %s buf_len: %zu > %d\n", __func__,
713 dimm_name, cmd_name, buf_len,
714 ND_IOCTL_MAX_BUFLEN);
718 buf = vmalloc(buf_len);
722 if (copy_from_user(buf, p, buf_len)) {
727 nvdimm_bus_lock(&nvdimm_bus->dev);
728 rc = nd_cmd_clear_to_send(nvdimm_bus, nvdimm, cmd);
732 rc = nd_desc->ndctl(nd_desc, nvdimm, cmd, buf, buf_len, NULL);
735 if (copy_to_user(p, buf, buf_len))
738 nvdimm_bus_unlock(&nvdimm_bus->dev);
744 static long nd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
746 long id = (long) file->private_data;
748 struct nvdimm_bus *nvdimm_bus;
750 ro = ((file->f_flags & O_ACCMODE) == O_RDONLY);
751 mutex_lock(&nvdimm_bus_list_mutex);
752 list_for_each_entry(nvdimm_bus, &nvdimm_bus_list, list) {
753 if (nvdimm_bus->id == id) {
754 rc = __nd_ioctl(nvdimm_bus, NULL, ro, cmd, arg);
758 mutex_unlock(&nvdimm_bus_list_mutex);
763 static int match_dimm(struct device *dev, void *data)
765 long id = (long) data;
767 if (is_nvdimm(dev)) {
768 struct nvdimm *nvdimm = to_nvdimm(dev);
770 return nvdimm->id == id;
776 static long nvdimm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
779 struct nvdimm_bus *nvdimm_bus;
781 ro = ((file->f_flags & O_ACCMODE) == O_RDONLY);
782 mutex_lock(&nvdimm_bus_list_mutex);
783 list_for_each_entry(nvdimm_bus, &nvdimm_bus_list, list) {
784 struct device *dev = device_find_child(&nvdimm_bus->dev,
785 file->private_data, match_dimm);
786 struct nvdimm *nvdimm;
791 nvdimm = to_nvdimm(dev);
792 rc = __nd_ioctl(nvdimm_bus, nvdimm, ro, cmd, arg);
796 mutex_unlock(&nvdimm_bus_list_mutex);
801 static int nd_open(struct inode *inode, struct file *file)
803 long minor = iminor(inode);
805 file->private_data = (void *) minor;
809 static const struct file_operations nvdimm_bus_fops = {
810 .owner = THIS_MODULE,
812 .unlocked_ioctl = nd_ioctl,
813 .compat_ioctl = nd_ioctl,
814 .llseek = noop_llseek,
817 static const struct file_operations nvdimm_fops = {
818 .owner = THIS_MODULE,
820 .unlocked_ioctl = nvdimm_ioctl,
821 .compat_ioctl = nvdimm_ioctl,
822 .llseek = noop_llseek,
825 int __init nvdimm_bus_init(void)
829 BUILD_BUG_ON(sizeof(struct nd_smart_payload) != 128);
830 BUILD_BUG_ON(sizeof(struct nd_smart_threshold_payload) != 8);
832 rc = bus_register(&nvdimm_bus_type);
836 rc = register_chrdev(0, "ndctl", &nvdimm_bus_fops);
839 nvdimm_bus_major = rc;
841 rc = register_chrdev(0, "dimmctl", &nvdimm_fops);
843 goto err_dimm_chrdev;
846 nd_class = class_create(THIS_MODULE, "nd");
847 if (IS_ERR(nd_class)) {
848 rc = PTR_ERR(nd_class);
855 unregister_chrdev(nvdimm_major, "dimmctl");
857 unregister_chrdev(nvdimm_bus_major, "ndctl");
859 bus_unregister(&nvdimm_bus_type);
864 void nvdimm_bus_exit(void)
866 class_destroy(nd_class);
867 unregister_chrdev(nvdimm_bus_major, "ndctl");
868 unregister_chrdev(nvdimm_major, "dimmctl");
869 bus_unregister(&nvdimm_bus_type);