On Wed, Aug 16, 2017 at 09:32:11PM +0800, Hangbin Liu wrote:
> -static void clock_reinit(struct clock *clock)
> +static void clock_reinit(struct node *node, struct clock *clock)
>  {
> +     struct port *p;
> +     int state, timestamping, ret;
> +     int phc_index = -1;
> +     char iface[IFNAMSIZ];
> +     clockid_t clkid = CLOCK_INVALID;
> +
> +     LIST_FOREACH(p, &node->ports, list) {
> +             if (p->clock == clock) {
> +                     ret = run_pmc_port_properties(node, 1000, p->number,
> +                                                   &state, &timestamping,
> +                                                   iface);
> +                     if (ret == -1) {
> +                             /* port does not exist, ignore the port */
> +                             continue;
> +                     }
> +                     if (ret <= 0) {
> +                             pr_err("failed to get port properties");
> +                             return;
> +                     }
> +                     if (timestamping == TS_SOFTWARE) {
> +                             /* ignore ports with software time stamping */
> +                             continue;
> +                     }
> +
> +                     p->state = normalize_state(state);
> +             }
> +     }
> +
> +     if (strcmp(clock->device, iface)) {
> +             free(clock->device);
> +             clock->device = strdup(iface);
> +             clkid = clock_open(clock->device, &phc_index);
> +             if (clkid == CLOCK_INVALID)
> +                     return;
> +             phc_close(clock->clkid);
> +             clock->clkid = clkid;
> +             clock->phc_index = phc_index;
> +     }
> +
>       servo_reset(clock->servo);
>       clock->servo_state = SERVO_UNLOCKED;

This part will be changed to

+
+       if (ret != -1) {
+               /* Check if device changed */
+               if (strcmp(clock->device, iface)) {
+                       free(clock->device);
+                       clock->device = strdup(iface);
+               }
+               /* Check if phc index changed */
+               if (!sk_get_ts_info(clock->device, &ts_info) &&
+                   clock->phc_index != ts_info.phc_index) {
+                       clkid = clock_open(clock->device, &phc_index);
+                       if (clkid == CLOCK_INVALID)
+                               return;
+                       phc_close(clock->clkid);
+                       clock->clkid = clkid;
+                       clock->phc_index = phc_index;
+               }
+       }
+
        servo_reset(clock->servo);
        clock->servo_state = SERVO_UNLOCKED;
+       servo_sync_interval(clock->servo, 1);


That's what I have mainly chaned so far.
If more stuff changed, I will add them in the cover letter.

Thanks
Hangbin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to