/arch/arm/mach-fsm/subsystem-fatal-8x60.c

https://bitbucket.org/sammyz/iscream_thunderc-2.6.35-rebase · C · 62 lines · 33 code · 13 blank · 16 comment · 0 complexity · a643cfbcbc69829a2f80fc8c48606c46 MD5 · raw file

  1. /* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. * 02110-1301, USA.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/reboot.h>
  20. #include <linux/workqueue.h>
  21. #include <mach/irqs.h>
  22. static void modem_fatal_fn(struct work_struct *work)
  23. {
  24. printk(KERN_CRIT "Watchdog bite received from modem! Rebooting.\n");
  25. lock_kernel();
  26. kernel_restart(NULL);
  27. unlock_kernel();
  28. }
  29. static DECLARE_WORK(modem_fatal_work, modem_fatal_fn);
  30. static irqreturn_t modem_wdog_bite_irq(int irq, void *dev_id)
  31. {
  32. int ret;
  33. ret = schedule_work(&modem_fatal_work);
  34. disable_irq_nosync(MARM_WDOG_EXPIRED);
  35. return IRQ_HANDLED;
  36. }
  37. static void __exit subsystem_fatal_exit(void)
  38. {
  39. free_irq(MARM_WDOG_EXPIRED, NULL);
  40. }
  41. static int __init subsystem_fatal_init(void)
  42. {
  43. int ret;
  44. ret = request_irq(MARM_WDOG_EXPIRED, modem_wdog_bite_irq,
  45. IRQF_TRIGGER_RISING, "modem_wdog", NULL);
  46. return ret;
  47. }
  48. module_init(subsystem_fatal_init);
  49. module_exit(subsystem_fatal_exit);