Skip to content

Commit 468ba54

Browse files
arndbdavem330
authored andcommitted
fec: convert to gpio descriptor
The driver can be trivially converted, as it only triggers the gpio pin briefly to do a reset, and it already only supports DT. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 453d9fd commit 468ba54

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@
5656
#include <linux/fec.h>
5757
#include <linux/of.h>
5858
#include <linux/of_device.h>
59-
#include <linux/of_gpio.h>
6059
#include <linux/of_mdio.h>
6160
#include <linux/of_net.h>
6261
#include <linux/regulator/consumer.h>
6362
#include <linux/if_vlan.h>
6463
#include <linux/pinctrl/consumer.h>
64+
#include <linux/gpio/consumer.h>
6565
#include <linux/prefetch.h>
6666
#include <linux/mfd/syscon.h>
6767
#include <linux/regmap.h>
@@ -4035,10 +4035,11 @@ static int fec_enet_init(struct net_device *ndev)
40354035
#ifdef CONFIG_OF
40364036
static int fec_reset_phy(struct platform_device *pdev)
40374037
{
4038-
int err, phy_reset;
4038+
struct gpio_desc *phy_reset;
40394039
bool active_high = false;
40404040
int msec = 1, phy_post_delay = 0;
40414041
struct device_node *np = pdev->dev.of_node;
4042+
int err;
40424043

40434044
if (!np)
40444045
return 0;
@@ -4048,33 +4049,25 @@ static int fec_reset_phy(struct platform_device *pdev)
40484049
if (!err && msec > 1000)
40494050
msec = 1;
40504051

4051-
phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
4052-
if (phy_reset == -EPROBE_DEFER)
4053-
return phy_reset;
4054-
else if (!gpio_is_valid(phy_reset))
4055-
return 0;
4056-
40574052
err = of_property_read_u32(np, "phy-reset-post-delay", &phy_post_delay);
40584053
/* valid reset duration should be less than 1s */
40594054
if (!err && phy_post_delay > 1000)
40604055
return -EINVAL;
40614056

40624057
active_high = of_property_read_bool(np, "phy-reset-active-high");
40634058

4064-
err = devm_gpio_request_one(&pdev->dev, phy_reset,
4065-
active_high ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
4066-
"phy-reset");
4067-
if (err) {
4068-
dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err);
4069-
return err;
4070-
}
4059+
phy_reset = devm_gpiod_get(&pdev->dev, "phy-reset",
4060+
active_high ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW);
4061+
if (IS_ERR(phy_reset))
4062+
return dev_err_probe(&pdev->dev, PTR_ERR(phy_reset),
4063+
"failed to get phy-reset-gpios\n");
40714064

40724065
if (msec > 20)
40734066
msleep(msec);
40744067
else
40754068
usleep_range(msec * 1000, msec * 1000 + 1000);
40764069

4077-
gpio_set_value_cansleep(phy_reset, !active_high);
4070+
gpiod_set_value_cansleep(phy_reset, !active_high);
40784071

40794072
if (!phy_post_delay)
40804073
return 0;

0 commit comments

Comments
 (0)