net: fec: Do a sanity check on the gpio number
authorFabio Estevam <fabio.estevam@freescale.com>
Mon, 18 Feb 2013 10:20:31 +0000 (10:20 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 19 Feb 2013 05:51:09 +0000 (00:51 -0500)
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>
drivers/net/ethernet/freescale/fec.c

index 0fe68c46267ebbb6538644c884f322c2d890510d..29d82cf1528e237b874b0cbbb51a37d6ce0d254e 100644 (file)
@@ -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);