Balance the posix clock open function with a close method.
The one user of the function, posix_clock_open(), simply open codes the closing call to phc_close(). This patch provides a method to balance closing and opening of a posix clock. In addition, the phc_ctl program never explicitly closed the opened clock, and so this patch adds the missing call. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
01db4c8849
commit
dde0bf2e28
|
@ -341,7 +341,7 @@ static void clock_reinit(struct node *node, struct clock *clock, int new_state)
|
|||
if (clkid == CLOCK_INVALID)
|
||||
return;
|
||||
|
||||
phc_close(clock->clkid);
|
||||
posix_clock_close(clock->clkid);
|
||||
clock->clkid = clkid;
|
||||
clock->phc_index = phc_index;
|
||||
|
||||
|
|
|
@ -531,6 +531,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* pass the remaining arguments to the run_cmds loop */
|
||||
result = run_cmds(clkid, cmdc, cmdv);
|
||||
posix_clock_close(clkid);
|
||||
if (result < -1) {
|
||||
/* show usage when command fails */
|
||||
usage(progname);
|
||||
|
|
8
util.c
8
util.c
|
@ -190,6 +190,14 @@ char *portaddr2str(struct PortAddress *addr)
|
|||
return buf;
|
||||
}
|
||||
|
||||
void posix_clock_close(clockid_t clock)
|
||||
{
|
||||
if (clock == CLOCK_REALTIME) {
|
||||
return;
|
||||
}
|
||||
phc_close(clock);
|
||||
}
|
||||
|
||||
clockid_t posix_clock_open(const char *device, int *phc_index)
|
||||
{
|
||||
struct sk_ts_info ts_info;
|
||||
|
|
6
util.h
6
util.h
|
@ -110,6 +110,12 @@ char *pid2str(struct PortIdentity *id);
|
|||
|
||||
char *portaddr2str(struct PortAddress *addr);
|
||||
|
||||
/**
|
||||
* Closes a dynamic posix clock.
|
||||
* @param clock A clock ID obtained via posix_clock_close().
|
||||
*/
|
||||
void posix_clock_close(clockid_t clock);
|
||||
|
||||
/**
|
||||
* Opens a dynamic posix clock by name.
|
||||
* @param device The PHC character device or network interface to open.
|
||||
|
|
Loading…
Reference in New Issue