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 #include <linux/vmalloc.h>
14 #include <linux/module.h>
15 #include <linux/device.h>
16 #include <linux/sizes.h>
17 #include <linux/ndctl.h>
18 #include <linux/slab.h>
23 static void free_data(struct nvdimm_drvdata *ndd)
28 if (ndd->data && is_vmalloc_addr(ndd->data))
35 static int nvdimm_probe(struct device *dev)
37 struct nvdimm_drvdata *ndd;
40 ndd = kzalloc(sizeof(*ndd), GFP_KERNEL);
44 dev_set_drvdata(dev, ndd);
47 rc = nvdimm_init_nsarea(ndd);
51 rc = nvdimm_init_config_data(ndd);
55 dev_dbg(dev, "config data size: %d\n", ndd->nsarea.config_size);
64 static int nvdimm_remove(struct device *dev)
66 struct nvdimm_drvdata *ndd = dev_get_drvdata(dev);
73 static struct nd_device_driver nvdimm_driver = {
74 .probe = nvdimm_probe,
75 .remove = nvdimm_remove,
79 .type = ND_DRIVER_DIMM,
82 int __init nvdimm_init(void)
84 return nd_driver_register(&nvdimm_driver);
87 void nvdimm_exit(void)
89 driver_unregister(&nvdimm_driver.drv);
92 MODULE_ALIAS_ND_DEVICE(ND_DEVICE_DIMM);