On Tue, Oct 15, 2024 at 12:54:14PM +0200, Sven Schnelle wrote: > Add a small PtP driver which allows user space to get > the values of the physical and tod clock. This allows > programs like chrony to use STP as clock source and > steer the kernel clock. The physical clock can be used > as a debugging aid to get the clock without any additional > offsets like STP steering or LPAR offset. > > Signed-off-by: Sven Schnelle <svens@xxxxxxxxxxxxx> ... > +static __always_inline unsigned long eitod_to_ns(union tod_clock *clk) > +{ > + clk->eitod -= TOD_UNIX_EPOCH; > + return ((clk->eitod >> 9) * 125) + (((clk->eitod & 0x1ff) * 125) >> 9); > +} This is quite odd ;). This helper modifies the input union, which may be very surprising to callers. It subtracts TOD_UNIX_EPOCH, which may also be surprising, especially since we don't do that for tod_to_ns(). In addition the input value contains 72 bits, while the output value is truncated to the lower 64 bits.