1 From da62577632857d63e82467c524cdbbf0425f7eec Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@armlinux.org.uk>
3 Date: Tue, 28 May 2019 10:27:21 +0100
4 Subject: net: phylink: ensure consistent phy interface mode
6 [ Upstream commit c678726305b9425454be7c8a7624290b602602fc ]
8 Ensure that we supply the same phy interface mode to mac_link_down() as
9 we did for the corresponding mac_link_up() call. This ensures that MAC
10 drivers that use the phy interface mode in these methods can depend on
11 mac_link_down() always corresponding to a mac_link_up() call for the
14 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
15 Signed-off-by: David S. Miller <davem@davemloft.net>
16 Signed-off-by: Sasha Levin <sashal@kernel.org>
18 drivers/net/phy/phylink.c | 10 +++++++---
19 1 file changed, 7 insertions(+), 3 deletions(-)
21 diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
22 index c5a509129ae6..b7dafa9dfef4 100644
23 --- a/drivers/net/phy/phylink.c
24 +++ b/drivers/net/phy/phylink.c
25 @@ -54,6 +54,10 @@ struct phylink {
27 /* The link configuration settings */
28 struct phylink_link_state link_config;
30 + /* The current settings */
31 + phy_interface_t cur_interface;
33 struct gpio_desc *link_gpio;
34 struct timer_list link_poll;
35 void (*get_fixed_state)(struct net_device *dev,
36 @@ -477,12 +481,12 @@ static void phylink_resolve(struct work_struct *w)
37 if (!link_state.link) {
38 netif_carrier_off(ndev);
39 pl->ops->mac_link_down(ndev, pl->link_an_mode,
40 - pl->phy_state.interface);
42 netdev_info(ndev, "Link is Down\n");
44 + pl->cur_interface = link_state.interface;
45 pl->ops->mac_link_up(ndev, pl->link_an_mode,
46 - pl->phy_state.interface,
48 + pl->cur_interface, pl->phydev);
50 netif_carrier_on(ndev);