treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / dax / hmem.c
blobfe7214daf62ef03a79f539d0a7c2a3f3870f1a11
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/platform_device.h>
3 #include <linux/memregion.h>
4 #include <linux/module.h>
5 #include <linux/pfn_t.h>
6 #include "bus.h"
8 static int dax_hmem_probe(struct platform_device *pdev)
10 struct device *dev = &pdev->dev;
11 struct dev_pagemap pgmap = { };
12 struct dax_region *dax_region;
13 struct memregion_info *mri;
14 struct dev_dax *dev_dax;
15 struct resource *res;
17 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
18 if (!res)
19 return -ENOMEM;
21 mri = dev->platform_data;
22 memcpy(&pgmap.res, res, sizeof(*res));
24 dax_region = alloc_dax_region(dev, pdev->id, res, mri->target_node,
25 PMD_SIZE, PFN_DEV|PFN_MAP);
26 if (!dax_region)
27 return -ENOMEM;
29 dev_dax = devm_create_dev_dax(dax_region, 0, &pgmap);
30 if (IS_ERR(dev_dax))
31 return PTR_ERR(dev_dax);
33 /* child dev_dax instances now own the lifetime of the dax_region */
34 dax_region_put(dax_region);
35 return 0;
38 static int dax_hmem_remove(struct platform_device *pdev)
40 /* devm handles teardown */
41 return 0;
44 static struct platform_driver dax_hmem_driver = {
45 .probe = dax_hmem_probe,
46 .remove = dax_hmem_remove,
47 .driver = {
48 .name = "hmem",
52 module_platform_driver(dax_hmem_driver);
54 MODULE_ALIAS("platform:hmem*");
55 MODULE_LICENSE("GPL v2");
56 MODULE_AUTHOR("Intel Corporation");