net: fec: handle small PHY reset durations more precisely
authorStefan Wahren <stefan.wahren@i2se.com>
Wed, 8 Jun 2016 20:42:46 +0000 (20:42 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 13 Jun 2016 01:58:10 +0000 (21:58 -0400)
Since msleep is based on jiffies the PHY reset could take longer
than expected. So use msleep for values greater than 20 msec otherwise
usleep_range.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/fec_main.c

index fea0f330ddbdeb2a5cf99b81f30e46919d066f62..c36401e5990583075a75a79636d977ddc258bc8f 100644 (file)
@@ -3191,7 +3191,12 @@ static void fec_reset_phy(struct platform_device *pdev)
                dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err);
                return;
        }
-       msleep(msec);
+
+       if (msec > 20)
+               msleep(msec);
+       else
+               usleep_range(msec * 1000, msec * 1000 + 1000);
+
        gpio_set_value_cansleep(phy_reset, !active_high);
 }
 #else /* CONFIG_OF */