| * Copyright (c) 2015, Christoph Hellwig. |
| #include <linux/memblock.h> |
| #include <linux/platform_device.h> |
| #include <asm/page_types.h> |
| static __init void register_pmem_device(struct resource *res) |
| struct platform_device *pdev; |
| pdev = platform_device_alloc("pmem", PLATFORM_DEVID_AUTO); |
| error = platform_device_add_resources(pdev, res, 1); |
| error = platform_device_add(pdev); |
| dev_warn(&pdev->dev, "failed to add 'pmem' (persistent memory) device!\n"); |
| platform_device_put(pdev); |
| static __init int register_pmem_devices(void) |
| for (i = 0; i < e820.nr_map; i++) { |
| struct e820entry *ei = &e820.map[i]; |
| if (ei->type == E820_PRAM) { |
| .end = ei->addr + ei->size - 1, |
| register_pmem_device(&res); |
| device_initcall(register_pmem_devices); |