Skip to contentSkip to conversation

net: phy: allow for reset line to be tied to a sleepy GPIO controller

PATCH Applied Andrea Merello 3 participants 3 messages Oct 4, 2019 – Oct 5, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: allow for reset line to be tied to a sleepy GPIO controller

mdio_device_reset() makes use of the atomic-pretending API flavor for handling the PHY reset GPIO line.

I found no hint that mdio_device_reset() is called from atomic context and indeed it uses usleep_range() since long time, so I would assume that it is OK to sleep there.

This patch switch to gpiod_set_value_cansleep() in mdio_device_reset(). This is relevant if e.g. the PHY reset line is tied to a I2C GPIO controller.

This has been tested on a ZynqMP board running an upstream 4.19 kernel and then hand-ported on current kernel tree.

---
 drivers/net/phy/mdio_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/mdio_device.c +1 -1
index e282600bd83e..c1d345c3cab3 100644
@@ -121,7 +121,7 @@ void mdio_device_reset(struct mdio_device *mdiodev, int value)
 		return;
 
 	if (mdiodev->reset_gpio)
-		gpiod_set_value(mdiodev->reset_gpio, value);
+		gpiod_set_value_cansleep(mdiodev->reset_gpio, value);
 
 	if (mdiodev->reset_ctrl) {
 		if (value)
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Andrea Merello

mdio_device_reset() makes use of the atomic-pretending API flavor for handling the PHY reset GPIO line.

I found no hint that mdio_device_reset() is called from atomic context and indeed it uses usleep_range() since long time, so I would assume that it is OK to sleep there.

Quoted 8 lines

This patch switch to gpiod_set_value_cansleep() in mdio_device_reset(). This is relevant if e.g. the PHY reset line is tied to a I2C GPIO controller.

This has been tested on a ZynqMP board running an upstream 4.19 kernel and then hand-ported on current kernel tree.

Yes, all the other bits of code using GPIOs are using the _cansleep versions.

Andrew

maintainer Applied
#2 lore raw
In reply to Andrea Merello

From: Andrea Merello <[email protected]>
Date: Fri, 4 Oct 2019 15:53:32 +0200

Quoted 7 lines

mdio_device_reset() makes use of the atomic-pretending API flavor for handling the PHY reset GPIO line.

I found no hint that mdio_device_reset() is called from atomic context and indeed it uses usleep_range() since long time, so I would assume that it is OK to sleep there.

Quoted 8 lines

This patch switch to gpiod_set_value_cansleep() in mdio_device_reset(). This is relevant if e.g. the PHY reset line is tied to a I2C GPIO controller.

This has been tested on a ZynqMP board running an upstream 4.19 kernel and then hand-ported on current kernel tree.

Applied.