From 024d4d5e6f94057c09007bfb5b327cf25a5d95cb Mon Sep 17 00:00:00 2001 From: Revanth Kumar Uppala Date: Thu, 23 Feb 2023 10:24:07 +0000 Subject: [PATCH] ptp: Linux v6.2: Add support for adjfine In Linux v6.2 func pointer adjfreq is replaced with adjfine. As a part of this, an argument of the function "s32 ppb" is changed to "long scaled_ppm".Added kernel version checks to handle this for Linux v6.2 Bug 3936429 Change-Id: I7a4f0a0e6e17d484c4ffd47e6e9ef78c214253e7 Signed-off-by: Revanth Kumar Uppala Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2862518 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Jonathan Hunter GVS: Gerrit_Virtual_Submit --- drivers/net/ethernet/nvidia/nvethernet/ptp.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ptp.c b/drivers/net/ethernet/nvidia/nvethernet/ptp.c index 5c73ce7f..667d2aa1 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ptp.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ptp.c @@ -125,11 +125,16 @@ static int ether_adjust_time(struct ptp_clock_info *ptp, s64 nsec_delta) * * @param[in] ptp: Pointer to ptp_clock_info structure. * @param[in] ppb: Desired period change in parts per billion. + * @param[in] scaled_ppm: Desired period change in parts per million. * * @retval 0 on success * @retval "negative value" on failure. */ -static int ether_adjust_freq(struct ptp_clock_info *ptp, s32 ppb) +#if KERNEL_VERSION(6, 2, 0) > LINUX_VERSION_CODE +static int ether_adjust_clock(struct ptp_clock_info *ptp, s32 ppb) +#else +static int ether_adjust_clock(struct ptp_clock_info *ptp, long scaled_ppm) +#endif { struct ether_priv_data *pdata = container_of(ptp, struct ether_priv_data, @@ -138,6 +143,9 @@ static int ether_adjust_freq(struct ptp_clock_info *ptp, s32 ppb) struct osi_ioctl ioctl_data = {}; unsigned long flags; int ret = -1; +#if KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE + s32 ppb = scaled_ppm_to_ppb(scaled_ppm); +#endif raw_spin_lock_irqsave(&pdata->ptp_lock, flags); @@ -245,7 +253,11 @@ static struct ptp_clock_info ether_ptp_clock_ops = { .n_ext_ts = 0, .n_per_out = 0, .pps = 0, - .adjfreq = ether_adjust_freq, +#if KERNEL_VERSION(6, 2, 0) > LINUX_VERSION_CODE + .adjfreq = ether_adjust_clock, +#else + .adjfine = ether_adjust_clock, +#endif .adjtime = ether_adjust_time, .gettime64 = ether_get_time, .settime64 = ether_set_time,