From: Luis R. Rodriguez Date: Fri, 10 Aug 2012 01:24:54 +0000 (-0700) Subject: compat: backport mod_delayed_work() usage instead of cancel + queue X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=c860c5e7310fcb43a099ef8ffde3706592658c13;p=openwrt%2Fstaging%2Fblogic.git compat: backport mod_delayed_work() usage instead of cancel + queue The patch below is backported by using cancel_delayed_work() followed by mod_delayed_work(). mod_delayed_work() will be introduced on v3.7, so we add this backport onto the 3.7 backport files. The commit that inroduced mod_delayed_work(): mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 8376fe22 next-20120809~16^2~2 The reason we are backporting this: commit 7adf612cacb5d49778201eb06cc54281570eeb21 Author: Tejun Heo Date: Fri Aug 3 10:30:47 2012 -0700 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 Acked-by: Henrique de Moraes Holschuh Acked-by: Dmitry Torokhov Acked-by: Anton Vorontsov Cc: Tomi Valkeinen Cc: Jens Axboe Cc: Jiri Kosina Cc: Doug Thompson Cc: David Airlie Cc: Roland Dreier Cc: "John W. Linville" Cc: Zhang Rui Cc: Len Brown Cc: David Howells Cc: "J. Bruce Fields" Cc: Johannes Berg mcgrof@garbanzo ~/compat (git::master)$ gcc --version gcc (Debian 4.7.1-2) 4.7.1 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. mcgrof@garbanzo ~/compat (git::master)$ ckmake Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- diff --git a/compat/Makefile b/compat/Makefile index 23c1296c36e9..a44b34593e65 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -45,6 +45,7 @@ compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_KERNEL_3_3) += \ compat-3.3.o compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o +compat-$(CONFIG_COMPAT_KERNEL_3_7) += compat-3.7.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o compat-$(CONFIG_COMPAT_CRC8) += crc8.o diff --git a/compat/compat-3.7.c b/compat/compat-3.7.c new file mode 100644 index 000000000000..8fd07ff9aacc --- /dev/null +++ b/compat/compat-3.7.c @@ -0,0 +1,19 @@ +/* + * Copyright 2012 Luis R. Rodriguez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Compatibility file for Linux wireless for kernels 3.7. + */ + +#include + +bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, + unsigned long delay) +{ + cancel_delayed_work(dwork); + queue_delayed_work(wq, dwork, delay); +} +EXPORT_SYMBOL_GPL(mod_delayed_work); diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 7aaa84836299..46ae654133a8 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -64,5 +64,6 @@ void compat_dependency_symbol(void); #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h new file mode 100644 index 000000000000..e113e80d29b7 --- /dev/null +++ b/include/linux/compat-3.7.h @@ -0,0 +1,15 @@ +#ifndef LINUX_3_7_COMPAT_H +#define LINUX_3_7_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) + +#include + +bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, + unsigned long delay); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) */ + +#endif /* LINUX_3_7_COMPAT_H */