Re: Export clocks_calc_mult_shift() function
From: Murali Karicheri
Date: Mon Mar 14 2016 - 11:27:52 EST
On 03/08/2016 05:25 PM, Murali Karicheri wrote:
> I found a patch posted sometime back to export the clocksource
> function clocks_calc_mult_shift() so that it can be called by
> drivers that are dynamically loadable. I have not seen any
> comment against this. Wondering why this is not merged. We require
> this function exported for use in our driver as well. Can you merge
> the patch please. Or do you suggest me to repost the same?
Some reason, your response didn't make into my inbox. So I am
reproducing it below.
>Why would the clocksource driver need to calculate the hz/shift value
>instead of using the clocksource_register_hz/khz functions?
In this use case, the timestamp for Tx/Rx is generated by a firmware
that attach the timestamp raw count to the packet meta data when the
same is received from the Packet Accelerator h/w at the ingress.
We need to convert this raw count value to nano second and use a code
/* Convert a raw PA timer count to nanoseconds
static inline u64 tstamp_raw_to_ns(struct pa_core_device *core_dev, u32 lo,
u32 mult = core_dev->timestamp_info.mult;
u32 shift = core_dev->timestamp_info.shift;
/* Minimize overflow errors by doing this in pieces */
result = ((u64)lo * mult) >> shift;
result += ((u64)hi << (32 - shift)) * mult;
The mult, shift values are obtained using the existing clocks_calc_mult_shift()
that will not work, if our driver is built as a dynamically loadable module
as the symbol is not exported.
Is there an alternative way of doing this without exporting this function.
clocksource_register_hz/khz() can't help in this, right?
Linux Kernel, Keystone