Staging: Panel: panel: Fixed checkpatch line length warnings
[linux/fpc-iii.git] / arch / arm / kernel / crash_dump.c
blob90c50d4b43f74089b8a7eae08753c41ec00b4461
1 /*
2 * arch/arm/kernel/crash_dump.c
4 * Copyright (C) 2010 Nokia Corporation.
5 * Author: Mika Westerberg
7 * This code is taken from arch/x86/kernel/crash_dump_64.c
8 * Created by: Hariprasad Nellitheertha (hari@in.ibm.com)
9 * Copyright (C) IBM Corporation, 2004. All rights reserved
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <linux/errno.h>
17 #include <linux/crash_dump.h>
18 #include <linux/uaccess.h>
19 #include <linux/io.h>
21 /**
22 * copy_oldmem_page() - copy one page from old kernel memory
23 * @pfn: page frame number to be copied
24 * @buf: buffer where the copied page is placed
25 * @csize: number of bytes to copy
26 * @offset: offset in bytes into the page
27 * @userbuf: if set, @buf is int he user address space
29 * This function copies one page from old kernel memory into buffer pointed by
30 * @buf. If @buf is in userspace, set @userbuf to %1. Returns number of bytes
31 * copied or negative error in case of failure.
33 ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
34 size_t csize, unsigned long offset,
35 int userbuf)
37 void *vaddr;
39 if (!csize)
40 return 0;
42 vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
43 if (!vaddr)
44 return -ENOMEM;
46 if (userbuf) {
47 if (copy_to_user(buf, vaddr + offset, csize)) {
48 iounmap(vaddr);
49 return -EFAULT;
51 } else {
52 memcpy(buf, vaddr + offset, csize);
55 iounmap(vaddr);
56 return csize;