hvc_irq.c 1.0 KB

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