hvc_irq.c 893 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. return IRQ_HANDLED;
  15. }
  16. /*
  17. * For IRQ based systems these callbacks can be used
  18. */
  19. int notifier_add_irq(struct hvc_struct *hp, int irq)
  20. {
  21. int rc;
  22. if (!irq) {
  23. hp->irq_requested = 0;
  24. return 0;
  25. }
  26. rc = request_irq(irq, hvc_handle_interrupt, 0,
  27. "hvc_console", hp);
  28. if (!rc)
  29. hp->irq_requested = 1;
  30. return rc;
  31. }
  32. void notifier_del_irq(struct hvc_struct *hp, int irq)
  33. {
  34. if (!hp->irq_requested)
  35. return;
  36. free_irq(irq, hp);
  37. hp->irq_requested = 0;
  38. }
  39. void notifier_hangup_irq(struct hvc_struct *hp, int irq)
  40. {
  41. notifier_del_irq(hp, irq);
  42. }