Skip to content

Commit

Permalink
power_supply: Don't use flush_scheduled_work()
Browse files Browse the repository at this point in the history
flush_scheduled_work() is deprecated and scheduled to be removed.

In battery drivers, the work can be canceled on probe failure and
removal and should be flushed on suspend.  Replace
flush_scheduled_work() usages with direct cancels and flushes.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
  • Loading branch information
Tejun Heo authored and Anton Vorontsov committed Dec 21, 2010
1 parent 3a2dbd6 commit bc51e7f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
13 changes: 6 additions & 7 deletions drivers/power/collie_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ static struct {
static int collie_bat_suspend(struct ucb1x00_dev *dev, pm_message_t state)
{
/* flush all pending status updates */
flush_scheduled_work();
flush_work_sync(&bat_work);
return 0;
}

Expand Down Expand Up @@ -362,7 +362,7 @@ static int __devinit collie_bat_probe(struct ucb1x00_dev *dev)
err_psy_reg_main:

/* see comment in collie_bat_remove */
flush_scheduled_work();
cancel_work_sync(&bat_work);

i--;
err_gpio:
Expand All @@ -382,12 +382,11 @@ static void __devexit collie_bat_remove(struct ucb1x00_dev *dev)
power_supply_unregister(&collie_bat_main.psy);

/*
* now flush all pending work.
* we won't get any more schedules, since all
* sources (isr and external_power_changed)
* are unregistered now.
* Now cancel the bat_work. We won't get any more schedules,
* since all sources (isr and external_power_changed) are
* unregistered now.
*/
flush_scheduled_work();
cancel_work_sync(&bat_work);

for (i = ARRAY_SIZE(gpios) - 1; i >= 0; i--)
gpio_free(gpios[i].gpio);
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/intel_mid_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ static int __devexit platform_pmic_battery_remove(struct platform_device *pdev)
power_supply_unregister(&pbi->usb);
power_supply_unregister(&pbi->batt);

flush_scheduled_work();
cancel_work_sync(&pbi->handler);
kfree(pbi);
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/power_supply_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ EXPORT_SYMBOL_GPL(power_supply_register);

void power_supply_unregister(struct power_supply *psy)
{
flush_scheduled_work();
cancel_work_sync(&psy->changed_work);
power_supply_remove_triggers(psy);
device_unregister(psy->dev);
}
Expand Down
13 changes: 6 additions & 7 deletions drivers/power/tosa_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ static struct {
static int tosa_bat_suspend(struct platform_device *dev, pm_message_t state)
{
/* flush all pending status updates */
flush_scheduled_work();
flush_work_sync(&bat_work);
return 0;
}

Expand Down Expand Up @@ -422,7 +422,7 @@ static int __devinit tosa_bat_probe(struct platform_device *dev)
err_psy_reg_main:

/* see comment in tosa_bat_remove */
flush_scheduled_work();
cancel_work_sync(&bat_work);

i--;
err_gpio:
Expand All @@ -445,12 +445,11 @@ static int __devexit tosa_bat_remove(struct platform_device *dev)
power_supply_unregister(&tosa_bat_main.psy);

/*
* now flush all pending work.
* we won't get any more schedules, since all
* sources (isr and external_power_changed)
* are unregistered now.
* Now cancel the bat_work. We won't get any more schedules,
* since all sources (isr and external_power_changed) are
* unregistered now.
*/
flush_scheduled_work();
cancel_work_sync(&bat_work);

for (i = ARRAY_SIZE(gpios) - 1; i >= 0; i--)
gpio_free(gpios[i].gpio);
Expand Down
4 changes: 2 additions & 2 deletions drivers/power/wm97xx_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static irqreturn_t wm97xx_chrg_irq(int irq, void *data)
#ifdef CONFIG_PM
static int wm97xx_bat_suspend(struct device *dev)
{
flush_scheduled_work();
flush_work_sync(&bat_work);
return 0;
}

Expand Down Expand Up @@ -273,7 +273,7 @@ static int __devexit wm97xx_bat_remove(struct platform_device *dev)
free_irq(gpio_to_irq(pdata->charge_gpio), dev);
gpio_free(pdata->charge_gpio);
}
flush_scheduled_work();
cancel_work_sync(&bat_work);
power_supply_unregister(&bat_ps);
kfree(prop);
return 0;
Expand Down
6 changes: 4 additions & 2 deletions drivers/power/z2_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static int __devexit z2_batt_remove(struct i2c_client *client)
struct z2_charger *charger = i2c_get_clientdata(client);
struct z2_battery_info *info = charger->info;

flush_scheduled_work();
cancel_work_sync(&charger->bat_work);
power_supply_unregister(&charger->batt_ps);

kfree(charger->batt_ps.properties);
Expand All @@ -271,7 +271,9 @@ static int __devexit z2_batt_remove(struct i2c_client *client)
#ifdef CONFIG_PM
static int z2_batt_suspend(struct i2c_client *client, pm_message_t state)
{
flush_scheduled_work();
struct z2_charger *charger = i2c_get_clientdata(client);

flush_work_sync(&charger->bat_work);
return 0;
}

Expand Down

0 comments on commit bc51e7f

Please sign in to comment.