qcacmn: Create qdf_log_timestamp_to_secs helper function

Create a timestamp conversion helper that returns whole seconds and
remaining micro seconds, for easier consumption by logging methods.

Change-Id: I5bc40075566485f3dc9f7e5fd81a13ec462c5da0
CRs-Fixed: 2031564
此提交包含在:
Dustin Brown
2017-04-10 13:26:56 -07:00
提交者 Sandeep Puligilla
父節點 674c4a0650
當前提交 6cb0fa1c4f
共有 3 個檔案被更改,包括 37 行新增11 行删除

查看文件

@@ -168,16 +168,39 @@ enum qdf_timestamp_unit {
#ifdef QCA_WIFI_3_0_ADRASTEA
#define QDF_LOG_TIMESTAMP_UNIT QTIMER
#define QDF_LOG_TIMESTAMP_CYCLES_PER_10_US 192
static inline uint64_t qdf_log_timestamp_to_usecs(uint64_t time)
{
/*
* Try to preserve precision by multiplying by 10 first.
* If that would cause a wrap around, divide first instead.
*/
if (time * 10 < time) {
do_div(time, QDF_LOG_TIMESTAMP_CYCLES_PER_10_US);
return time * 10;
}
time = time * 10;
do_div(time, QDF_LOG_TIMESTAMP_CYCLES_PER_10_US);
return time;
}
#else
#define QDF_LOG_TIMESTAMP_UNIT KERNEL_LOG
#define QDF_LOG_TIMESTAMP_CYCLES_PER_10_US 10
static inline uint64_t qdf_log_timestamp_to_usecs(uint64_t time)
{
/* timestamps are already in micro seconds */
return time;
}
#endif
static inline unsigned long long qdf_log_timestamp_to_usecs(uint64_t time)
static inline void qdf_log_timestamp_to_secs(uint64_t time, uint64_t *secs,
uint64_t *usecs)
{
if ((time * 10) < time)
return (time / QDF_LOG_TIMESTAMP_CYCLES_PER_10_US) * 10;
return (time * 10) / QDF_LOG_TIMESTAMP_CYCLES_PER_10_US;
*secs = qdf_log_timestamp_to_usecs(time);
*usecs = do_div(*secs, 1000000ul);
}
static inline uint64_t qdf_usecs_to_log_timestamp(uint64_t usecs)