Skip to contentSkip to conversation

w35und: more cleanups

PATCH Pavel Machek 3 participants 3 messages Apr 7, 2008 – Apr 8, 2008 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

Next set of cleanups to bring kernel closer to kernel coding style...

drivers/net/wireless/winbond/winbondport/linux/common.h +15 -21
index 3e63f3f..2731e5b 100644
@@ -50,10 +50,10 @@ typedef u8*		PBOOLEAN;
 typedef u16*		PUSHORT;
 typedef u32*		PULONG;
 
-typedef u32		UINT;//$
+typedef u32		UINT;
 typedef u64		ULONG64;
 typedef s32		LONG;
-typedef s32		INT;//$
+typedef s32		INT;
 typedef s16		SHORT;
 typedef s16*	PSHORT;
 
@@ -123,7 +123,7 @@ typedef int	URB_STATUS;
 // Common function definition
 //==================================================================================================
 #ifndef abs
-#define abs(_T)							((_T) < 0 ? -_T : _T)   //Added by wangJS 2006.7.25
+#define abs(_T)							((_T) < 0 ? -_T : _T)
 #endif
 #define DEBUG_ENABLED
 #define ETH_LENGTH_OF_ADDRESS	6
@@ -133,26 +133,19 @@ #else
 #define WBDEBUG( _M )	0
 #endif
 
-// #define OS_PACKET_SIZE( _A )						<-- Supported. In WbLinux module
-// #define OS_LINK_STATUS							<-- Supported. In WbLinux module
-// #define OS_SET_SHUTDOWN( _A )					<-- Supported. In WbLinux module
-// #define OS_CONNECT_STATUS_INDICATE( _A, _F )		<-- Supported. In WbLinux module
 #define OS_DISCONNECTED	0
 #define OS_CONNECTED	1
-// #define OS_STOP( _A )							<-- Supported. In WbLinux module
 
-// #define OS_CURRENT_RX_BYTE( _A )					<-- Supported. In WbLinux module
-// #define OS_CURRENT_TX_BYTE( _A )					<-- Supported. In WbLinux module
+
 #define OS_EVENT_INDICATE( _A, _B, _F )
 #define OS_PMKID_STATUS_EVENT( _A )
-// #define OS_RECEIVE_PACKET_INDICATE( _A, _D )		<-- Supported. In WbLinux module
-// #define OS_GET_PACKET( _A, _D )					<-- Supported. In WbLinux module
-// #define OS_GET_PACKET_COMPLETE( _A, _D )			<-- Supported. In WbLinux module
 
-// #define cpu_to_le32( _A )			<-- Supported. Linux OS
-// #define cpu_to_le16( _A )			<-- Supported. Linux OS
+
 #define __ALIGN_PACK__                  __attribute__ ((packed))
 
+/* Uff, no, longs are not atomic on all architectures Linux
+ * supports. This should really use tomic_t */
+
 #define OS_ATOMIC						ULONG
 #define OS_ATOMIC_READ( _A, _V )		_V
 #define OS_ATOMIC_INC( _A, _V )			EncapAtomicInc( _A, (PVOID)_V )
@@ -165,13 +158,13 @@ #define OS_MEMORY_COPY( _T, _S, _SIZE )	
 #define OS_MEMORY_CLEAR( _A, _S )		memset( (PUCHAR)_A,0,_S)
 #define OS_MEMORY_COMPARE( _A, _B, _S )	(memcmp(_A,_B,_S)? 0 : 1) // Definition is reverse with Ndis 1: the same 0: different
 #define OS_DELAY( _MT )					//NdisStallExecution( _MT ) _MT : microsecond
-//#define OS_SLEEP( _MT )					<--- Supported in WbUsb module
 
-#define OS_SPIN_LOCK					spinlock_t//NDIS_SPIN_LOCK
-#define OS_SPIN_LOCK_ALLOCATE( _S )		spin_lock_init( _S ); //NdisAllocateSpinLock( _S )	
-#define OS_SPIN_LOCK_FREE( _S )			//NdisFreeSpinLock( _S )
+
+#define OS_SPIN_LOCK					spinlock_t
+#define OS_SPIN_LOCK_ALLOCATE( _S )		spin_lock_init( _S );
+#define OS_SPIN_LOCK_FREE( _S )
 #define OS_SPIN_LOCK_ACQUIRED( _S )		spin_lock_irq( _S )
