GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / arm / mach-msm / last_radio_log.c
blobb64ba5a98686a2ad8fe85ffdb971d51725b192f5
1 /* arch/arm/mach-msm/last_radio_log.c
3 * Extract the log from a modem crash though SMEM
5 * Copyright (C) 2007 Google, Inc.
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20 #include <linux/fs.h>
21 #include <linux/proc_fs.h>
22 #include <linux/uaccess.h>
24 #include "smd_private.h"
26 static void *radio_log_base;
27 static size_t radio_log_size;
29 extern void *smem_item(unsigned id, unsigned *size);
31 static ssize_t last_radio_log_read(struct file *file, char __user *buf,
32 size_t len, loff_t *offset)
34 loff_t pos = *offset;
35 ssize_t count;
37 if (pos >= radio_log_size)
38 return 0;
40 count = min(len, (size_t)(radio_log_size - pos));
41 if (copy_to_user(buf, radio_log_base + pos, count)) {
42 pr_err("%s: copy to user failed\n", __func__);
43 return -EFAULT;
46 *offset += count;
47 return count;
50 static struct file_operations last_radio_log_fops = {
51 .read = last_radio_log_read
54 void msm_init_last_radio_log(struct module *owner)
56 struct proc_dir_entry *entry;
58 if (last_radio_log_fops.owner) {
59 pr_err("%s: already claimed\n", __func__);
60 return;
63 radio_log_base = smem_item(SMEM_CLKREGIM_BSP, &radio_log_size);
64 if (!radio_log_base) {
65 pr_err("%s: could not retrieve SMEM_CLKREGIM_BSP\n", __func__);
66 return;
69 entry = create_proc_entry("last_radio_log", S_IFREG | S_IRUGO, NULL);
70 if (!entry) {
71 pr_err("%s: could not create proc entry for radio log\n",
72 __func__);
73 return;
76 pr_err("%s: last radio log is %d bytes long\n", __func__,
77 radio_log_size);
78 last_radio_log_fops.owner = owner;
79 entry->proc_fops = &last_radio_log_fops;
80 entry->size = radio_log_size;
82 EXPORT_SYMBOL(msm_init_last_radio_log);