Hi,
I am using VAYU EVM board and the ptp clock used is CPTS . The Vayu evm is running with the Kernel version 3.8 . I am trying to implement clock synchronization and syntonization using cpts driver and the trying to achieve it by getting hardware timestamp from cpts (implementing 802.1.AS)
. I do adjtime call to adjust the time of the cpts clock.
But I face the following issue, 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 Rajendran