Merge branch 'timecounter-next'
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlx4 / en_clock.c
index 9990144..90b5309 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <linux/mlx4/device.h>
+#include <linux/clocksource.h>
 
 #include "mlx4_en.h"
 
@@ -147,12 +148,9 @@ static int mlx4_en_phc_adjtime(struct ptp_clock_info *ptp, s64 delta)
        struct mlx4_en_dev *mdev = container_of(ptp, struct mlx4_en_dev,
                                                ptp_clock_info);
        unsigned long flags;
-       s64 now;
 
        write_lock_irqsave(&mdev->clock_lock, flags);
-       now = timecounter_read(&mdev->clock);
-       now += delta;
-       timecounter_init(&mdev->clock, &mdev->cycles, now);
+       timecounter_adjtime(&mdev->clock, delta);
        write_unlock_irqrestore(&mdev->clock_lock, flags);
 
        return 0;
@@ -243,7 +241,7 @@ void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev)
 {
        struct mlx4_dev *dev = mdev->dev;
        unsigned long flags;
-       u64 ns;
+       u64 ns, zero = 0;
 
        rwlock_init(&mdev->clock_lock);
 
@@ -268,7 +266,7 @@ void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev)
        /* Calculate period in seconds to call the overflow watchdog - to make
         * sure counter is checked at least once every wrap around.
         */
-       ns = cyclecounter_cyc2ns(&mdev->cycles, mdev->cycles.mask);
+       ns = cyclecounter_cyc2ns(&mdev->cycles, mdev->cycles.mask, zero, &zero);
        do_div(ns, NSEC_PER_SEC / 2 / HZ);
        mdev->overflow_period = ns;