ostimer.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /***************************************************************************
  2. ostimer.c
  3. -------------------
  4. copyright : (C) 2001, 2002 by Frank Mori Hess
  5. email : fmhess@users.sourceforge.net
  6. ***************************************************************************/
  7. /***************************************************************************
  8. * *
  9. * This program is free software; you can redistribute it and/or modify *
  10. * it under the terms of the GNU General Public License as published by *
  11. * the Free Software Foundation; either version 2 of the License, or *
  12. * (at your option) any later version. *
  13. * *
  14. ***************************************************************************/
  15. #include "ibsys.h"
  16. /*
  17. * Timer functions
  18. */
  19. void watchdog_timeout( unsigned long arg )
  20. /* Watchdog timeout routine */
  21. {
  22. gpib_board_t *board = (gpib_board_t*) arg;
  23. set_bit( TIMO_NUM, &board->status );
  24. wake_up_interruptible( &board->wait );
  25. }
  26. /* install timer interrupt handler */
  27. void osStartTimer( gpib_board_t *board, unsigned int usec_timeout )
  28. /* Starts the timeout task */
  29. {
  30. if( timer_pending( &board->timer ) )
  31. {
  32. printk("gpib: bug! timer already running?\n");
  33. return;
  34. }
  35. clear_bit( TIMO_NUM, &board->status );
  36. if( usec_timeout > 0 )
  37. {
  38. board->timer.expires = jiffies + usec_to_jiffies( usec_timeout ); /* set number of ticks */
  39. board->timer.function = watchdog_timeout;
  40. board->timer.data = (unsigned long) board;
  41. add_timer( &board->timer ); /* add timer */
  42. }
  43. }
  44. void osRemoveTimer( gpib_board_t *board )
  45. /* Removes the timeout task */
  46. {
  47. if( timer_pending( &board->timer ) )
  48. del_timer_sync( &board->timer );
  49. }
  50. int io_timed_out( gpib_board_t *board )
  51. {
  52. if( test_bit( TIMO_NUM, &board->status ) ) return 1;
  53. return 0;
  54. }