Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9911674f authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'ptp-ns_to_timespec64'



Richard Cochran says:

====================
ptp: remove open coded ns_to_timespec64 and reverse

This patch series is a follow up to the recent timespec64 work for the
PTP Hardware Clock drivers.  Arnd noticed that drivers are using open
coded implementations of ns_to_timespec64 and timespec64_to_ns.  This
series replaces the open coded logic with the helper functions.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents f6a69a8f 0704fae3
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -986,7 +986,6 @@ static int bfin_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
static int bfin_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
{
	u64 ns;
	u32 remainder;
	unsigned long flags;
	struct bfin_mac_local *lp =
		container_of(ptp, struct bfin_mac_local, caps);
@@ -997,8 +996,8 @@ static int bfin_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)

	spin_unlock_irqrestore(&lp->phc_lock, flags);

	ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
	ts->tv_nsec = remainder;
	*ts = ns_to_timespec64(ns);

	return 0;
}

@@ -1010,8 +1009,7 @@ static int bfin_ptp_settime(struct ptp_clock_info *ptp,
	struct bfin_mac_local *lp =
		container_of(ptp, struct bfin_mac_local, caps);

	ns = ts->tv_sec * 1000000000ULL;
	ns += ts->tv_nsec;
	ns = timespec64_to_ns(ts);

	spin_lock_irqsave(&lp->phc_lock, flags);

+2 −5
Original line number Diff line number Diff line
@@ -13290,14 +13290,12 @@ static int bnx2x_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
{
	struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
	u64 ns;
	u32 remainder;

	ns = timecounter_read(&bp->timecounter);

	DP(BNX2X_MSG_PTP, "PTP gettime called, ns = %llu\n", ns);

	ts->tv_sec = div_u64_rem(ns, 1000000000ULL, &remainder);
	ts->tv_nsec = remainder;
	*ts = ns_to_timespec64(ns);

	return 0;
}
@@ -13308,8 +13306,7 @@ static int bnx2x_ptp_settime(struct ptp_clock_info *ptp,
	struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
	u64 ns;

	ns = ts->tv_sec * 1000000000ULL;
	ns += ts->tv_nsec;
	ns = timespec64_to_ns(ts);

	DP(BNX2X_MSG_PTP, "PTP settime called, ns = %llu\n", ns);

+1 −3
Original line number Diff line number Diff line
@@ -6220,7 +6220,6 @@ static int tg3_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
static int tg3_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
{
	u64 ns;
	u32 remainder;
	struct tg3 *tp = container_of(ptp, struct tg3, ptp_info);

	tg3_full_lock(tp, 0);
@@ -6228,8 +6227,7 @@ static int tg3_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
	ns += tp->ptp_adjust;
	tg3_full_unlock(tp);

	ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
	ts->tv_nsec = remainder;
	*ts = ns_to_timespec64(ns);

	return 0;
}
+2 −5
Original line number Diff line number Diff line
@@ -395,15 +395,13 @@ static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
	struct fec_enet_private *adapter =
	    container_of(ptp, struct fec_enet_private, ptp_caps);
	u64 ns;
	u32 remainder;
	unsigned long flags;

	spin_lock_irqsave(&adapter->tmreg_lock, flags);
	ns = timecounter_read(&adapter->tc);
	spin_unlock_irqrestore(&adapter->tmreg_lock, flags);

	ts->tv_sec = div_u64_rem(ns, 1000000000ULL, &remainder);
	ts->tv_nsec = remainder;
	*ts = ns_to_timespec64(ns);

	return 0;
}
@@ -433,8 +431,7 @@ static int fec_ptp_settime(struct ptp_clock_info *ptp,
		return -EINVAL;
	}

	ns = ts->tv_sec * 1000000000ULL;
	ns += ts->tv_nsec;
	ns = timespec64_to_ns(ts);
	/* Get the timer value based on timestamp.
	 * Update the counter with the masked value.
	 */
+3 −5
Original line number Diff line number Diff line
@@ -326,7 +326,6 @@ static int ptp_gianfar_gettime(struct ptp_clock_info *ptp,
			       struct timespec64 *ts)
{
	u64 ns;
	u32 remainder;
	unsigned long flags;
	struct etsects *etsects = container_of(ptp, struct etsects, caps);

@@ -336,8 +335,8 @@ static int ptp_gianfar_gettime(struct ptp_clock_info *ptp,

	spin_unlock_irqrestore(&etsects->lock, flags);

	ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
	ts->tv_nsec = remainder;
	*ts = ns_to_timespec64(ns);

	return 0;
}

@@ -348,8 +347,7 @@ static int ptp_gianfar_settime(struct ptp_clock_info *ptp,
	unsigned long flags;
	struct etsects *etsects = container_of(ptp, struct etsects, caps);

	ns = ts->tv_sec * 1000000000ULL;
	ns += ts->tv_nsec;
	ns = timespec64_to_ns(ts);

	spin_lock_irqsave(&etsects->lock, flags);

Loading