Thomas Gleixner | 457c899 | 2019-05-19 13:08:55 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Borislav Petkov | c4cf3b4 | 2015-11-30 19:02:01 +0100 | [diff] [blame] | 2 | #include "edac_module.h" |
| 3 | |
| 4 | static struct workqueue_struct *wq; |
| 5 | |
| 6 | bool edac_queue_work(struct delayed_work *work, unsigned long delay) |
| 7 | { |
| 8 | return queue_delayed_work(wq, work, delay); |
| 9 | } |
| 10 | EXPORT_SYMBOL_GPL(edac_queue_work); |
| 11 | |
| 12 | bool edac_mod_work(struct delayed_work *work, unsigned long delay) |
| 13 | { |
| 14 | return mod_delayed_work(wq, work, delay); |
| 15 | } |
| 16 | EXPORT_SYMBOL_GPL(edac_mod_work); |
| 17 | |
| 18 | bool edac_stop_work(struct delayed_work *work) |
| 19 | { |
| 20 | bool ret; |
| 21 | |
| 22 | ret = cancel_delayed_work_sync(work); |
| 23 | flush_workqueue(wq); |
| 24 | |
| 25 | return ret; |
| 26 | } |
| 27 | EXPORT_SYMBOL_GPL(edac_stop_work); |
| 28 | |
| 29 | int edac_workqueue_setup(void) |
| 30 | { |
Bhaktipriya Shridhar | 7bb8b77 | 2016-08-13 22:11:24 +0530 | [diff] [blame] | 31 | wq = alloc_ordered_workqueue("edac-poller", WQ_MEM_RECLAIM); |
Borislav Petkov | c4cf3b4 | 2015-11-30 19:02:01 +0100 | [diff] [blame] | 32 | if (!wq) |
| 33 | return -ENODEV; |
| 34 | else |
| 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | void edac_workqueue_teardown(void) |
| 39 | { |
| 40 | flush_workqueue(wq); |
| 41 | destroy_workqueue(wq); |
| 42 | wq = NULL; |
| 43 | } |