@@ -30,9 +30,9 @@ static inline unsigned int get_irq_flags(struct resource *res)
30
30
static struct device * dev ;
31
31
static struct pda_power_pdata * pdata ;
32
32
static struct resource * ac_irq , * usb_irq ;
33
- static struct timer_list charger_timer ;
34
- static struct timer_list supply_timer ;
35
- static struct timer_list polling_timer ;
33
+ static struct delayed_work charger_work ;
34
+ static struct delayed_work polling_work ;
35
+ static struct delayed_work supply_work ;
36
36
static int polling ;
37
37
38
38
#if IS_ENABLED (CONFIG_USB_PHY )
@@ -143,7 +143,7 @@ static void update_charger(void)
143
143
}
144
144
}
145
145
146
- static void supply_timer_func ( unsigned long unused )
146
+ static void supply_work_func ( struct work_struct * work )
147
147
{
148
148
if (ac_status == PDA_PSY_TO_CHANGE ) {
149
149
ac_status = new_ac_status ;
@@ -164,11 +164,12 @@ static void psy_changed(void)
164
164
* Okay, charger set. Now wait a bit before notifying supplicants,
165
165
* charge power should stabilize.
166
166
*/
167
- mod_timer (& supply_timer ,
168
- jiffies + msecs_to_jiffies (pdata -> wait_for_charger ));
167
+ cancel_delayed_work (& supply_work );
168
+ schedule_delayed_work (& supply_work ,
169
+ msecs_to_jiffies (pdata -> wait_for_charger ));
169
170
}
170
171
171
- static void charger_timer_func ( unsigned long unused )
172
+ static void charger_work_func ( struct work_struct * work )
172
173
{
173
174
update_status ();
174
175
psy_changed ();
@@ -187,13 +188,14 @@ static irqreturn_t power_changed_isr(int irq, void *power_supply)
187
188
* Wait a bit before reading ac/usb line status and setting charger,
188
189
* because ac/usb status readings may lag from irq.
189
190
*/
190
- mod_timer (& charger_timer ,
191
- jiffies + msecs_to_jiffies (pdata -> wait_for_status ));
191
+ cancel_delayed_work (& charger_work );
192
+ schedule_delayed_work (& charger_work ,
193
+ msecs_to_jiffies (pdata -> wait_for_status ));
192
194
193
195
return IRQ_HANDLED ;
194
196
}
195
197
196
- static void polling_timer_func ( unsigned long unused )
198
+ static void polling_work_func ( struct work_struct * work )
197
199
{
198
200
int changed = 0 ;
199
201
@@ -214,8 +216,9 @@ static void polling_timer_func(unsigned long unused)
214
216
if (changed )
215
217
psy_changed ();
216
218
217
- mod_timer (& polling_timer ,
218
- jiffies + msecs_to_jiffies (pdata -> polling_interval ));
219
+ cancel_delayed_work (& polling_work );
220
+ schedule_delayed_work (& polling_work ,
221
+ msecs_to_jiffies (pdata -> polling_interval ));
219
222
}
220
223
221
224
#if IS_ENABLED (CONFIG_USB_PHY )
@@ -253,8 +256,9 @@ static int otg_handle_notification(struct notifier_block *nb,
253
256
* Wait a bit before reading ac/usb line status and setting charger,
254
257
* because ac/usb status readings may lag from irq.
255
258
*/
256
- mod_timer (& charger_timer ,
257
- jiffies + msecs_to_jiffies (pdata -> wait_for_status ));
259
+ cancel_delayed_work (& charger_work );
260
+ schedule_delayed_work (& charger_work ,
261
+ msecs_to_jiffies (pdata -> wait_for_status ));
258
262
259
263
return NOTIFY_OK ;
260
264
}
@@ -302,8 +306,8 @@ static int pda_power_probe(struct platform_device *pdev)
302
306
if (!pdata -> ac_max_uA )
303
307
pdata -> ac_max_uA = 500000 ;
304
308
305
- setup_timer ( & charger_timer , charger_timer_func , 0 );
306
- setup_timer ( & supply_timer , supply_timer_func , 0 );
309
+ INIT_DELAYED_WORK ( & charger_work , charger_work_func );
310
+ INIT_DELAYED_WORK ( & supply_work , supply_work_func );
307
311
308
312
ac_irq = platform_get_resource_byname (pdev , IORESOURCE_IRQ , "ac" );
309
313
usb_irq = platform_get_resource_byname (pdev , IORESOURCE_IRQ , "usb" );
@@ -381,9 +385,10 @@ static int pda_power_probe(struct platform_device *pdev)
381
385
382
386
if (polling ) {
383
387
dev_dbg (dev , "will poll for status\n" );
384
- setup_timer (& polling_timer , polling_timer_func , 0 );
385
- mod_timer (& polling_timer ,
386
- jiffies + msecs_to_jiffies (pdata -> polling_interval ));
388
+ INIT_DELAYED_WORK (& polling_work , polling_work_func );
389
+ cancel_delayed_work (& polling_work );
390
+ schedule_delayed_work (& polling_work ,
391
+ msecs_to_jiffies (pdata -> polling_interval ));
387
392
}
388
393
389
394
if (ac_irq || usb_irq )
@@ -429,9 +434,9 @@ static int pda_power_remove(struct platform_device *pdev)
429
434
free_irq (ac_irq -> start , & pda_psy_ac );
430
435
431
436
if (polling )
432
- del_timer_sync ( & polling_timer );
433
- del_timer_sync ( & charger_timer );
434
- del_timer_sync ( & supply_timer );
437
+ cancel_delayed_work_sync ( & polling_work );
438
+ cancel_delayed_work_sync ( & charger_work );
439
+ cancel_delayed_work_sync ( & supply_work );
435
440
436
441
if (pdata -> is_usb_online )
437
442
power_supply_unregister (& pda_psy_usb );
0 commit comments