From: Larry Finger Date: Mon, 1 Aug 2011 20:31:00 +0000 (-0500) Subject: staging: rtl8192e: Modify time handling X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e829d65e7855fb4c98a81dd8c210c5b6d738bde1;p=linux-beck.git staging: rtl8192e: Modify time handling In several places, the driver keeps times (in jiffies) in two 32-bit quantities. In the rtl8192_hw_to_sleep(), there is an error in the calculation of the difference between two 64-bit quantities. Rather than fix that error, I have converted to a single 64-bit number. That makes the code be much cleaner and clearer. Signed-off-by: Larry Finger --- diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index e633f0b074e2..f585f71e14b7 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -2243,13 +2243,10 @@ void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stat { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - if (stats->bIsAMPDU && !stats->bFirstMPDU) { - stats->mac_time[0] = priv->LastRxDescTSFLow; - stats->mac_time[1] = priv->LastRxDescTSFHigh; - } else { - priv->LastRxDescTSFLow = stats->mac_time[0]; - priv->LastRxDescTSFHigh = stats->mac_time[1]; - } + if (stats->bIsAMPDU && !stats->bFirstMPDU) + stats->mac_time = priv->LastRxDescTSF; + else + priv->LastRxDescTSF = stats->mac_time; } long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index ) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 22b0a438b9dd..4f94d0a18f06 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -642,8 +642,7 @@ struct r8192_priv { int rxringcount; u16 rxbuffersize; - u32 LastRxDescTSFHigh; - u32 LastRxDescTSFLow; + u64 LastRxDescTSF; u16 EarlyRxThreshold; u32 ReceiveConfig; diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index 58966e07be78..ea9eac712530 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -78,36 +78,33 @@ void rtl8192_hw_wakeup_wq(void *data) #define MIN_SLEEP_TIME 50 #define MAX_SLEEP_TIME 10000 -void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl) +void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) { struct r8192_priv *priv = rtllib_priv(dev); - u32 rb = jiffies; + u32 tmp; unsigned long flags; spin_lock_irqsave(&priv->ps_lock,flags); - tl -= MSECS(8+16+7); + time -= MSECS(8+16+7); - if (((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME)) - ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) { + if ((time - jiffies) <= MSECS(MIN_SLEEP_TIME)) { spin_unlock_irqrestore(&priv->ps_lock,flags); - printk("too short to sleep::%x, %x, %lx\n",tl, rb, MSECS(MIN_SLEEP_TIME)); + printk(KERN_INFO "too short to sleep::%lld < %ld\n", + time - jiffies, MSECS(MIN_SLEEP_TIME)); return; } - if (((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| - ((tl < rb) && (tl>MSECS(69)) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))|| - ((tlMSECS(MAX_SLEEP_TIME)))) { - printk("========>too long to sleep:%x, %x, %lx\n", tl, rb, MSECS(MAX_SLEEP_TIME)); + if ((time - jiffies) > MSECS(MAX_SLEEP_TIME)) { + printk(KERN_INFO "========>too long to sleep:%lld > %ld\n", + time - jiffies, MSECS(MAX_SLEEP_TIME)); spin_unlock_irqrestore(&priv->ps_lock,flags); return; } - { - u32 tmp = (tl>rb)?(tl-rb):(rb-tl); - queue_delayed_work_rsl(priv->rtllib->wq, - &priv->rtllib->hw_wakeup_wq,tmp); - } + tmp = time - jiffies; + queue_delayed_work_rsl(priv->rtllib->wq, + &priv->rtllib->hw_wakeup_wq,tmp); queue_delayed_work_rsl(priv->rtllib->wq, (void *)&priv->rtllib->hw_sleep_wq,0); spin_unlock_irqrestore(&priv->ps_lock,flags); diff --git a/drivers/staging/rtl8192e/rtl_ps.h b/drivers/staging/rtl8192e/rtl_ps.h index d97a6edd1e85..453df2cbb3d2 100644 --- a/drivers/staging/rtl8192e/rtl_ps.h +++ b/drivers/staging/rtl8192e/rtl_ps.h @@ -33,7 +33,7 @@ struct net_device; #define INIT_DEFAULT_CHAN 1 void rtl8192_hw_wakeup(struct net_device *dev); -void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl); +void rtl8192_hw_to_sleep(struct net_device *dev, u64 time); void rtllib_ips_leave_wq(struct net_device *dev); void rtllib_ips_leave(struct net_device *dev); void IPSLeave_wq (void *data); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 2ab1e6cb6390..2a394ee9f750 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -993,7 +993,7 @@ struct ieee_ibss_seq { * any adverse affects. */ struct rtllib_rx_stats { #if 1 - u32 mac_time[2]; + u64 mac_time; s8 rssi; u8 signal; u8 noise; @@ -1679,7 +1679,7 @@ struct rtllib_network { struct rtllib_tim_parameters tim; u8 dtim_period; u8 dtim_data; - u32 last_dtim_sta_time[2]; + u64 last_dtim_sta_time; u8 wmm_info; struct rtllib_wmm_ac_param wmm_param[4]; @@ -2305,8 +2305,7 @@ struct rtllib_device { int ps_timeout; int ps_period; struct tasklet_struct ps_task; - u32 ps_th; - u32 ps_tl; + u64 ps_time; bool polling; short raw_tx; @@ -2498,7 +2497,7 @@ struct rtllib_device { /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); - void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); + void (*enter_sleep_state) (struct net_device *dev, u64 time); short (*ps_is_queue_empty) (struct net_device *dev); int (*handle_beacon) (struct net_device * dev, struct rtllib_beacon * beacon, struct rtllib_network * network); int (*handle_assoc_response) (struct net_device * dev, struct rtllib_assoc_response_frame * resp, struct rtllib_network * network); diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 24ad9713d0b6..9606bedf16de 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1867,8 +1867,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, network->dtim_period = info_element->data[1]; if (ieee->state != RTLLIB_LINKED) break; - network->last_dtim_sta_time[0] = jiffies; - network->last_dtim_sta_time[1] = stats->mac_time[1]; + network->last_dtim_sta_time = jiffies; network->dtim_data = RTLLIB_DTIM_VALID; @@ -2466,8 +2465,7 @@ static inline void update_network(struct rtllib_network *dst, dst->atim_window = src->atim_window; dst->dtim_period = src->dtim_period; dst->dtim_data = src->dtim_data; - dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; - dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; + dst->last_dtim_sta_time = src->last_dtim_sta_time; memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters)); dst->bssht.bdSupportHT = src->bssht.bdSupportHT; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 11433c61bdaf..29277d18f021 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2037,7 +2037,7 @@ void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee) } -short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) +static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) { int timeout = ieee->ps_timeout; u8 dtim; @@ -2074,7 +2074,7 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - if (time_l){ + if (time){ if (ieee->bAwakePktSent == true) { pPSC->LPSAwakeIntvl = 1; } else { @@ -2107,17 +2107,11 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; } - *time_l = ieee->current_network.last_dtim_sta_time[0] + *time = ieee->current_network.last_dtim_sta_time + MSECS(ieee->current_network.beacon_interval * LPSAwakeIntvl_tmp); } } - if (time_h) { - *time_h = ieee->current_network.last_dtim_sta_time[1]; - if (time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) - *time_h += 1; - } - return 1; @@ -2126,7 +2120,7 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) inline void rtllib_sta_ps(struct rtllib_device *ieee) { - u32 th,tl; + u64 time; short sleep; unsigned long flags,flags2; @@ -2146,7 +2140,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - sleep = rtllib_sta_ps_sleep(ieee,&th, &tl); + sleep = rtllib_sta_ps_sleep(ieee, &time); /* 2 wake, 1 sleep, 0 do nothing */ if (sleep == 0) { @@ -2154,7 +2148,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) } if (sleep == 1){ if (ieee->sta_sleep == LPS_IS_SLEEP){ - ieee->enter_sleep_state(ieee->dev,th,tl); + ieee->enter_sleep_state(ieee->dev, time); } else if (ieee->sta_sleep == LPS_IS_WAKE){ @@ -2164,8 +2158,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) ieee->sta_sleep = LPS_WAIT_NULL_DATA_SEND; ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_null_frame(ieee,1); - ieee->ps_th = th; - ieee->ps_tl = tl; + ieee->ps_time = time; } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); @@ -2241,7 +2234,7 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) /* Null frame with PS bit set */ if (success){ ieee->sta_sleep = LPS_IS_SLEEP; - ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl); + ieee->enter_sleep_state(ieee->dev, ieee->ps_time); } /* if the card report not success we can't be sure the AP * has not RXed so we can't assume the AP believe us awake