wq.c 782 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "edac_module.h"
  2. static struct workqueue_struct *wq;
  3. bool edac_queue_work(struct delayed_work *work, unsigned long delay)
  4. {
  5. return queue_delayed_work(wq, work, delay);
  6. }
  7. EXPORT_SYMBOL_GPL(edac_queue_work);
  8. bool edac_mod_work(struct delayed_work *work, unsigned long delay)
  9. {
  10. return mod_delayed_work(wq, work, delay);
  11. }
  12. EXPORT_SYMBOL_GPL(edac_mod_work);
  13. bool edac_stop_work(struct delayed_work *work)
  14. {
  15. bool ret;
  16. ret = cancel_delayed_work_sync(work);
  17. flush_workqueue(wq);
  18. return ret;
  19. }
  20. EXPORT_SYMBOL_GPL(edac_stop_work);
  21. int edac_workqueue_setup(void)
  22. {
  23. wq = alloc_ordered_workqueue("edac-poller", WQ_MEM_RECLAIM);
  24. if (!wq)
  25. return -ENODEV;
  26. else
  27. return 0;
  28. }
  29. void edac_workqueue_teardown(void)
  30. {
  31. flush_workqueue(wq);
  32. destroy_workqueue(wq);
  33. wq = NULL;
  34. }