net: stmmac: avoid using timespec
authorArnd Bergmann <arnd@arndb.de>
Wed, 30 Sep 2015 11:26:32 +0000 (13:26 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 5 Oct 2015 10:16:41 +0000 (03:16 -0700)
We want to deprecate the use of 'struct timespec' on 32-bit
architectures, as it is will overflow in 2038. The stmmac
driver uses it to read the current time, and can simply
be changed to use ktime_get_real_ts64() instead.

Because of hardware limitations, there is still an overflow
in year 2106, which we cannot really avoid, but this documents
the overflow.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 934143e1193bebda911b549381444f5aa3d368c1..64d8aa4e0cad6420bcb1fa4cd827ad823ba3601d 100644 (file)
@@ -424,7 +424,7 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
 {
        struct stmmac_priv *priv = netdev_priv(dev);
        struct hwtstamp_config config;
-       struct timespec now;
+       struct timespec64 now;
        u64 temp = 0;
        u32 ptp_v2 = 0;
        u32 tstamp_all = 0;
@@ -621,8 +621,10 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
                                             priv->default_addend);
 
                /* initialize system time */
-               getnstimeofday(&now);
-               priv->hw->ptp->init_systime(priv->ioaddr, now.tv_sec,
+               ktime_get_real_ts64(&now);
+
+               /* lower 32 bits of tv_sec are safe until y2106 */
+               priv->hw->ptp->init_systime(priv->ioaddr, (u32)now.tv_sec,
                                            now.tv_nsec);
        }