@@ -438,10 +438,14 @@ static void devfreq_monitor(struct work_struct *work)
438
438
if (err )
439
439
dev_err (& devfreq -> dev , "dvfs failed with (%d) error\n" , err );
440
440
441
+ if (devfreq -> stop_polling )
442
+ goto out ;
443
+
441
444
queue_delayed_work (devfreq_wq , & devfreq -> work ,
442
445
msecs_to_jiffies (devfreq -> profile -> polling_ms ));
443
- mutex_unlock (& devfreq -> lock );
444
446
447
+ out :
448
+ mutex_unlock (& devfreq -> lock );
445
449
trace_devfreq_monitor (devfreq );
446
450
}
447
451
@@ -459,6 +463,10 @@ void devfreq_monitor_start(struct devfreq *devfreq)
459
463
if (devfreq -> governor -> interrupt_driven )
460
464
return ;
461
465
466
+ mutex_lock (& devfreq -> lock );
467
+ if (delayed_work_pending (& devfreq -> work ))
468
+ goto out ;
469
+
462
470
switch (devfreq -> profile -> timer ) {
463
471
case DEVFREQ_TIMER_DEFERRABLE :
464
472
INIT_DEFERRABLE_WORK (& devfreq -> work , devfreq_monitor );
@@ -467,12 +475,16 @@ void devfreq_monitor_start(struct devfreq *devfreq)
467
475
INIT_DELAYED_WORK (& devfreq -> work , devfreq_monitor );
468
476
break ;
469
477
default :
470
- return ;
478
+ goto out ;
471
479
}
472
480
473
481
if (devfreq -> profile -> polling_ms )
474
482
queue_delayed_work (devfreq_wq , & devfreq -> work ,
475
483
msecs_to_jiffies (devfreq -> profile -> polling_ms ));
484
+
485
+ out :
486
+ devfreq -> stop_polling = false;
487
+ mutex_unlock (& devfreq -> lock );
476
488
}
477
489
EXPORT_SYMBOL (devfreq_monitor_start );
478
490
@@ -489,6 +501,14 @@ void devfreq_monitor_stop(struct devfreq *devfreq)
489
501
if (devfreq -> governor -> interrupt_driven )
490
502
return ;
491
503
504
+ mutex_lock (& devfreq -> lock );
505
+ if (devfreq -> stop_polling ) {
506
+ mutex_unlock (& devfreq -> lock );
507
+ return ;
508
+ }
509
+
510
+ devfreq -> stop_polling = true;
511
+ mutex_unlock (& devfreq -> lock );
492
512
cancel_delayed_work_sync (& devfreq -> work );
493
513
}
494
514
EXPORT_SYMBOL (devfreq_monitor_stop );
0 commit comments