sigio_kern.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
  3. * Licensed under the GPL
  4. */
  5. #include "linux/kernel.h"
  6. #include "linux/list.h"
  7. #include "linux/slab.h"
  8. #include "linux/signal.h"
  9. #include "linux/interrupt.h"
  10. #include "init.h"
  11. #include "sigio.h"
  12. #include "irq_user.h"
  13. #include "irq_kern.h"
  14. /* Protected by sigio_lock() called from write_sigio_workaround */
  15. static int sigio_irq_fd = -1;
  16. static irqreturn_t sigio_interrupt(int irq, void *data, struct pt_regs *unused)
  17. {
  18. read_sigio_fd(sigio_irq_fd);
  19. reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
  20. return(IRQ_HANDLED);
  21. }
  22. int write_sigio_irq(int fd)
  23. {
  24. int err;
  25. err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
  26. SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio",
  27. NULL);
  28. if(err){
  29. printk("write_sigio_irq : um_request_irq failed, err = %d\n",
  30. err);
  31. return(-1);
  32. }
  33. sigio_irq_fd = fd;
  34. return(0);
  35. }
  36. static DEFINE_SPINLOCK(sigio_spinlock);
  37. void sigio_lock(void)
  38. {
  39. spin_lock(&sigio_spinlock);
  40. }
  41. void sigio_unlock(void)
  42. {
  43. spin_unlock(&sigio_spinlock);
  44. }
  45. /*
  46. * Overrides for Emacs so that we follow Linus's tabbing style.
  47. * Emacs will notice this stuff at the end of the file and automatically
  48. * adjust the settings for this buffer only. This must remain at the end
  49. * of the file.
  50. * ---------------------------------------------------------------------------
  51. * Local variables:
  52. * c-file-style: "linux"
  53. * End:
  54. */