aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-08-03 13:30:47 -0400
committerTejun Heo <tj@kernel.org>2012-08-13 19:27:37 -0400
commit41f63c5359d14ca995172b8f6eaffd93f60fec54 (patch)
treed3d93dfd25d2e29e8abeae934835f2266b018cb7 /drivers/edac
parent8376fe22c7e79c7e90857d39f82aeae6cad6c4b8 (diff)
workqueue: use mod_delayed_work() instead of cancel + queue
Convert delayed_work users doing cancel_delayed_work() followed by queue_delayed_work() to mod_delayed_work(). Most conversions are straight-forward. Ones worth mentioning are, * drivers/edac/edac_mc.c: edac_mc_workq_setup() converted to always use mod_delayed_work() and cancel loop in edac_mc_reset_delay_period() is dropped. * drivers/platform/x86/thinkpad_acpi.c: No need to remember whether watchdog is active or not. @fan_watchdog_active and related code dropped. * drivers/power/charger-manager.c: Seemingly a lot of delayed_work_pending() abuse going on here. [delayed_]work_pending() are unsynchronized and racy when used like this. I converted one instance in fullbatt_handler(). Please conver the rest so that it invokes workqueue APIs for the intended target state rather than trying to game work item pending state transitions. e.g. if timer should be modified - call mod_delayed_work(), canceled - call cancel_delayed_work[_sync](). * drivers/thermal/thermal_sys.c: thermal_zone_device_set_polling() simplified. Note that round_jiffies() calls in this function are meaningless. round_jiffies() work on absolute jiffies not delta delay used by delayed_work. v2: Tomi pointed out that __cancel_delayed_work() users can't be safely converted to mod_delayed_work(). They could be calling it from irq context and if that happens while delayed_work_timer_fn() is running, it could deadlock. __cancel_delayed_work() users are dropped. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com> Acked-by: David Howells <dhowells@redhat.com> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Doug Thompson <dougthompson@xmission.com> Cc: David Airlie <airlied@linux.ie> Cc: Roland Dreier <roland@kernel.org> Cc: "John W. Linville" <linville@tuxdriver.com> Cc: Zhang Rui <rui.zhang@intel.com> Cc: Len Brown <len.brown@intel.com> Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: Johannes Berg <johannes@sipsolutions.net>
Diffstat (limited to 'drivers/edac')
-rw-r--r--drivers/edac/edac_mc.c17
1 files changed, 1 insertions, 16 deletions
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 616d90bcb3a4..7c0df4af9ef7 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -538,7 +538,7 @@ static void edac_mc_workq_setup(struct mem_ctl_info *mci, unsigned msec)
538 return; 538 return;
539 539
540 INIT_DELAYED_WORK(&mci->work, edac_mc_workq_function); 540 INIT_DELAYED_WORK(&mci->work, edac_mc_workq_function);
541 queue_delayed_work(edac_workqueue, &mci->work, msecs_to_jiffies(msec)); 541 mod_delayed_work(edac_workqueue, &mci->work, msecs_to_jiffies(msec));
542} 542}
543 543
544/* 544/*
@@ -578,21 +578,6 @@ void edac_mc_reset_delay_period(int value)
578 578
579 mutex_lock(&mem_ctls_mutex); 579 mutex_lock(&mem_ctls_mutex);
580 580
581 /* scan the list and turn off all workq timers, doing so under lock
582 */
583 list_for_each(item, &mc_devices) {
584 mci = list_entry(item, struct mem_ctl_info, link);
585
586 if (mci->op_state == OP_RUNNING_POLL)
587 cancel_delayed_work(&mci->work);
588 }
589
590 mutex_unlock(&mem_ctls_mutex);
591
592
593 /* re-walk the list, and reset the poll delay */
594 mutex_lock(&mem_ctls_mutex);
595
596 list_for_each(item, &mc_devices) { 581 list_for_each(item, &mc_devices) {
597 mci = list_entry(item, struct mem_ctl_info, link); 582 mci = list_entry(item, struct mem_ctl_info, link);
598 583