summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmed ElArabawy <arabawy@google.com>2020-10-05 07:51:01 -0700
committerAhmed ElArabawy <arabawy@google.com>2020-10-05 12:30:30 -0700
commitad8cf57918f614e334c5f88f34f2fa670212d31d (patch)
tree0c88be7ec16336fef776ba2cf3efc71e9ca9f48f
parentb5043a59931aa336153cd4a679079330ca133698 (diff)
downloadbcm43752-ad8cf57918f614e334c5f88f34f2fa670212d31d.tar.gz
Replace usage of timeval and timespec with timespec64
This commit replaces the use of the struct timeval and timespec with the timespec64. This is part of the effort to switch to kernel 5.9 Bug: 169622740 Test: Build successful in mainline kernel branch Change-Id: I317b270b3f6e1ca75769030069ee091625772713 Signed-off-by: Ahmed ElArabawy <arabawy@google.com>
-rwxr-xr-xdhd_debug.c10
-rwxr-xr-xdhd_linux.c20
-rw-r--r--dhd_pno.c22
-rw-r--r--dhd_rtt.c14
-rw-r--r--include/linuxver.h18
-rwxr-xr-xlinux_osl.c16
-rw-r--r--wl_bam.c14
-rwxr-xr-xwl_cfgscan.c18
8 files changed, 59 insertions, 73 deletions
diff --git a/dhd_debug.c b/dhd_debug.c
index 764cad0..3e89696 100755
--- a/dhd_debug.c
+++ b/dhd_debug.c
@@ -1491,16 +1491,16 @@ __dhd_dbg_pkt_hash(uintptr_t pkt, uint32 pktid)
(__pkt + __pktid * __pktid));
}
-#define __TIMESPEC_TO_US(ts) \
- (((uint32)(ts).tv_sec * USEC_PER_SEC) + ((ts).tv_nsec / NSEC_PER_USEC))
+#define __TIMESPEC64_TO_US(ts) \
+ (((ts).tv_sec * USEC_PER_SEC) + ((ts).tv_nsec / NSEC_PER_USEC))
uint32
__dhd_dbg_driver_ts_usec(void)
{
- struct timespec ts;
+ struct timespec64 ts;
- get_monotonic_boottime(&ts);
- return ((uint32)(__TIMESPEC_TO_US(ts)));
+ GET_MONOTONIC_BOOT_TIME(&ts);
+ return ((uint32)(__TIMESPEC64_TO_US(ts)));
}
wifi_tx_packet_fate
diff --git a/dhd_linux.c b/dhd_linux.c
index 8c7f021..ffab7fd 100755
--- a/dhd_linux.c
+++ b/dhd_linux.c
@@ -21554,16 +21554,16 @@ char*
dhd_dbg_get_system_timestamp(void)
{
static char timebuf[DEBUG_DUMP_TIME_BUF_LEN];
- struct timeval tv;
- unsigned long local_time;
+ struct timespec64 ts;
+ unsigned long long local_time;
struct rtc_time tm;
memset(timebuf, 0, DEBUG_DUMP_TIME_BUF_LEN);
- do_gettimeofday(&tv);
- local_time = (u32)(tv.tv_sec - (sys_tz.tz_minuteswest * 60));
+ GET_TIME_OF_DAY(&ts);
+ local_time = (u64)(ts.tv_sec - (sys_tz.tz_minuteswest * 60));
rtc_time_to_tm(local_time, &tm);
scnprintf(timebuf, DEBUG_DUMP_TIME_BUF_LEN,
"%02d:%02d:%02d.%06lu",
- tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_usec);
+ tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec/NSEC_PER_USEC);
return timebuf;
}
@@ -22989,19 +22989,19 @@ void dhd_schedule_gather_ap_stadata(void *bcm_cfg, void *ndev, const wl_event_ms
void
get_debug_dump_time(char *str)
{
- struct timeval curtime;
- unsigned long local_time;
+ struct timespec64 curtime;
+ unsigned long long local_time;
struct rtc_time tm;
if (!strlen(str)) {
- do_gettimeofday(&curtime);
- local_time = (u32)(curtime.tv_sec -
+ GET_TIME_OF_DAY(&curtime);
+ local_time = (u64)(curtime.tv_sec -
(sys_tz.tz_minuteswest * DHD_LOG_DUMP_TS_MULTIPLIER_VALUE));
rtc_time_to_tm(local_time, &tm);
snprintf(str, DEBUG_DUMP_TIME_BUF_LEN, DHD_LOG_DUMP_TS_FMT_YYMMDDHHMMSSMSMS,
tm.tm_year - 100, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min,
- tm.tm_sec, (int)(curtime.tv_usec/NSEC_PER_USEC));
+ tm.tm_sec, (int)(curtime.tv_nsec/NSEC_PER_MSEC));
}
}
diff --git a/dhd_pno.c b/dhd_pno.c
index 422214f..d2d94d7 100644
--- a/dhd_pno.c
+++ b/dhd_pno.c
@@ -100,7 +100,7 @@
- (uint32)(timestamp2/1000)))
#define TIME_DIFF_MS(timestamp1, timestamp2) (abs((uint32)(timestamp1) \
- (uint32)(timestamp2)))
-#define TIMESPEC_TO_US(ts) (((uint64)(ts).tv_sec * USEC_PER_SEC) + \
+#define TIMESPEC64_TO_US(ts) (((ts).tv_sec * USEC_PER_SEC) + \
(ts).tv_nsec / NSEC_PER_USEC)
#define ENTRY_OVERHEAD strlen("bssid=\nssid=\nfreq=\nlevel=\nage=\ndist=\ndistSd=\n====")
@@ -202,9 +202,9 @@ dhd_is_legacy_pno_enabled(dhd_pub_t *dhd)
#ifdef GSCAN_SUPPORT
static uint64
-convert_fw_rel_time_to_systime(struct timespec *ts, uint32 fw_ts_ms)
+convert_fw_rel_time_to_systime(struct timespec64 *ts, uint32 fw_ts_ms)
{
- return ((uint64)(TIMESPEC_TO_US(*ts)) - (uint64)(fw_ts_ms * 1000));
+ return ((uint64)(TIMESPEC64_TO_US(*ts)) - (uint64)(fw_ts_ms * USEC_PER_MSEC));
}
static void
@@ -2534,7 +2534,7 @@ _dhd_pno_get_gscan_batch_from_fw(dhd_pub_t *dhd)
uint16 count;
uint16 fwcount;
uint16 fwstatus = PFN_INCOMPLETE;
- struct timespec tm_spec;
+ struct timespec64 tm_spec;
/* Static asserts in _dhd_pno_get_for_batch() below guarantee the v1 and v2
* net_info and subnet_info structures are compatible in size and SSID offset,
@@ -2599,7 +2599,7 @@ _dhd_pno_get_gscan_batch_from_fw(dhd_pub_t *dhd)
__FUNCTION__, err));
goto exit_mutex_unlock;
}
- get_monotonic_boottime(&tm_spec);
+ GET_MONOTONIC_BOOT_TIME(&tm_spec);
if (plbestnet_v1->version == PFN_LBEST_SCAN_RESULT_VERSION_V1) {
fwstatus = plbestnet_v1->status;
@@ -3934,7 +3934,7 @@ dhd_process_full_gscan_result(dhd_pub_t *dhd, const void *data, uint32 len, int
u32 bi_length = 0;
uint8 channel;
uint32 mem_needed;
- struct timespec ts;
+ struct timespec64 ts;
u32 bi_ie_length = 0;
u32 bi_ie_offset = 0;
@@ -3993,8 +3993,8 @@ dhd_process_full_gscan_result(dhd_pub_t *dhd, const void *data, uint32 len, int
result->fixed.rssi = (int32) bi->RSSI;
result->fixed.rtt = 0;
result->fixed.rtt_sd = 0;
- get_monotonic_boottime(&ts);
- result->fixed.ts = (uint64) TIMESPEC_TO_US(ts);
+ GET_MONOTONIC_BOOT_TIME(&ts);
+ result->fixed.ts = (uint64) TIMESPEC64_TO_US(ts);
result->fixed.beacon_period = dtoh16(bi->beacon_period);
result->fixed.capability = dtoh16(bi->capability);
result->ie_length = bi_ie_length;
@@ -4130,7 +4130,7 @@ dhd_handle_hotlist_scan_evt(dhd_pub_t *dhd, const void *event_data,
wl_pfn_net_info_v2_t *pnetinfo_v2;
gscan_results_cache_t *gscan_hotlist_cache;
u32 malloc_size = 0, i, total = 0;
- struct timespec tm_spec;
+ struct timespec64 tm_spec;
uint16 fwstatus;
uint16 fwcount;
@@ -4154,7 +4154,7 @@ dhd_handle_hotlist_scan_evt(dhd_pub_t *dhd, const void *event_data,
return ptr;
}
- get_monotonic_boottime(&tm_spec);
+ GET_MONOTONIC_BOOT_TIME(&tm_spec);
malloc_size = sizeof(gscan_results_cache_t) +
((fwcount - 1) * sizeof(wifi_gscan_result_t));
gscan_hotlist_cache = (gscan_results_cache_t *)MALLOC(dhd->osh, malloc_size);
@@ -4218,7 +4218,7 @@ dhd_handle_hotlist_scan_evt(dhd_pub_t *dhd, const void *event_data,
return ptr;
}
- get_monotonic_boottime(&tm_spec);
+ GET_MONOTONIC_BOOT_TIME(&tm_spec);
malloc_size = sizeof(gscan_results_cache_t) +
((fwcount - 1) * sizeof(wifi_gscan_result_t));
gscan_hotlist_cache =
diff --git a/dhd_rtt.c b/dhd_rtt.c
index d0f408d..d84867c 100644
--- a/dhd_rtt.c
+++ b/dhd_rtt.c
@@ -70,7 +70,7 @@ static DEFINE_SPINLOCK(noti_list_lock);
}\
} while (0)
-#define TIMESPEC_TO_US(ts) (((uint64)(ts).tv_sec * USEC_PER_SEC) + \
+#define TIMESPEC64_TO_US(ts) (((ts).tv_sec * USEC_PER_SEC) + \
(ts).tv_nsec / NSEC_PER_USEC)
#undef DHD_RTT_MEM
@@ -2936,7 +2936,7 @@ dhd_rtt_convert_results_to_host_v1(rtt_result_t *rtt_result, const uint8 *p_data
wl_proxd_session_state_t session_state;
wl_proxd_status_t proxd_status;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
- struct timespec ts;
+ struct timespec64 ts;
#endif /* LINUX_VER >= 2.6.39 */
uint32 ratespec;
uint32 avg_dist;
@@ -3055,8 +3055,8 @@ dhd_rtt_convert_results_to_host_v1(rtt_result_t *rtt_result, const uint8 *p_data
/* time stamp */
/* get the time elapsed from boot time */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
- get_monotonic_boottime(&ts);
- rtt_report->ts = (uint64)TIMESPEC_TO_US(ts);
+ GET_MONOTONIC_BOOT_TIME(&ts);
+ rtt_report->ts = (uint64)TIMESPEC64_TO_US(ts);
#endif /* LINUX_VER >= 2.6.39 */
if (proxd_status == WL_PROXD_E_REMOTE_FAIL) {
@@ -3149,7 +3149,7 @@ dhd_rtt_convert_results_to_host_v2(rtt_result_t *rtt_result, const uint8 *p_data
wl_proxd_session_state_t session_state;
wl_proxd_status_t proxd_status;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
- struct timespec ts;
+ struct timespec64 ts;
#endif /* LINUX_VER >= 2.6.39 */
uint32 ratespec;
uint32 avg_dist;
@@ -3309,8 +3309,8 @@ dhd_rtt_convert_results_to_host_v2(rtt_result_t *rtt_result, const uint8 *p_data
/* time stamp */
/* get the time elapsed from boot time */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
- get_monotonic_boottime(&ts);
- rtt_report->ts = (uint64)TIMESPEC_TO_US(ts);
+ GET_MONOTONIC_BOOT_TIME(&ts);
+ rtt_report->ts = (uint64)TIMESPEC64_TO_US(ts);
#endif /* LINUX_VER >= 2.6.39 */
if (proxd_status == WL_PROXD_E_REMOTE_FAIL) {
diff --git a/include/linuxver.h b/include/linuxver.h
index 9ea9ad5..2388f36 100644
--- a/include/linuxver.h
+++ b/include/linuxver.h
@@ -909,22 +909,8 @@ int kernel_read_compat(struct file *file, loff_t offset, char *addr, unsigned lo
#define kernel_read_compat(file, offset, addr, count) kernel_read(file, offset, addr, count)
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0) */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
-static inline void get_monotonic_boottime(struct timespec *ts)
-{
- *ts = ktime_to_timespec(ktime_get_boottime());
-}
-#endif /* LINUX_VER >= 4.20 */
+#define GET_MONOTONIC_BOOT_TIME(x) (*(x) = ktime_to_timespec64(ktime_get_boottime()))
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
-static inline void do_gettimeofday(struct timeval *tv)
-{
- struct timespec64 now;
-
- ktime_get_real_ts64(&now);
- tv->tv_sec = now.tv_sec;
- tv->tv_usec = now.tv_nsec/1000;
-}
-#endif /* LINUX_VER >= 5.0 */
+#define GET_TIME_OF_DAY(ts) ktime_get_real_ts64(ts)
#endif /* _linuxver_h_ */
diff --git a/linux_osl.c b/linux_osl.c
index 3dff2b2..b715d31 100755
--- a/linux_osl.c
+++ b/linux_osl.c
@@ -930,12 +930,12 @@ osl_sleep(uint ms)
uint64
osl_sysuptime_us(void)
{
- struct timeval tv;
+ struct timespec64 ts;
uint64 usec;
- do_gettimeofday(&tv);
- /* tv_usec content is fraction of a second */
- usec = (uint64)tv.tv_sec * 1000000ul + tv.tv_usec;
+ GET_TIME_OF_DAY(&ts);
+ /* ts_nsec content is fraction of a second */
+ usec = (uint64)ts.tv_sec * USEC_PER_SEC + (ts.tv_nsec / NSEC_PER_USEC);
return usec;
}
@@ -973,14 +973,14 @@ osl_get_localtime(uint64 *sec, uint64 *usec)
uint64
osl_systztime_us(void)
{
- struct timeval tv;
+ struct timespec64 ts;
uint64 tzusec;
- do_gettimeofday(&tv);
+ GET_TIME_OF_DAY(&ts);
/* apply timezone */
- tzusec = (uint64)((tv.tv_sec - (sys_tz.tz_minuteswest * 60)) *
+ tzusec = (uint64)((ts.tv_sec - (sys_tz.tz_minuteswest * 60)) *
USEC_PER_SEC);
- tzusec += tv.tv_usec;
+ tzusec += ts.tv_nsec / NSEC_PER_USEC;
return tzusec;
}
diff --git a/wl_bam.c b/wl_bam.c
index e380c67..3ec8eea 100644
--- a/wl_bam.c
+++ b/wl_bam.c
@@ -69,9 +69,9 @@ wl_bad_ap_mngr_add_entry(wl_bad_ap_mngr_t *bad_ap_mngr, wl_bad_ap_info_t *bad_ap
#define WL_BAD_AP_INFO_FMT_ITEM_CNT 15u
static inline void
-wl_bad_ap_mngr_tm2ts(struct timespec *ts, const struct tm tm)
+wl_bad_ap_mngr_tm2ts(struct timespec64 *ts, const struct tm tm)
{
- ts->tv_sec = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
+ ts->tv_sec = mktime64(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
ts->tv_nsec = 0;
}
@@ -85,8 +85,8 @@ wl_bad_ap_mngr_timecmp(void *priv, struct list_head *a, struct list_head *b)
{
int ret;
- struct timespec ts1;
- struct timespec ts2;
+ struct timespec64 ts1;
+ struct timespec64 ts2;
wl_bad_ap_info_entry_t *e1 = CONTAINEROF(a, wl_bad_ap_info_entry_t, list);
wl_bad_ap_info_entry_t *e2 = CONTAINEROF(b, wl_bad_ap_info_entry_t, list);
@@ -94,7 +94,7 @@ wl_bad_ap_mngr_timecmp(void *priv, struct list_head *a, struct list_head *b)
wl_bad_ap_mngr_tm2ts(&ts1, e1->bad_ap.tm);
wl_bad_ap_mngr_tm2ts(&ts2, e2->bad_ap.tm);
- ret = timespec_compare((const struct timespec *)&ts1, (const struct timespec *)&ts2);
+ ret = timespec64_compare((const struct timespec64 *)&ts1, (const struct timespec64 *)&ts2);
return ret;
}
@@ -452,7 +452,7 @@ wl_event_adps_bad_ap_mngr(struct bcm_cfg80211 *cfg, void *data)
wl_bad_ap_info_entry_t *entry;
wl_bad_ap_info_t temp;
#if !defined(DHD_ADPS_BAM_EXPORT)
- struct timespec ts;
+ struct timespec64 ts;
#endif /* !DHD_ADPS_BAM_EXPORT */
if (event_data->version != WL_EVENT_ADPS_VER_1) {
@@ -473,7 +473,7 @@ wl_event_adps_bad_ap_mngr(struct bcm_cfg80211 *cfg, void *data)
wl_bad_ap_mngr_fread(cfg, WL_BAD_AP_INFO_FILE_PATH);
}
- getnstimeofday(&ts);
+ ktime_get_real_ts64(&ts);
entry = wl_bad_ap_mngr_find(&cfg->bad_ap_mngr, &bad_ap_data->ea);
if (entry != NULL) {
time_to_tm((ts.tv_sec - (sys_tz.tz_minuteswest * 60)), 0, &entry->bad_ap.tm);
diff --git a/wl_cfgscan.c b/wl_cfgscan.c
index b757666..b3d78f8 100755
--- a/wl_cfgscan.c
+++ b/wl_cfgscan.c
@@ -389,13 +389,13 @@ s32 wl_inform_single_bss(struct bcm_cfg80211 *cfg, wl_bss_info_t *bi, bool updat
signal = notif_bss_info->rssi * 100;
if (!mgmt->u.probe_resp.timestamp) {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
- struct timespec ts;
- get_monotonic_boottime(&ts);
- mgmt->u.probe_resp.timestamp = ((u64)ts.tv_sec*1000000)
- + ts.tv_nsec / 1000;
+ struct timespec64 ts;
+ GET_MONOTONIC_BOOT_TIME(&ts);
+ mgmt->u.probe_resp.timestamp = ((u64)ts.tv_sec*USEC_PER_SEC)
+ + (ts.tv_nsec / NSEC_PER_USEC);
#else
struct timeval tv;
- do_gettimeofday(&tv);
+ GET_TIME_OF_DAY(&tv);
mgmt->u.probe_resp.timestamp = ((u64)tv.tv_sec*1000000)
+ tv.tv_usec;
#endif
@@ -617,7 +617,7 @@ wl_bcnrecv_result_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
s32 err = BCME_OK;
struct wiphy *wiphy = NULL;
wl_bcnrecv_result_t *bcn_recv = NULL;
- struct timespec ts;
+ struct timespec64 ts;
if (!bi) {
WL_ERR(("%s: bi is NULL\n", __func__));
err = BCME_NORESOURCE;
@@ -650,9 +650,9 @@ wl_bcnrecv_result_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
bcn_recv->beacon_interval = bi->beacon_period;
/* kernal timestamp */
- get_monotonic_boottime(&ts);
- bcn_recv->system_time = ((u64)ts.tv_sec*1000000)
- + ts.tv_nsec / 1000;
+ GET_MONOTONIC_BOOT_TIME(&ts);
+ bcn_recv->system_time = ((u64)ts.tv_sec*USEC_PER_SEC)
+ + ts.tv_nsec / NSEC_PER_USEC;
bcn_recv->timestamp[0] = bi->timestamp[0];
bcn_recv->timestamp[1] = bi->timestamp[1];
if ((err = wl_android_bcnrecv_event(cfgdev_to_wlc_ndev(cfgdev, cfg),