On Tue, Mar 25, 2014 at 12:30:01PM +0100, Richard Cochran wrote:
> On Tue, Mar 25, 2014 at 09:52:32AM +0100, Mohamed Belaouad wrote:
>
> > Also, what we would like to know is: is the max ppb adjustment check
> > done in the PTP subsystem (I have not found anything about it in
> > drivers/ptp, maybe wrong location?) or should it be handled in the
> > driver?
>
> There is no check in the kernel. I guess that ptp_clock_adjtime could
> return ERANGE in such a case.
Is this (untested patch) what you are asking for?
Thanks,
Richard
---
diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index e25d2bc..239d02f 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -142,7 +142,10 @@ static int ptp_clock_adjtime(struct posix_clock *pc,
struct timex *tx)
delta = ktime_to_ns(kt);
err = ops->adjtime(ops, delta);
} else if (tx->modes & ADJ_FREQUENCY) {
- err = ops->adjfreq(ops, scaled_ppm_to_ppb(tx->freq));
+ s32 delta = scaled_ppm_to_ppb(tx->freq);
+ if (delta > ops->max_adj || delta < -ops->max_adj)
+ return -ERANGE;
+ err = ops->adjfreq(ops, delta);
ptp->dialed_frequency = tx->freq;
} else if (tx->modes == 0) {
tx->freq = ptp->dialed_frequency;
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Linuxptp-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-users