treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / dax / pmem / compat.c
blobd7b15e6f30c5b3f696bb593980abe84f9b1e7017
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>
7 #include <linux/nd.h>
8 #include "../bus.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);
16 int rc;
18 if (IS_ERR(dev_dax))
19 return PTR_ERR(dev_dax);
21 if (!devres_open_group(&dev_dax->dev, dev_dax, GFP_KERNEL))
22 return -ENOMEM;
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);
29 if (rc)
30 devres_release_group(&dev_dax->dev, dev_dax);
32 return rc;
35 static int dax_pmem_compat_release(struct device *dev, void *data)
37 device_lock(dev);
38 devres_release_group(dev, to_dev_dax(dev));
39 device_unlock(dev);
41 return 0;
44 static int dax_pmem_compat_remove(struct device *dev)
46 device_for_each_child(dev, NULL, dax_pmem_compat_release);
47 return 0;
50 static struct nd_device_driver dax_pmem_compat_driver = {
51 .probe = dax_pmem_compat_probe,
52 .remove = dax_pmem_compat_remove,
53 .drv = {
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);