Skip to content

Commit

Permalink
net: fec: Do a sanity check on the gpio number
Browse files Browse the repository at this point in the history
Check whether the phy-reset GPIO is valid, prior to requesting it.

In the case a board does not provide a phy-reset GPIO, just returns immediately.

With such gpio validation in place, it is also safe to change from pr_debug to
dev_err in the case the gpio request fails.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Fabio Estevam authored and David S. Miller committed Feb 19, 2013
1 parent eb6b9a8 commit 07dcf8e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/ethernet/freescale/fec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1689,10 +1689,13 @@ static void fec_reset_phy(struct platform_device *pdev)
msec = 1;

phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
if (!gpio_is_valid(phy_reset))
return;

err = devm_gpio_request_one(&pdev->dev, phy_reset,
GPIOF_OUT_INIT_LOW, "phy-reset");
if (err) {
pr_debug("FEC: failed to get gpio phy-reset: %d\n", err);
dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err);
return;
}
msleep(msec);
Expand Down

0 comments on commit 07dcf8e

Please sign in to comment.