/* Calling copy_to_user() in atomic context is not desirable. Hence first copying the data to a pre-allocated kernel page and then copying to user space in non-atomic context.  */
ssize_t copy_oldmem_page(unsigned long pfn, char *buf, size_t csize, unsigned long offset, int userbuf)
/* Calling copy_to_user() in atomic context is not desirable. Hence first copying the data to a pre-allocated kernel page and then copying to user space in non-atomic context.  */
ssize_t copy_oldmem_page(unsigned long pfn, char *buf, size_t csize, unsigned long offset, int userbuf)
{
	void  *vaddr;
	if (!csize)
		return 0;
	vaddr = __va(pfn<<PAGE_SHIFT);
	if (userbuf) {
		if (copy_to_user(buf, (vaddr + offset), csize)) {
			return -EFAULT;
		}
	} else
		memcpy(buf, (vaddr + offset), csize);
	return csize;
}