Hi,
I am using Vayu evm board,
I am trying to do synchronization and syntonization of the cpts clock.Based on the timestamp of the cpts.
I face the following issue:
I have a negative offset to be adjusted with the cpts clock and I use the clock_adjtime system call but I find the call failing for all the negative value.
If I have a negative offset that is passed to the kernel the conversion of signed integer to unsigned integer gives me a problem
File : drivers/ptp/ptp_clock.c
static int ptp_clock_adjtime(struct posix_clock *pc, struct timex *tx)
{
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
struct ptp_clock_info *ops;
int err = -EOPNOTSUPP;
ops = ptp->info;
if (tx->modes & ADJ_SETOFFSET) {
struct timespec ts;
ktime_t kt;
s64 delta;
ts.tv_sec = tx->time.tv_sec;
ts.tv_nsec = tx->time.tv_usec;
if (!(tx->modes & ADJ_NANO))
ts.tv_nsec *= 1000;
if ((unsigned long) ts.tv_nsec >= NSEC_PER_SEC)
return -EINVAL;
kt = timespec_to_ktime(ts);
delta = ktime_to_ns(kt);
err = ops->adjtime(ops, delta);
} else if (tx->modes & ADJ_FREQUENCY) {
err = ops->adjfreq(ops, scaled_ppm_to_ppb(tx->freq));
ptp->dialed_frequency = tx->freq;
} else if (tx->modes == 0) {
tx->freq = ptp->dialed_frequency;
err = 0;
}
return err;
}
Then When the condition is omitted there is another issue in timespec_to_ktime function.
ktime has a structure,
union ktime {
s64 tv64;
#if BITS_PER_LONG != 64 && !defined(CONFIG_KTIME_SCALAR)
struct {
# ifdef __BIG_ENDIAN
s32 sec, nsec;
# else
s32 nsec, sec;
# endif
} tv;
#endif
};
CONFIG_KTIME_SCALAR is 1 . This causes the ktime to have only tv64 and the function call doesn't have any meaning.
There is no other way to adjust the clock, Please suggest me of any solution that would help.
Thanks and Regards,
Sarah Blessie Rajendran