On Thu, Apr 07, 2022 at 04:55:29AM -0700, Richard Cochran wrote:
> Can you refactor this somehow so that get_tsinfo doesn't need to be
> called twice?
If you just want to avoid getting and checking tsinfo twice. We can keep
the code after PATCH 1/2 and change nothing for clock_create() in PATCH 2/2.
i.e.
"""
STAILQ_FOREACH(iface, &config->interfaces, list) {
memset(ts_label, 0, sizeof(ts_label));
if (!rtnl_get_ts_device(interface_name(iface), ts_label))
interface_set_label(iface, ts_label);
interface_get_tsinfo(iface);
if (interface_tsinfo_valid(iface) &&
!interface_tsmodes_supported(iface, required_modes)) {
pr_err("interface '%s' does not support requested timestamping
mode",
interface_name(iface));
return NULL;
}
}
"""
With this it will try update ts_label by force and do interface_get_tsinfo()
only once.
BTW, I just found this is the same situation with what we discussed about
the "#ifdef HWTSTAMP_FLAG_BONDED_PHC_INDEX" issue in PATCHv2. I only thought
about optimize the code running path(as the need of updating ts_label is
unlikely) but forgot the code readability.
Thanks
Hangbin
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel