1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2016 - 2018 Intel Corporation. All rights reserved. */
3 #include <linux/percpu-refcount.h>
4 #include <linux/memremap.h>
5 #include <linux/module.h>
6 #include <linux/pfn_t.h>
10 /* we need the private definitions to implement compat suport */
11 #include "../dax-private.h"
13 static int dax_pmem_compat_probe(struct device
*dev
)
15 struct dev_dax
*dev_dax
= __dax_pmem_probe(dev
, DEV_DAX_CLASS
);
19 return PTR_ERR(dev_dax
);
21 if (!devres_open_group(&dev_dax
->dev
, dev_dax
, GFP_KERNEL
))
24 device_lock(&dev_dax
->dev
);
25 rc
= dev_dax_probe(&dev_dax
->dev
);
26 device_unlock(&dev_dax
->dev
);
28 devres_close_group(&dev_dax
->dev
, dev_dax
);
30 devres_release_group(&dev_dax
->dev
, dev_dax
);
35 static int dax_pmem_compat_release(struct device
*dev
, void *data
)
38 devres_release_group(dev
, to_dev_dax(dev
));
44 static int dax_pmem_compat_remove(struct device
*dev
)
46 device_for_each_child(dev
, NULL
, dax_pmem_compat_release
);
50 static struct nd_device_driver dax_pmem_compat_driver
= {
51 .probe
= dax_pmem_compat_probe
,
52 .remove
= dax_pmem_compat_remove
,
54 .name
= "dax_pmem_compat",
56 .type
= ND_DRIVER_DAX_PMEM
,
59 static int __init
dax_pmem_compat_init(void)
61 return nd_driver_register(&dax_pmem_compat_driver
);
63 module_init(dax_pmem_compat_init
);
65 static void __exit
dax_pmem_compat_exit(void)
67 driver_unregister(&dax_pmem_compat_driver
.drv
);
69 module_exit(dax_pmem_compat_exit
);
71 MODULE_LICENSE("GPL v2");
72 MODULE_AUTHOR("Intel Corporation");
73 MODULE_ALIAS_ND_DEVICE(ND_DEVICE_DAX_PMEM
);