mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
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 <[email protected]>
Acked-by: Henrique de Moraes Holschuh <[email protected]>
Acked-by: Dmitry Torokhov <[email protected]>
Acked-by: Anton Vorontsov <[email protected]>
Acked-by: David Howells <[email protected]>
Cc: Tomi Valkeinen <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Jiri Kosina <[email protected]>
Cc: Doug Thompson <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Roland Dreier <[email protected]>
Cc: "John W. Linville" <[email protected]>
Cc: Zhang Rui <[email protected]>
Cc: Len Brown <[email protected]>
Cc: "J. Bruce Fields" <[email protected]>
Cc: Johannes Berg <[email protected]>
This commit is contained in:
parent
8376fe22c7
commit
41f63c5359
18 changed files with 41 additions and 105 deletions
|
|
@ -509,9 +509,8 @@ static void _setup_polling(struct work_struct *work)
|
|||
if (!delayed_work_pending(&cm_monitor_work) ||
|
||||
(delayed_work_pending(&cm_monitor_work) &&
|
||||
time_after(next_polling, _next_polling))) {
|
||||
cancel_delayed_work_sync(&cm_monitor_work);
|
||||
next_polling = jiffies + polling_jiffy;
|
||||
queue_delayed_work(cm_wq, &cm_monitor_work, polling_jiffy);
|
||||
mod_delayed_work(cm_wq, &cm_monitor_work, polling_jiffy);
|
||||
}
|
||||
|
||||
out:
|
||||
|
|
@ -546,10 +545,8 @@ static void fullbatt_handler(struct charger_manager *cm)
|
|||
if (cm_suspended)
|
||||
device_set_wakeup_capable(cm->dev, true);
|
||||
|
||||
if (delayed_work_pending(&cm->fullbatt_vchk_work))
|
||||
cancel_delayed_work(&cm->fullbatt_vchk_work);
|
||||
queue_delayed_work(cm_wq, &cm->fullbatt_vchk_work,
|
||||
msecs_to_jiffies(desc->fullbatt_vchkdrop_ms));
|
||||
mod_delayed_work(cm_wq, &cm->fullbatt_vchk_work,
|
||||
msecs_to_jiffies(desc->fullbatt_vchkdrop_ms));
|
||||
cm->fullbatt_vchk_jiffies_at = jiffies + msecs_to_jiffies(
|
||||
desc->fullbatt_vchkdrop_ms);
|
||||
|
||||
|
|
|
|||
|
|
@ -355,8 +355,7 @@ static void ds2760_battery_external_power_changed(struct power_supply *psy)
|
|||
|
||||
dev_dbg(di->dev, "%s\n", __func__);
|
||||
|
||||
cancel_delayed_work(&di->monitor_work);
|
||||
queue_delayed_work(di->monitor_wqueue, &di->monitor_work, HZ/10);
|
||||
mod_delayed_work(di->monitor_wqueue, &di->monitor_work, HZ/10);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -401,8 +400,7 @@ static void ds2760_battery_set_charged(struct power_supply *psy)
|
|||
|
||||
/* postpone the actual work by 20 secs. This is for debouncing GPIO
|
||||
* signals and to let the current value settle. See AN4188. */
|
||||
cancel_delayed_work(&di->set_charged_work);
|
||||
queue_delayed_work(di->monitor_wqueue, &di->set_charged_work, HZ * 20);
|
||||
mod_delayed_work(di->monitor_wqueue, &di->set_charged_work, HZ * 20);
|
||||
}
|
||||
|
||||
static int ds2760_battery_get_property(struct power_supply *psy,
|
||||
|
|
@ -616,8 +614,7 @@ static int ds2760_battery_resume(struct platform_device *pdev)
|
|||
di->charge_status = POWER_SUPPLY_STATUS_UNKNOWN;
|
||||
power_supply_changed(&di->bat);
|
||||
|
||||
cancel_delayed_work(&di->monitor_work);
|
||||
queue_delayed_work(di->monitor_wqueue, &di->monitor_work, HZ);
|
||||
mod_delayed_work(di->monitor_wqueue, &di->monitor_work, HZ);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,16 +173,14 @@ static void jz_battery_external_power_changed(struct power_supply *psy)
|
|||
{
|
||||
struct jz_battery *jz_battery = psy_to_jz_battery(psy);
|
||||
|
||||
cancel_delayed_work(&jz_battery->work);
|
||||
schedule_delayed_work(&jz_battery->work, 0);
|
||||
mod_delayed_work(system_wq, &jz_battery->work, 0);
|
||||
}
|
||||
|
||||
static irqreturn_t jz_battery_charge_irq(int irq, void *data)
|
||||
{
|
||||
struct jz_battery *jz_battery = data;
|
||||
|
||||
cancel_delayed_work(&jz_battery->work);
|
||||
schedule_delayed_work(&jz_battery->work, 0);
|
||||
mod_delayed_work(system_wq, &jz_battery->work, 0);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue