On Wed,  5 Nov 2014 23:42:36 +0100, Richard Cochran wrote:
> If the user has configured the appropriate option, then simply warn about
> the clock device mismatch, open the port's clock device, and then go on.
> 
> Signed-off-by: Richard Cochran <[email protected]>
> ---
>  port.c |   25 ++++++++++++++++++++++---
>  1 file changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/port.c b/port.c
> index 2176962..95b6794 100644
> --- a/port.c
> +++ b/port.c
> @@ -29,6 +29,7 @@
>  #include "filter.h"
>  #include "missing.h"
>  #include "msg.h"
> +#include "phc.h"
>  #include "port.h"
>  #include "print.h"
>  #include "sk.h"
> @@ -65,6 +66,7 @@ struct port {
>       char *name;
>       struct clock *clock;
>       clockid_t clkid;
> +     int max_adj;
>       struct transport *trp;
>       enum timestamp_type timestamping;
>       struct fdarray fda;
> @@ -1952,6 +1954,8 @@ void port_close(struct port *p)
>       filter_destroy(p->delay_filter);
>       if (p->fault_fd >= 0)
>               close(p->fault_fd);
> +     if (p->max_adj)
> +             phc_close(p->clkid);
>       free(p);
>  }
>  
> @@ -2463,10 +2467,25 @@ struct port *port_open(clockid_t clkid,
>       else if (!interface->ts_info.valid)
>               pr_warning("port %d: get_ts_info not supported", number);
>       else if (phc_index >= 0 && phc_index != interface->ts_info.phc_index) {
> +             char phc[32];
> +             snprintf(phc, 31, "/dev/ptp%d", interface->ts_info.phc_index);
>               pr_err("port %d: PHC device mismatch", number);
> -             pr_err("port %d: /dev/ptp%d requested, but /dev/ptp%d attached",
> -                    number, phc_index, interface->ts_info.phc_index);
> -             goto err_port;
> +             pr_err("port %d: /dev/ptp%d requested, but %s attached",
> +                    number, phc_index, phc);
> +             if (!interface->boundary_clock_jbod) {
> +                     goto err_port;
> +             }
> +             pr_warning("port %d: just a bunch of devices", number);

I think this warning is enough, the previous ones ("PHC device
mismatch" and "/dev/ptp%d requested, but %s attached") can be printed
only when boundary_clock_jbod is not set. After all, the user is
supposed to know what he's doing when enabling this.

> +             p->clkid = phc_open(phc);
> +             if (p->clkid == CLOCK_INVALID) {
> +                     pr_err("port %d: Failed to open %s: %m", number, phc);
> +                     goto err_port;
> +             }
> +             p->max_adj = phc_max_adj(p->clkid);
> +             if (!p->max_adj) {
> +                     pr_err("port %d: clock is not adjustable", number);
> +                     goto err_port;
> +             }
>       }
>  
>       p->pod = interface->pod;

I think the servo state should be separate, too. The reference counted
structure would be a good place to hold that.

 Jiri

-- 
Jiri Benc

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to