Patchwork [upstream,for,stable,8/8] staging: vt6656: 64bit fixes: vCommandTimerWait change calculation of timer.

login
register
mail settings
Submitter Malcolm Priestley
Date Dec. 27, 2012, 1:25 p.m.
Message ID <1356614729.3447.48.camel@canaries64>
Download mbox | patch
Permalink /patch/209022/
State New
Headers show

Comments

Malcolm Priestley - Dec. 27, 2012, 1:25 p.m.
upstream commit
70e227790d4ee4590023d8041a3485f8053593fc

Tested on kernel 2.6.35, 3.0, 3.2, 3.5 & 3.7

staging: vt6656: 64bit fixes: vCommandTimerWait change calculation of timer.
    
The timer appears to run too fast/race on 64 bit systems.
    
Using msecs_to_jiffies seems to cause a deadlock on 64 bit.
    
A calculation of (MSecond * HZ) / 1000 appears to run satisfactory.
    
Change BSSIDInfoCount to u32.
    
After this patch the driver can be successfully connect on little endian 64/32 bit systems.

Cc: stable@kernel.org  # 2.6.35+
Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Patch

diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c
index 586fbe1..b854d7e 100644
--- a/drivers/staging/vt6656/wcmd.c
+++ b/drivers/staging/vt6656/wcmd.c
@@ -316,17 +316,19 @@  s_MgrMakeProbeRequest(
     return pTxPacket;
 }
 
-void vCommandTimerWait(void *hDeviceContext, unsigned int MSecond)
+void vCommandTimerWait(void *hDeviceContext, unsigned long MSecond)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
+	PSDevice pDevice = (PSDevice)hDeviceContext;
 
-    init_timer(&pDevice->sTimerCommand);
-    pDevice->sTimerCommand.data = (unsigned long)pDevice;
-    pDevice->sTimerCommand.function = (TimerFunction)vRunCommand;
-    // RUN_AT :1 msec ~= (HZ/1024)
-    pDevice->sTimerCommand.expires = (unsigned int)RUN_AT((MSecond * HZ) >> 10);
-    add_timer(&pDevice->sTimerCommand);
-    return;
+	init_timer(&pDevice->sTimerCommand);
+
+	pDevice->sTimerCommand.data = (unsigned long)pDevice;
+	pDevice->sTimerCommand.function = (TimerFunction)vRunCommand;
+	pDevice->sTimerCommand.expires = RUN_AT((MSecond * HZ) / 1000);
+
+	add_timer(&pDevice->sTimerCommand);
+
+	return;
 }
 
 void vRunCommand(void *hDeviceContext)
diff --git a/drivers/staging/vt6656/wpa2.h b/drivers/staging/vt6656/wpa2.h
index 46c2959..c359252 100644
--- a/drivers/staging/vt6656/wpa2.h
+++ b/drivers/staging/vt6656/wpa2.h
@@ -45,8 +45,8 @@  typedef struct tagsPMKIDInfo {
 } PMKIDInfo, *PPMKIDInfo;
 
 typedef struct tagSPMKIDCache {
-    unsigned long       BSSIDInfoCount;
-    PMKIDInfo   BSSIDInfo[MAX_PMKID_CACHE];
+	u32 BSSIDInfoCount;
+	PMKIDInfo BSSIDInfo[MAX_PMKID_CACHE];
 } SPMKIDCache, *PSPMKIDCache;