Skip to content

Commit ab696fa

Browse files
committed
Merge branch 'net-phy-relax-PHY-and-MDIO-reset-handling'
Bartosz Golaszewski says: ==================== net: phy: relax PHY and MDIO reset handling Previously these patches were submitted as part of a larger series[1] but since the approach in it will have to be reworked I'm resending the ones that were non-controversial and have been reviewed for upstream. Florian suggested a better solution for managing multiple resets. While I will definitely try to implement something at the driver model's bus level (together with regulator support), the 'resets' and 'reset-gpios' DT property is a stable ABI defined in mdio.yaml so improving its support is in order as we'll have to stick with it anyway. Current implementation contains an unnecessary limitation where drivers without probe() can't define resets. Changes from the previous version: - order forward declarations in patch 4 alphabetically - collect review tags [1] https://lkml.org/lkml/2020/6/22/253 ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 61b5cc2 + 96e2635 commit ab696fa

File tree

4 files changed

+51
-50
lines changed

4 files changed

+51
-50
lines changed

drivers/net/phy/mdio_bus.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@
88

99
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1010

11-
#include <linux/kernel.h>
12-
#include <linux/string.h>
13-
#include <linux/errno.h>
14-
#include <linux/unistd.h>
15-
#include <linux/slab.h>
16-
#include <linux/interrupt.h>
17-
#include <linux/init.h>
1811
#include <linux/delay.h>
1912
#include <linux/device.h>
13+
#include <linux/errno.h>
14+
#include <linux/etherdevice.h>
15+
#include <linux/ethtool.h>
2016
#include <linux/gpio.h>
2117
#include <linux/gpio/consumer.h>
18+
#include <linux/init.h>
19+
#include <linux/interrupt.h>
20+
#include <linux/io.h>
21+
#include <linux/kernel.h>
22+
#include <linux/mii.h>
23+
#include <linux/mm.h>
24+
#include <linux/module.h>
25+
#include <linux/netdevice.h>
2226
#include <linux/of_device.h>
23-
#include <linux/of_mdio.h>
2427
#include <linux/of_gpio.h>
25-
#include <linux/netdevice.h>
26-
#include <linux/etherdevice.h>
28+
#include <linux/of_mdio.h>
29+
#include <linux/phy.h>
2730
#include <linux/reset.h>
2831
#include <linux/skbuff.h>
32+
#include <linux/slab.h>
2933
#include <linux/spinlock.h>
30-
#include <linux/mm.h>
31-
#include <linux/module.h>
32-
#include <linux/mii.h>
33-
#include <linux/ethtool.h>
34-
#include <linux/phy.h>
35-
#include <linux/io.h>
34+
#include <linux/string.h>
3635
#include <linux/uaccess.h>
36+
#include <linux/unistd.h>
3737

3838
#define CREATE_TRACE_POINTS
3939
#include <trace/events/mdio.h>

drivers/net/phy/mdio_device.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
88

9+
#include <linux/delay.h>
910
#include <linux/errno.h>
1011
#include <linux/gpio.h>
1112
#include <linux/gpio/consumer.h>
@@ -20,7 +21,6 @@
2021
#include <linux/slab.h>
2122
#include <linux/string.h>
2223
#include <linux/unistd.h>
23-
#include <linux/delay.h>
2424

