2 * Copyright (c) 2015, Christoph Hellwig.
4 #include <linux/memblock.h>
5 #include <linux/platform_device.h>
6 #include <linux/slab.h>
8 #include <asm/page_types.h>
11 static __init
void register_pmem_device(struct resource
*res
)
13 struct platform_device
*pdev
;
16 pdev
= platform_device_alloc("pmem", PLATFORM_DEVID_AUTO
);
20 error
= platform_device_add_resources(pdev
, res
, 1);
24 error
= platform_device_add(pdev
);
30 dev_warn(&pdev
->dev
, "failed to add 'pmem' (persistent memory) device!\n");
31 platform_device_put(pdev
);
34 static __init
int register_pmem_devices(void)
38 for (i
= 0; i
< e820
.nr_map
; i
++) {
39 struct e820entry
*ei
= &e820
.map
[i
];
41 if (ei
->type
== E820_PRAM
) {
42 struct resource res
= {
43 .flags
= IORESOURCE_MEM
,
45 .end
= ei
->addr
+ ei
->size
- 1,
47 register_pmem_device(&res
);
53 device_initcall(register_pmem_devices
);