On Thu, Mar 30, 2023 at 11:16:44AM +0800, Hangbin Liu wrote:
> Richard, what do you think?
This code in hwts_init is wrong:
cfg.flags = HWTSTAMP_FLAG_BONDED_PHC_INDEX;
/* Fall back without flag if user run new build on old kernel */
if (ioctl(fd, SIOCGHWTSTAMP, &ifreq) == -EINVAL)
init_ifreq(&ifreq, &cfg, device);
As `man ioctl` says:
RETURN VALUE
Usually, on success zero is returned. A few ioctl() requests use the
return value as an output parameter and return a nonnegative value on
success. On error, -1 is returned, and errno is set appropriately.
So I think what you meant to write is this:
cfg.flags = HWTSTAMP_FLAG_BONDED_PHC_INDEX;
err = ioctl(fd, SIOCGHWTSTAMP, &ifreq);
if (err < 0) {
/* Fall back without flag if user run new build on old kernel */
if (errno == EINVAL) {
init_ifreq(&ifreq, &cfg, device);
} else {
pr_err("ioctl SIOCGHWTSTAMP failed: %m");
return err;
}
}
@Martin would that also fix your issue?
Thanks,
Richard
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel