Rename set_tmo() to set_tmo_log(), add set_tmo_lin()

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
master
Delio Brignoli 2013-03-18 17:08:20 +01:00 committed by Richard Cochran
parent d374ad6bf7
commit 455ebe7d22
3 changed files with 31 additions and 8 deletions

View File

@ -134,7 +134,7 @@ static int clock_fault_timeout(struct clock *c, int index, int set)
} else {
pr_debug("clearing fault on port %d", index);
}
return set_tmo(c->fault_fd[index], scale, log_seconds);
return set_tmo_log(c->fault_fd[index], scale, log_seconds);
}
static void clock_freq_est_reset(struct clock *c)

22
port.c
View File

@ -160,7 +160,7 @@ static int source_pid_eq(struct ptp_message *m1, struct ptp_message *m2)
&m2->header.sourcePortIdentity);
}
int set_tmo(int fd, unsigned int scale, int log_seconds)
int set_tmo_log(int fd, unsigned int scale, int log_seconds)
{
struct itimerspec tmo = {
{0, 0}, {0, 0}
@ -187,6 +187,16 @@ int set_tmo(int fd, unsigned int scale, int log_seconds)
return timerfd_settime(fd, 0, &tmo, NULL);
}
int set_tmo_lin(int fd, int seconds)
{
struct itimerspec tmo = {
{0, 0}, {0, 0}
};
tmo.it_value.tv_sec = seconds;
return timerfd_settime(fd, 0, &tmo, NULL);
}
static void fc_clear(struct foreign_clock *fc)
{
struct ptp_message *m;
@ -720,7 +730,7 @@ static void port_nrate_initialize(struct port *p)
static int port_set_announce_tmo(struct port *p)
{
return set_tmo(p->fda.fd[FD_ANNOUNCE_TIMER],
return set_tmo_log(p->fda.fd[FD_ANNOUNCE_TIMER],
p->announceReceiptTimeout, p->logAnnounceInterval);
}
@ -731,7 +741,7 @@ static int port_set_delay_tmo(struct port *p)
};
int index;
if (p->delayMechanism == DM_P2P) {
return set_tmo(p->fda.fd[FD_DELAY_TIMER], 1,
return set_tmo_log(p->fda.fd[FD_DELAY_TIMER], 1,
p->logMinPdelayReqInterval);
}
index = random() % TMTAB_MAX;
@ -741,18 +751,18 @@ static int port_set_delay_tmo(struct port *p)
static int port_set_manno_tmo(struct port *p)
{
return set_tmo(p->fda.fd[FD_MANNO_TIMER], 1, p->logAnnounceInterval);
return set_tmo_log(p->fda.fd[FD_MANNO_TIMER], 1, p->logAnnounceInterval);
}
static int port_set_qualification_tmo(struct port *p)
{
return set_tmo(p->fda.fd[FD_QUALIFICATION_TIMER],
return set_tmo_log(p->fda.fd[FD_QUALIFICATION_TIMER],
1+clock_steps_removed(p->clock), p->logAnnounceInterval);
}
static int port_set_sync_tmo(struct port *p)
{
return set_tmo(p->fda.fd[FD_SYNC_TIMER], 1, p->logSyncInterval);
return set_tmo_log(p->fda.fd[FD_SYNC_TIMER], 1, p->logSyncInterval);
}
static void port_show_transition(struct port *p,

15
port.h
View File

@ -171,6 +171,19 @@ enum port_state port_state(struct port *port);
* @param log_seconds The exponential factor for the timer.
* @return Zero on success, non-zero otherwise.
*/
int set_tmo(int fd, unsigned int scale, int log_seconds);
int set_tmo_log(int fd, unsigned int scale, int log_seconds);
/**
* Utility function for setting or resetting a file descriptor timer.
*
* This function sets the timer 'fd' to the value of the 'seconds' parameter.
*
* Passing 'seconds' as zero disables the timer.
*
* @param fd A file descriptor previously opened with timerfd_create(2).
* @param seconds The timeout value for the timer.
* @return Zero on success, non-zero otherwise.
*/
int set_tmo_lin(int fd, int seconds);
#endif