-#define OS_SPIN_LOCK_RELEASED( _S )		spin_unlock_irq( _S ); //NdisReleaseSpinLock( _S )
+#define OS_SPIN_LOCK_RELEASED( _S )		spin_unlock_irq( _S );
 
 #define OS_TIMER						struct timer_list
 #define OS_TIMER_INITIAL( _T, _F, _P )			\
@@ -180,6 +173,7 @@ #define OS_TIMER_INITIAL( _T, _F, _P )		
 	(_T)->function = (void *)_F##_1a;			\
 	(_T)->data = (unsigned long)_P;				\
 }
+
 // _S : Millisecond
 // 20060420 At least 1 large than jiffies
 #define OS_TIMER_SET( _T, _S )					\
@@ -187,7 +181,7 @@ #define OS_TIMER_SET( _T, _S )					\
 	(_T)->expires = jiffies + ((_S*HZ+999)/1000);\
 	add_timer( _T );							\
 }
-#define OS_TIMER_CANCEL( _T, _B )		del_timer_sync( _T ) //NdisMCancelTimer( _T, _B )
+#define OS_TIMER_CANCEL( _T, _B )		del_timer_sync( _T )
 #define OS_TIMER_GET_SYS_TIME( _T )		(*_T=jiffies)
 
 
drivers/net/wireless/winbond/winbondport/linux/new_wireless.c +172 -191

400 lines not on this page · raw message

drivers/net/wireless/winbond/winbondport/linux/sysdef.h +1 -1
index e4ec713..093b726 100644
@@ -77,7 +77,7 @@ #include "../wbhal_f.h"
 #include "../wblinux_f.h"
 #include "new_wireless.h"
 // Kernel Timer resolution, NDIS is 10ms, 10000us
-#define MIN_TIMEOUT_VAL				(10)		//ms
+#define MIN_TIMEOUT_VAL	(10) //ms
 
 
 #endif
drivers/net/wireless/winbond/winbondport/linux/wb35reg.c +221 -289

901 lines not on this page · raw message

drivers/net/wireless/winbond/winbondport/linux/wb35rx.c +63 -96

355 lines not on this page · raw message

drivers/net/wireless/winbond/winbondport/linux/wb35tx.c +41 -79

278 lines not on this page · raw message

drivers/net/wireless/winbond/winbondport/linux/wbusb.c +7 -64

122 lines not on this page · raw message

drivers/net/wireless/winbond/winbondport/linux/wbusb_f.h +10 -24
index 58848bb..5d04861 100644
@@ -11,34 +11,20 @@
 //	  
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
-int wb35_open( struct net_device *netdev );
-int wb35_close( struct net_device *netdev );
-BOOL WbUsb_initial( IN phw_data_t pHwData );
-VOID WbUsb_destroy( IN phw_data_t pHwData );
-BOOL WbWLanInitialize( IN PADAPTER Adapter );
+int wb35_open(struct net_device *netdev);
+int wb35_close(struct net_device *netdev);
+BOOL WbUsb_initial(phw_data_t pHwData);
+VOID WbUsb_destroy(phw_data_t pHwData);
+BOOL WbWLanInitialize(PADAPTER Adapter);
 #define	WbUsb_Stop( _A )
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	void *wb35_probe( struct usb_device *udev, unsigned int ifnum, const struct usb_device_id *id_table );
-	void wb35_disconnect(struct usb_device *udev, void *ptr);
-#else
-	int wb35_probe( struct usb_interface *intf,const struct usb_device_id *id_table );
-	void wb35_disconnect(struct usb_interface *intf);
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	#define wb_usb_submit_urb(_A) usb_submit_urb(_A)
-#else
-	#define wb_usb_submit_urb(_A) usb_submit_urb(_A,GFP_ATOMIC)
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	#define wb_usb_alloc_urb(_A) usb_alloc_urb(_A)
-#else
-	#define wb_usb_alloc_urb(_A) usb_alloc_urb(_A,GFP_ATOMIC)
-#endif
+int wb35_probe(struct usb_interface *intf,const struct usb_device_id *id_table);
+void wb35_disconnect(struct usb_interface *intf);
 
 
+#define wb_usb_submit_urb(_A) usb_submit_urb(_A, GFP_ATOMIC)
+#define wb_usb_alloc_urb(_A) usb_alloc_urb(_A, GFP_ATOMIC)
+
 #define WbUsb_CheckForHang( _P )
 #define WbUsb_DetectStart( _P, _I )
 
