Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e829d65e authored by Larry Finger's avatar Larry Finger
Browse files

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: default avatarLarry Finger <Larry.Finger@lwfinger.net>
parent 1800925f
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -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	)
+1 −2
Original line number Diff line number Diff line
@@ -642,8 +642,7 @@ struct r8192_priv {
	int		rxringcount;
	u16		rxbuffersize;

	u32		LastRxDescTSFHigh;
	u32		LastRxDescTSFLow;
	u64		LastRxDescTSF;

	u16		EarlyRxThreshold;
	u32		ReceiveConfig;
+12 −15
Original line number Diff line number Diff line
@@ -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)))||
			((tl<rb)&&(tl<MSECS(69))&&((tl+0xffffffff-rb)>MSECS(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);
	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);
+1 −1
Original line number Diff line number Diff line
@@ -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);
+4 −5
Original line number Diff line number Diff line
@@ -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);
Loading