/* The NVS region need not be page-aligned (both ends) and we arrange things so that the data from page-aligned addresses in this region will be copied into separate RAM pages.  */
int hibernate_nvs_register(unsigned long start, unsigned long size)
/* The NVS region need not be page-aligned (both ends) and we arrange things so that the data from page-aligned addresses in this region will be copied into separate RAM pages.  */
int hibernate_nvs_register(unsigned long start, unsigned long size)
{
	struct nvs_page *entry, *next;
	while (size > 0) {
		unsigned int nr_bytes;
		entry = kzalloc(sizeof(struct nvs_page), GFP_KERNEL);
		if (!entry)
			goto Error;
		list_add_tail(&entry->node, &nvs_list);
		entry->phys_start = start;
		nr_bytes = PAGE_SIZE - (start & ~PAGE_MASK);
		entry->size = (size < nr_bytes) ? size : nr_bytes;
		start += entry->size;
		size -= entry->size;
	}
	return 0;
 Error:
	list_for_each_entry_safe(entry, next, &nvs_list, node) {
		list_del(&entry->node);
		kfree(entry);
	}
	return -ENOMEM;
}