last_radio_log.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* 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. #include <linux/kernel.h>
  18. #include <linux/module.h>
  19. #include <linux/fs.h>
  20. #include <linux/proc_fs.h>
  21. #include <linux/uaccess.h>
  22. #include "smd_private.h"
  23. static void *radio_log_base;
  24. static size_t radio_log_size;
  25. extern void *smem_item(unsigned id, unsigned *size);
  26. static ssize_t last_radio_log_read(struct file *file, char __user *buf,
  27. size_t len, loff_t *offset)
  28. {
  29. return simple_read_from_buffer(buf, len, offset,
  30. radio_log_base, radio_log_size);
  31. }
  32. static struct file_operations last_radio_log_fops = {
  33. .read = last_radio_log_read,
  34. .llseek = default_llseek,
  35. };
  36. void msm_init_last_radio_log(struct module *owner)
  37. {
  38. struct proc_dir_entry *entry;
  39. if (last_radio_log_fops.owner) {
  40. pr_err("%s: already claimed\n", __func__);
  41. return;
  42. }
  43. radio_log_base = smem_item(SMEM_CLKREGIM_BSP, &radio_log_size);
  44. if (!radio_log_base) {
  45. pr_err("%s: could not retrieve SMEM_CLKREGIM_BSP\n", __func__);
  46. return;
  47. }
  48. entry = proc_create("last_radio_log", S_IRUGO, NULL,
  49. &last_radio_log_fops);
  50. if (!entry) {
  51. pr_err("%s: could not create proc entry for radio log\n",
  52. __func__);
  53. return;
  54. }
  55. pr_err("%s: last radio log is %d bytes long\n", __func__,
  56. radio_log_size);
  57. last_radio_log_fops.owner = owner;
  58. proc_set_size(entry, radio_log_size);
  59. }
  60. EXPORT_SYMBOL(msm_init_last_radio_log);