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: David S. Miller <davem@davemloft.net>
This commit is contained in:
Коммит
9911674fcf
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -111,15 +111,13 @@ static int e1000e_phc_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
|
|||
struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter,
|
||||
ptp_clock_info);
|
||||
unsigned long flags;
|
||||
u32 remainder;
|
||||
u64 ns;
|
||||
|
||||
spin_lock_irqsave(&adapter->systim_lock, flags);
|
||||
ns = timecounter_read(&adapter->tc);
|
||||
spin_unlock_irqrestore(&adapter->systim_lock, flags);
|
||||
|
||||
ts->tv_sec = div_u64_rem(ns, NSEC_PER_SEC, &remainder);
|
||||
ts->tv_nsec = remainder;
|
||||
*ts = ns_to_timespec64(ns);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -290,7 +290,6 @@ static int igb_ptp_gettime_82576(struct ptp_clock_info *ptp,
|
|||
ptp_caps);
|
||||
unsigned long flags;
|
||||
u64 ns;
|
||||
u32 remainder;
|
||||
|
||||
spin_lock_irqsave(&igb->tmreg_lock, flags);
|
||||
|
||||
|
@ -298,8 +297,7 @@ static int igb_ptp_gettime_82576(struct ptp_clock_info *ptp,
|
|||
|
||||
spin_unlock_irqrestore(&igb->tmreg_lock, flags);
|
||||
|
||||
ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
|
||||
ts->tv_nsec = remainder;
|
||||
*ts = ns_to_timespec64(ns);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -328,8 +326,7 @@ static int igb_ptp_settime_82576(struct ptp_clock_info *ptp,
|
|||
unsigned long flags;
|
||||
u64 ns;
|
||||
|
||||
ns = ts->tv_sec * 1000000000ULL;
|
||||
ns += ts->tv_nsec;
|
||||
ns = timespec64_to_ns(ts);
|
||||
|
||||
spin_lock_irqsave(&igb->tmreg_lock, flags);
|
||||
|
||||
|
|
|
@ -284,15 +284,13 @@ static int ixgbe_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
|
|||
struct ixgbe_adapter *adapter =
|
||||
container_of(ptp, struct ixgbe_adapter, 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;
|
||||
}
|
||||
|
@ -313,8 +311,7 @@ static int ixgbe_ptp_settime(struct ptp_clock_info *ptp,
|
|||
u64 ns;
|
||||
unsigned long flags;
|
||||
|
||||
ns = ts->tv_sec * 1000000000ULL;
|
||||
ns += ts->tv_nsec;
|
||||
ns = timespec64_to_ns(ts);
|
||||
|
||||
/* reset the timecounter */
|
||||
spin_lock_irqsave(&adapter->tmreg_lock, flags);
|
||||
|
|
|
@ -170,15 +170,13 @@ static int mlx4_en_phc_gettime(struct ptp_clock_info *ptp,
|
|||
struct mlx4_en_dev *mdev = container_of(ptp, struct mlx4_en_dev,
|
||||
ptp_clock_info);
|
||||
unsigned long flags;
|
||||
u32 remainder;
|
||||
u64 ns;
|
||||
|
||||
write_lock_irqsave(&mdev->clock_lock, flags);
|
||||
ns = timecounter_read(&mdev->clock);
|
||||
write_unlock_irqrestore(&mdev->clock_lock, flags);
|
||||
|
||||
ts->tv_sec = div_u64_rem(ns, NSEC_PER_SEC, &remainder);
|
||||
ts->tv_nsec = remainder;
|
||||
*ts = ns_to_timespec64(ns);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,6 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts)
|
|||
container_of(ptp, struct stmmac_priv, ptp_clock_ops);
|
||||
unsigned long flags;
|
||||
u64 ns;
|
||||
u32 reminder;
|
||||
|
||||
spin_lock_irqsave(&priv->ptp_lock, flags);
|
||||
|
||||
|
@ -119,8 +118,7 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts)
|
|||
|
||||
spin_unlock_irqrestore(&priv->ptp_lock, flags);
|
||||
|
||||
ts->tv_sec = div_u64_rem(ns, 1000000000ULL, &reminder);
|
||||
ts->tv_nsec = reminder;
|
||||
*ts = ns_to_timespec64(ns);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,6 @@ static int cpts_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
|
|||
static int cpts_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
|
||||
{
|
||||
u64 ns;
|
||||
u32 remainder;
|
||||
unsigned long flags;
|
||||
struct cpts *cpts = container_of(ptp, struct cpts, info);
|
||||
|
||||
|
@ -178,8 +177,7 @@ static int cpts_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
|
|||
ns = timecounter_read(&cpts->tc);
|
||||
spin_unlock_irqrestore(&cpts->lock, flags);
|
||||
|
||||
ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
|
||||
ts->tv_nsec = remainder;
|
||||
*ts = ns_to_timespec64(ns);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -191,8 +189,7 @@ static int cpts_ptp_settime(struct ptp_clock_info *ptp,
|
|||
unsigned long flags;
|
||||
struct cpts *cpts = container_of(ptp, struct cpts, info);
|
||||
|
||||
ns = ts->tv_sec * 1000000000ULL;
|
||||
ns += ts->tv_nsec;
|
||||
ns = timespec64_to_ns(ts);
|
||||
|
||||
spin_lock_irqsave(&cpts->lock, flags);
|
||||
timecounter_init(&cpts->tc, &cpts->cc, ns);
|
||||
|
|
Загрузка…
Ссылка в новой задаче