Hi, > -----Original Message----- > From: Richard Cochran [mailto:richardcoch...@gmail.com] > Sent: Saturday, April 09, 2016 12:32 PM > To: linuxptp-devel@lists.sourceforge.net > Subject: [Linuxptp-devel] [PATCH RFC 7/7] Let the clock code figure the PHC > index. > > The code that determines the index of the PHC device is useful to all > kinds of clock devices. > > Signed-off-by: Richard Cochran <richardcoch...@gmail.com> > --- > clock.c | 30 ++++++++++++++++++++++++++---- > clock.h | 6 +++--- > ptp4l.c | 31 ++----------------------------- > 3 files changed, 31 insertions(+), 36 deletions(-) > > diff --git a/clock.c b/clock.c > index 17c9687..c59046a 100644 > --- a/clock.c > +++ b/clock.c > @@ -801,19 +801,18 @@ static void clock_remove_port(struct clock *c, > struct port *p) > } > > struct clock *clock_create(enum clock_type type, struct config *config, > - int phc_index) > + const char *phc_device) > { > enum timestamp_type timestamping = > config_get_int(config, NULL, "time_stamping"); > int fadj = 0, max_adj = 0, sw_ts = timestamping == TS_SOFTWARE ? > 1 : 0; > enum servo_type servo = config_get_int(config, NULL, > "clock_servo"); > + int phc_index, required_modes = 0; > struct clock *c = &the_clock; > - int required_modes = 0; > struct port *p; > unsigned char oui[OUI_LEN]; > char phc[32], *tmp; > - struct interface *udsif = &c->uds_interface; > - struct interface *iface = STAILQ_FIRST(&config->interfaces); > + struct interface *iface, *udsif = &c->uds_interface; > struct timespec ts; > int sfl; > > @@ -936,6 +935,29 @@ struct clock *clock_create(enum clock_type type, > struct config *config, > } > > iface = STAILQ_FIRST(&config->interfaces); > + > + /* determine PHC Clock index */ > + if (config_get_int(config, NULL, "free_running")) { > + phc_index = -1; > + } else if (config_get_int(config, NULL, "time_stamping") == > TS_SOFTWARE || > + config_get_int(config, NULL, "time_stamping") == > TS_LEGACY_HW) { > + phc_index = -1; > + } else if (phc_device) { > + if (1 != sscanf(phc_device, "/dev/ptp%d", &phc_index)) { > + pr_err("bad ptp device string"); > + return NULL; > + } > + } else if (iface->ts_info.valid) { > + phc_index = iface->ts_info.phc_index; > + } else { > + pr_err("PTP device not specified and automatic > determination" > + " is not supported. Please specify PTP device."); > + return NULL; > + } > + if (phc_index >= 0) { > + pr_info("selected /dev/ptp%d as PTP clock", phc_index); > + } > +
Would this make more logical sense as a separate function here? Thanks, Jake ------------------------------------------------------------------------------ Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! http://pubads.g.doubleclick.net/ gampad/clk?id=1444514301&iu=/ca-pub-7940484522588532 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel