Skip to content

Commit

Permalink
clock: avoid checking phc state for system clock
Browse files Browse the repository at this point in the history
clock->u.nic.phc happens typically to be non-zero for a system clock type in
most systems but apparently not on Raspberry Pi 5 with Debian 12. It could be
a layout change or system clock characteristics change but in any case the
code should not have been checking this field. Fixes #9
  • Loading branch information
abower-amd committed Mar 16, 2024
1 parent dfc3c2c commit c7d6add
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/sfptpd_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,8 @@ int sfptpd_clock_adjust_time(struct sfptpd_clock *clock, struct timespec *offset
assert(clock->magic == SFPTPD_CLOCK_MAGIC);
assert(offset != NULL);

if (clock->u.nic.phc == NULL) {
if (clock->type != SFPTPD_CLOCK_TYPE_SYSTEM &&
clock->u.nic.phc == NULL) {
ERROR("clock %s: unable to step clock - no phc device\n",
clock->long_name);
rc = ENODEV;
Expand Down Expand Up @@ -1683,7 +1684,8 @@ int sfptpd_clock_adjust_frequency(struct sfptpd_clock *clock, long double freq_a
assert(clock != NULL);
assert(clock->magic == SFPTPD_CLOCK_MAGIC);

if (clock->u.nic.phc == NULL) {
if (clock->type != SFPTPD_CLOCK_TYPE_SYSTEM &&
clock->u.nic.phc == NULL) {
ERROR("clock %s: unable to adjust frequency - no phc device\n",
clock->long_name);
rc = ENODEV;
Expand Down Expand Up @@ -1877,7 +1879,8 @@ int sfptpd_clock_get_time(const struct sfptpd_clock *clock, struct timespec *tim
assert(clock->magic == SFPTPD_CLOCK_MAGIC);
assert(time != NULL);

if (clock->u.nic.phc == NULL) {
if (clock->type != SFPTPD_CLOCK_TYPE_SYSTEM &&
clock->u.nic.phc == NULL) {
ERROR("clock %s: unable to get time - no phc device\n",
clock->long_name);
rc = ENODEV;
Expand Down
2 changes: 1 addition & 1 deletion src/sfptpd_phc.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ static int phc_configure_pps(struct sfptpd_phc *phc)

if (ioctl(phc->phc_fd, PTP_ENABLE_PPS, 1) != 0) {
ERROR("phc%d: failed to enable PPS events, %s\n",
phc->phc_fd, strerror(errno));
phc->phc_idx, strerror(errno));
rc = errno;
goto fail2;
}
Expand Down

0 comments on commit c7d6add

Please sign in to comment.