blob: 9c392a29fc7e89a2802aedbaf1aca81e0ff846e6 [file] [log] [blame]
Iliyan Malchev1207bab2009-11-15 18:16:43 -08001/* arch/arm/mach-msm/last_radio_log.c
2 *
3 * Extract the log from a modem crash though SMEM
4 *
5 * Copyright (C) 2007 Google, Inc.
6 *
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.
10 *
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.
15 *
16 */
17
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>
23
24#include "smd_private.h"
25
26static void *radio_log_base;
27static size_t radio_log_size;
28
29extern void *smem_item(unsigned id, unsigned *size);
30
31static ssize_t last_radio_log_read(struct file *file, char __user *buf,
32 size_t len, loff_t *offset)
33{
Al Viro8510e302013-03-31 15:41:41 -040034 return simple_read_from_buffer(buf, len, offset,
35 radio_log_base, radio_log_size);
Iliyan Malchev1207bab2009-11-15 18:16:43 -080036}
37
38static struct file_operations last_radio_log_fops = {
Arnd Bergmann6038f372010-08-15 18:52:59 +020039 .read = last_radio_log_read,
40 .llseek = default_llseek,
Iliyan Malchev1207bab2009-11-15 18:16:43 -080041};
42
43void msm_init_last_radio_log(struct module *owner)
44{
45 struct proc_dir_entry *entry;
46
47 if (last_radio_log_fops.owner) {
48 pr_err("%s: already claimed\n", __func__);
49 return;
50 }
51
52 radio_log_base = smem_item(SMEM_CLKREGIM_BSP, &radio_log_size);
53 if (!radio_log_base) {
54 pr_err("%s: could not retrieve SMEM_CLKREGIM_BSP\n", __func__);
55 return;
56 }
57
Al Viro8510e302013-03-31 15:41:41 -040058 entry = proc_create("last_radio_log", S_IRUGO, NULL,
59 &last_radio_log_fops);
Iliyan Malchev1207bab2009-11-15 18:16:43 -080060 if (!entry) {
61 pr_err("%s: could not create proc entry for radio log\n",
62 __func__);
63 return;
64 }
65
66 pr_err("%s: last radio log is %d bytes long\n", __func__,
67 radio_log_size);
68 last_radio_log_fops.owner = owner;
Geert Uytterhoeven254844d2013-05-07 11:20:26 +020069 proc_set_size(entry, radio_log_size);
Iliyan Malchev1207bab2009-11-15 18:16:43 -080070}
71EXPORT_SYMBOL(msm_init_last_radio_log);