phc2sys.c: Replace variable 'domain_number

Replaced usage of variable 'domain_number' with struct config item
'domainNumber'. Original variable still used for range checking. Removed
(now obsolete) third parameter of init_pmc().

Signed-off-by: Peter Schneider <peter@psch.de>
master
Peter Schneider 2018-04-15 21:13:47 +02:00 committed by Richard Cochran
parent f26ca92f1c
commit e8d01515cf
1 changed files with 8 additions and 5 deletions

View File

@ -897,13 +897,14 @@ static void send_subscription(struct node *node)
pmc_send_set_action(node->pmc, TLV_SUBSCRIBE_EVENTS_NP, &sen, sizeof(sen)); pmc_send_set_action(node->pmc, TLV_SUBSCRIBE_EVENTS_NP, &sen, sizeof(sen));
} }
static int init_pmc(struct config *cfg, struct node *node, int domain_number) static int init_pmc(struct config *cfg, struct node *node)
{ {
char uds_local[MAX_IFNAME_SIZE + 1]; char uds_local[MAX_IFNAME_SIZE + 1];
snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d", snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
getpid()); getpid());
node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, domain_number, 0, 1); node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0,
config_get_int(cfg, NULL, "domainNumber"), 0, 1);
if (!node->pmc) { if (!node->pmc) {
pr_err("failed to create pmc"); pr_err("failed to create pmc");
return -1; return -1;
@ -1460,8 +1461,10 @@ int main(int argc, char *argv[])
wait_sync = 1; wait_sync = 1;
break; break;
case 'n': case 'n':
if (get_arg_val_i(c, optarg, &domain_number, 0, 255)) if (get_arg_val_i(c, optarg, &domain_number, 0, 255) ||
config_set_int(cfg, "domainNumber", domain_number)) {
goto end; goto end;
}
break; break;
case 'x': case 'x':
node.kernel_leap = 0; node.kernel_leap = 0;
@ -1532,7 +1535,7 @@ int main(int argc, char *argv[])
print_set_level(print_level); print_set_level(print_level);
if (autocfg) { if (autocfg) {
if (init_pmc(cfg, &node, domain_number)) if (init_pmc(cfg, &node))
goto end; goto end;
if (auto_init_ports(&node, rt) < 0) if (auto_init_ports(&node, rt) < 0)
goto end; goto end;
@ -1568,7 +1571,7 @@ int main(int argc, char *argv[])
r = -1; r = -1;
if (wait_sync) { if (wait_sync) {
if (init_pmc(cfg, &node, domain_number)) if (init_pmc(cfg, &node))
goto end; goto end;
while (is_running()) { while (is_running()) {