Skip to content

Commit 61a1796

Browse files
Zach Browndavem330
authored andcommitted
net: phy: Encapsulate actions performed during link state changes into function phy_adjust_link
During phy state machine state transitions some set of actions should occur whenever the link state changes. These actions should be encapsulated into a single function This patch adds the phy_adjust_link function, which is called whenever phydev->adjust_link would have been called before. Actions that should occur whenever the phy link is adjusted can now be added to the phy_adjust_link function. Signed-off-by: Zach Brown <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0e0f27d commit 61a1796

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

drivers/net/phy/phy.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,11 @@ void phy_start(struct phy_device *phydev)
908908
}
909909
EXPORT_SYMBOL(phy_start);
910910

911+
static void phy_adjust_link(struct phy_device *phydev)
912+
{
913+
phydev->adjust_link(phydev->attached_dev);
914+
}
915+
911916
/**
912917
* phy_state_machine - Handle the state machine
913918
* @work: work_struct that describes the work to be done
@@ -950,7 +955,7 @@ void phy_state_machine(struct work_struct *work)
950955
if (!phydev->link) {
951956
phydev->state = PHY_NOLINK;
952957
netif_carrier_off(phydev->attached_dev);
953-
phydev->adjust_link(phydev->attached_dev);
958+
phy_adjust_link(phydev);
954959
break;
955960
}
956961

@@ -963,7 +968,7 @@ void phy_state_machine(struct work_struct *work)
963968
if (err > 0) {
964969
phydev->state = PHY_RUNNING;
965970
netif_carrier_on(phydev->attached_dev);
966-
phydev->adjust_link(phydev->attached_dev);
971+
phy_adjust_link(phydev);
967972

968973
} else if (0 == phydev->link_timeout--)
969974
needs_aneg = true;
@@ -990,7 +995,7 @@ void phy_state_machine(struct work_struct *work)
990995
}
991996
phydev->state = PHY_RUNNING;
992997
netif_carrier_on(phydev->attached_dev);
993-
phydev->adjust_link(phydev->attached_dev);
998+
phy_adjust_link(phydev);
994999
}
9951000
break;
9961001
case PHY_FORCING:
@@ -1006,7 +1011,7 @@ void phy_state_machine(struct work_struct *work)
10061011
needs_aneg = true;
10071012
}
10081013

1009-
phydev->adjust_link(phydev->attached_dev);
1014+
phy_adjust_link(phydev);
10101015
break;
10111016
case PHY_RUNNING:
10121017
/* Only register a CHANGE if we are polling and link changed
@@ -1035,7 +1040,7 @@ void phy_state_machine(struct work_struct *work)
10351040
netif_carrier_off(phydev->attached_dev);
10361041
}
10371042

1038-
phydev->adjust_link(phydev->attached_dev);
1043+
phy_adjust_link(phydev);
10391044

10401045
if (phy_interrupt_is_valid(phydev))
10411046
err = phy_config_interrupt(phydev,
@@ -1045,7 +1050,7 @@ void phy_state_machine(struct work_struct *work)
10451050
if (phydev->link) {
10461051
phydev->link = 0;
10471052
netif_carrier_off(phydev->attached_dev);
1048-
phydev->adjust_link(phydev->attached_dev);
1053+
phy_adjust_link(phydev);
10491054
do_suspend = true;
10501055
}
10511056
break;
@@ -1069,7 +1074,7 @@ void phy_state_machine(struct work_struct *work)
10691074
} else {
10701075
phydev->state = PHY_NOLINK;
10711076
}
1072-
phydev->adjust_link(phydev->attached_dev);
1077+
phy_adjust_link(phydev);
10731078
} else {
10741079
phydev->state = PHY_AN;
10751080
phydev->link_timeout = PHY_AN_TIMEOUT;
@@ -1085,7 +1090,7 @@ void phy_state_machine(struct work_struct *work)
10851090
} else {
10861091
phydev->state = PHY_NOLINK;
10871092
}
1088-
phydev->adjust_link(phydev->attached_dev);
1093+
phy_adjust_link(phydev);
10891094
}
10901095
break;
10911096
}

0 commit comments

Comments
 (0)