drivers/net/wireless/winbond/winbondport/mds.c +3 -3
index 5556e6a..7d40c0e 100644
@@ -34,7 +34,7 @@ Mds_Destroy( IN PADAPTER Adapter )
 }
 
 VOID
-Mds_Tx( IN PADAPTER Adapter )
+Mds_Tx(PADAPTER Adapter)
 {
 	phw_data_t	pHwData = &Adapter->sHwData;
 	PMDS		pMds = &Adapter->Mds;
@@ -47,10 +47,10 @@ Mds_Tx( IN PADAPTER Adapter )
 
 
 	//931130.5.a
-	if( pMds->TxPause )
+	if (pMds->TxPause)
 		return;
 	// 20060717.3 Add
-	if( !hal_driver_init_OK( pHwData ) )
+	if (!hal_driver_init_OK(pHwData))
 		return;
 
 	//Only one thread can be run here
drivers/net/wireless/winbond/winbondport/mlmetxrx.c +28 -50

115 lines not on this page · raw message

drivers/net/wireless/winbond/winbondport/phy_calibration.c +0 -3
index d89047b..1e36218 100644
@@ -19,15 +19,12 @@ #include "phy_calibration.h"
 /****************** LOCAL CONSTANT AND MACRO SECTION ************************/
 #define LOOP_TIMES      20
 #define US              1000//MICROSECOND
-//#define US              100//MICROSECOND
 
 #define AG_CONST        0.6072529350
 #define FIXED(X)        ((s32)((X) * 32768.0))
-#define FLOAT(X)        ((X) / 32768.0)
 #define DEG2RAD(X)      0.017453 * (X)
 
 /****************** LOCAL TYPE DEFINITION SECTION ***************************/
-//typedef long int        fixed; /* 16.16 fixed-point */
 typedef s32         fixed; /* 16.16 fixed-point */
 
 static const fixed Angles[]=
drivers/net/wireless/winbond/winbondport/smetask.c +134 -198

586 lines not on this page · raw message

drivers/net/wireless/winbond/winbondport/wblinux.c +7 -11
index 147989f..3a836c4 100644
@@ -10,19 +10,15 @@
 //============================================================================
 #include "os_common.h"
 #include "linux/new_wireless.h"
+
 ULONG
-  WBLINUX_MemoryAlloc( OUT PVOID *VirtualAddress, IN UINT Length )
+WBLINUX_MemoryAlloc( OUT PVOID *VirtualAddress, IN UINT Length )
 {
-#ifndef CONFIG_BOARD_W90N740
-   *VirtualAddress = kmalloc( Length, GFP_ATOMIC ); //GFP_KERNEL is not suitable
-#else
-   //Added by WangJS 2006.9.1,
-   //To suit for cache mechanism of W90N740 board, the MSB of assined address must be 1
-   *VirtualAddress = (PVOID)((ULONG)kmalloc( Length, GFP_ATOMIC ) | 0x80000000); //GFP_KERNEL is not suitable
-#endif
-   if( *VirtualAddress == NULL )
-     return OS_MEMORY_ALLOC_FAIL;
-   return OS_MEMORY_ALLOC_OK;
+	*VirtualAddress = kmalloc( Length, GFP_ATOMIC ); //GFP_KERNEL is not suitable
+
+	if (*VirtualAddress == NULL)
+		return OS_MEMORY_ALLOC_FAIL;
+	return OS_MEMORY_ALLOC_OK;
 }
 
 LONG
drivers/net/wireless/winbond/winbondport/wblinux_s.h +12 -14
index 4995194..6faf1e4 100644
@@ -1,43 +1,42 @@
 //============================================================
 // wblinux_s.h
 //
-#define OS_MEMORY_ALLOC( _V, _S )					WBLINUX_MemoryAlloc( _V, _S )
-#define OS_PACKET_SIZE( _A )						(!Adapter->WbLinux.shutdown && Adapter->WbLinux.skb_array[Adapter->WbLinux.skb_GetIndex]) ? (USHORT)Adapter->WbLinux.skb_array[Adapter->WbLinux.skb_GetIndex]->len : 0
-#define OS_LINK_STATUS							(Adapter->WbLinux.LinkStatus == OS_CONNECTED)
-#define OS_SET_SHUTDOWN( _A )						_A->WbLinux.shutdown=1
-#define OS_SET_RESUME( _A )							_A->WbLinux.shutdown=0
+#define OS_MEMORY_ALLOC( _V, _S )	WBLINUX_MemoryAlloc( _V, _S )
+#define OS_PACKET_SIZE( _A )		(!Adapter->WbLinux.shutdown && Adapter->WbLinux.skb_array[Adapter->WbLinux.skb_GetIndex]) ? (USHORT)Adapter->WbLinux.skb_array[Adapter->WbLinux.skb_GetIndex]->len : 0
+#define OS_LINK_STATUS			(Adapter->WbLinux.LinkStatus == OS_CONNECTED)
+#define OS_SET_SHUTDOWN( _A )		_A->WbLinux.shutdown=1
+#define OS_SET_RESUME( _A )		_A->WbLinux.shutdown=0
 #define OS_CONNECT_STATUS_INDICATE( _A, _F )		WBLINUX_ConnectStatus( _A, _F )
 #define OS_DISCONNECTED	0
 #define OS_CONNECTED	1
 #define OS_STOP( _A )	WBLINUX_stop( _A )
 
-#define OS_CURRENT_RX_BYTE( _A )					_A->WbLinux.RxByteCount
-#define OS_CURRENT_TX_BYTE( _A )					_A->WbLinux.TxByteCount
+#define OS_CURRENT_RX_BYTE( _A )		_A->WbLinux.RxByteCount
+#define OS_CURRENT_TX_BYTE( _A )		_A->WbLinux.TxByteCount
 #define OS_EVENT_INDICATE( _A, _B, _F )
 #define OS_PMKID_STATUS_EVENT( _A )
 #define OS_RECEIVE_PACKET_INDICATE( _A, _D )		WBLinux_ReceivePacket( _A, _D )
 #define OS_RECEIVE_802_1X_PACKET_INDICATE( _A, _D )	EAP_ReceivePacket( _A, _D )
-#define OS_GET_PACKET( _A, _D )						WBLINUX_GetNextPacket( _A, _D )
-#define OS_GET_PACKET_COMPLETE( _A, _D )			WBLINUX_GetNextPacketCompleted( _A, _D )
+#define OS_GET_PACKET( _A, _D )				WBLINUX_GetNextPacket( _A, _D )
+#define OS_GET_PACKET_COMPLETE( _A, _D )	WBLINUX_GetNextPacketCompleted( _A, _D )
 #define OS_SEND_RESULT( _A, _ID, _R )
 
 #define WBLINUX_PACKET_ARRAY_SIZE	(ETHERNET_TX_DESCRIPTORS*4)
 
-
 typedef struct _WBLINUX
 {
 	OS_SPIN_LOCK	AtomicSpinLock;
 	OS_SPIN_LOCK	SpinLock;
-	ULONG	shutdown;// 931130.4.s
+	ULONG	shutdown;
 
 	// For storing the 802.3 NDIS packet
 	struct net_device_stats 	stats;
 
 	OS_ATOMIC	ThreadCount;
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 1 line · Pavel Machek

Next set of cleanups to bring kernel closer to kernel coding style...

\Where is that driver coming from to start with? I hope no one intends to send it to mainline in a shape like that?

Quoted 1 line
#2 lore raw

Nope, we are planning to rewrite it, Pavel is cleaning it up for easirer study. For its origin see http://lkml.org/lkml/2007/10/21/116.

Quoted 7 lines · Christoph Hellwig
Quoted 1 line · Pavel Machek

Next set of cleanups to bring kernel closer to kernel coding style...

\Where is that driver coming from to start with? I hope no one intends to send it to mainline in a shape like that?

Quoted 1 line