@@ -414,7 +414,6 @@ EXPORT_SYMBOL(phy_start_aneg);
414
414
415
415
static void phy_change (struct work_struct * work );
416
416
static void phy_state_machine (struct work_struct * work );
417
- static void phy_timer (unsigned long data );
418
417
419
418
/**
420
419
* phy_start_machine - start PHY state machine tracking
@@ -434,11 +433,8 @@ void phy_start_machine(struct phy_device *phydev,
434
433
{
435
434
phydev -> adjust_state = handler ;
436
435
437
- INIT_WORK (& phydev -> state_queue , phy_state_machine );
438
- init_timer (& phydev -> phy_timer );
439
- phydev -> phy_timer .function = & phy_timer ;
440
- phydev -> phy_timer .data = (unsigned long ) phydev ;
441
- mod_timer (& phydev -> phy_timer , jiffies + HZ );
436
+ INIT_DELAYED_WORK (& phydev -> state_queue , phy_state_machine );
437
+ schedule_delayed_work (& phydev -> state_queue , jiffies + HZ );
442
438
}
443
439
444
440
/**
@@ -451,8 +447,7 @@ void phy_start_machine(struct phy_device *phydev,
451
447
*/
452
448
void phy_stop_machine (struct phy_device * phydev )
453
449
{
454
- del_timer_sync (& phydev -> phy_timer );
455
- cancel_work_sync (& phydev -> state_queue );
450
+ cancel_delayed_work_sync (& phydev -> state_queue );
456
451
457
452
mutex_lock (& phydev -> lock );
458
453
if (phydev -> state > PHY_UP )
@@ -680,11 +675,9 @@ static void phy_change(struct work_struct *work)
680
675
if (err )
681
676
goto irq_enable_err ;
682
677
683
- /* Stop timer and run the state queue now. The work function for
684
- * state_queue will start the timer up again.
685
- */
686
- del_timer (& phydev -> phy_timer );
687
- schedule_work (& phydev -> state_queue );
678
+ /* reschedule state queue work to run as soon as possible */
679
+ cancel_delayed_work_sync (& phydev -> state_queue );
680
+ schedule_delayed_work (& phydev -> state_queue , 0 );
688
681
689
682
return ;
690
683
@@ -761,14 +754,13 @@ EXPORT_SYMBOL(phy_start);
761
754
/**
762
755
* phy_state_machine - Handle the state machine
763
756
* @work: work_struct that describes the work to be done
764
- *
765
- * Description: Scheduled by the state_queue workqueue each time
766
- * phy_timer is triggered.
767
757
*/
768
758
static void phy_state_machine (struct work_struct * work )
769
759
{
760
+ struct delayed_work * dwork =
761
+ container_of (work , struct delayed_work , work );
770
762
struct phy_device * phydev =
771
- container_of (work , struct phy_device , state_queue );
763
+ container_of (dwork , struct phy_device , state_queue );
772
764
int needs_aneg = 0 ;
773
765
int err = 0 ;
774
766
@@ -946,17 +938,6 @@ static void phy_state_machine(struct work_struct *work)
946
938
if (err < 0 )
947
939
phy_error (phydev );
948
940
949
- mod_timer (& phydev -> phy_timer , jiffies + PHY_STATE_TIME * HZ );
950
- }
951
-
952
- /* PHY timer which schedules the state machine work */
953
- static void phy_timer (unsigned long data )
954
- {
955
- struct phy_device * phydev = (struct phy_device * )data ;
956
-
957
- /*
958
- * PHY I/O operations can potentially sleep so we ensure that
959
- * it's done from a process context
960
- */
961
- schedule_work (& phydev -> state_queue );
941
+ schedule_delayed_work (& phydev -> state_queue ,
942
+ jiffies + PHY_STATE_TIME * HZ );
962
943
}
0 commit comments