2525
void mdio_device_free(struct mdio_device *mdiodev)
2626
{
@@ -150,10 +150,10 @@ static int mdio_probe(struct device *dev)
150150
struct mdio_driver *mdiodrv = to_mdio_driver(drv);
151151
int err = 0;
152152

153-
if (mdiodrv->probe) {
154-
/* Deassert the reset signal */
155-
mdio_device_reset(mdiodev, 0);
153+
/* Deassert the reset signal */
154+
mdio_device_reset(mdiodev, 0);
156155

156+
if (mdiodrv->probe) {
157157
err = mdiodrv->probe(mdiodev);
158158
if (err) {
159159
/* Assert the reset signal */
@@ -170,12 +170,11 @@ static int mdio_remove(struct device *dev)
170170
struct device_driver *drv = mdiodev->dev.driver;
171171
struct mdio_driver *mdiodrv = to_mdio_driver(drv);
172172

173-
if (mdiodrv->remove) {
173+
if (mdiodrv->remove)
174174
mdiodrv->remove(mdiodev);
175175

176-
/* Assert the reset signal */
177-
mdio_device_reset(mdiodev, 1);
178-
}
176+
/* Assert the reset signal */
177+
mdio_device_reset(mdiodev, 1);
179178

180179
return 0;
181180
}

drivers/net/phy/phy_device.c

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@
99

1010
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1111

12-
#include <linux/kernel.h>
13-
#include <linux/string.h>
14-
#include <linux/errno.h>
15-
#include <linux/unistd.h>
16-
#include <linux/slab.h>
17-
#include <linux/interrupt.h>
18-
#include <linux/init.h>
12+
#include <linux/bitmap.h>
1913
#include <linux/delay.h>
20-
#include <linux/netdevice.h>
14+
#include <linux/errno.h>
2115
#include <linux/etherdevice.h>
22-
#include <linux/skbuff.h>
16+
#include <linux/ethtool.h>
17+
#include <linux/init.h>
18+
#include <linux/interrupt.h>
19+
#include <linux/io.h>
20+
#include <linux/kernel.h>
21+
#include <linux/mdio.h>
22+
#include <linux/mii.h>
2323
#include <linux/mm.h>
2424
#include <linux/module.h>
25-
#include <linux/mii.h>
26-
#include <linux/ethtool.h>
27-
#include <linux/bitmap.h>
25+
#include <linux/netdevice.h>
2826
#include <linux/phy.h>
2927
#include <linux/phy_led_triggers.h>
28+
#include <linux/property.h>
3029
#include <linux/sfp.h>
31-
#include <linux/mdio.h>
32-
#include <linux/io.h>
30+
#include <linux/skbuff.h>
31+
#include <linux/slab.h>
32+
#include <linux/string.h>
3333
#include <linux/uaccess.h>
34-
#include <linux/property.h>
34+
#include <linux/unistd.h>
3535

3636
MODULE_DESCRIPTION("PHY library");
3737
MODULE_AUTHOR("Andy Fleming");
@@ -2846,16 +2846,13 @@ static int phy_probe(struct device *dev)
28462846

28472847
mutex_lock(&phydev->lock);
28482848

2849-
if (phydev->drv->probe) {
2850-
/* Deassert the reset signal */
2851-
phy_device_reset(phydev, 0);
2849+
/* Deassert the reset signal */
2850+
phy_device_reset(phydev, 0);
28522851

2852+
if (phydev->drv->probe) {
28532853
err = phydev->drv->probe(phydev);
2854-
if (err) {
2855-
/* Assert the reset signal */
2856-
phy_device_reset(phydev, 1);
2854+
if (err)
28572855
goto out;
2858-
}
28592856
}
28602857

28612858
/* Start out supporting everything. Eventually,
@@ -2917,6 +2914,10 @@ static int phy_probe(struct device *dev)
29172914
phydev->state = PHY_READY;
29182915

29192916
out:
2917+
/* Assert the reset signal */
2918+
if (err)
2919+
phy_device_reset(phydev, 1);
2920+
29202921
mutex_unlock(&phydev->lock);
29212922

29222923
return err;
@@ -2935,12 +2936,12 @@ static int phy_remove(struct device *dev)
29352936
sfp_bus_del_upstream(phydev->sfp_bus);
29362937
phydev->sfp_bus = NULL;
29372938

2938-
if (phydev->drv && phydev->drv->remove) {
2939+
if (phydev->drv && phydev->drv->remove)
29392940
phydev->drv->remove(phydev);
29402941

2941-
/* Assert the reset signal */
2942-
phy_device_reset(phydev, 1);
2943-
}
2942+
/* Assert the reset signal */
2943+
phy_device_reset(phydev, 1);
2944+
29442945
phydev->drv = NULL;
29452946

29462947
return 0;

include/linux/mdio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
struct gpio_desc;
2020
struct mii_bus;
21+
struct reset_control;
2122

2223
/* Multiple levels of nesting are possible. However typically this is
2324
* limited to nested DSA like layer, a MUX layer, and the normal

0 commit comments

Comments
 (0)