wq.c 801 B

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