hvc_irq.c 1013 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright IBM Corp. 2001,2008
  3. *
  4. * This file contains the IRQ specific code for hvc_console
  5. *
  6. */
  7. #include <linux/interrupt.h>
  8. #include "hvc_console.h"
  9. static irqreturn_t hvc_handle_interrupt(int irq, void *dev_instance)
  10. {
  11. /* if hvc_poll request a repoll, then kick the hvcd thread */
  12. if (hvc_poll(dev_instance))
  13. hvc_kick();
  14. /*
  15. * We're safe to always return IRQ_HANDLED as the hvcd thread will
  16. * iterate through each hvc_struct.
  17. */
  18. return IRQ_HANDLED;
  19. }
  20. /*
  21. * For IRQ based systems these callbacks can be used
  22. */
  23. int notifier_add_irq(struct hvc_struct *hp, int irq)
  24. {
  25. int rc;
  26. if (!irq) {
  27. hp->irq_requested = 0;
  28. return 0;
  29. }
  30. rc = request_irq(irq, hvc_handle_interrupt, hp->flags,
  31. "hvc_console", hp);
  32. if (!rc)
  33. hp->irq_requested = 1;
  34. return rc;
  35. }
  36. void notifier_del_irq(struct hvc_struct *hp, int irq)
  37. {
  38. if (!hp->irq_requested)
  39. return;
  40. free_irq(irq, hp);
  41. hp->irq_requested = 0;
  42. }
  43. void notifier_hangup_irq(struct hvc_struct *hp, int irq)
  44. {
  45. notifier_del_irq(hp, irq);
  46. }