lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 30 Oct 2008 16:14:39 +0200
From:	Pekka Enberg <penberg@...helsinki.fi>
To:	greg@...ah.com
Cc:	linux-kernel@...r.kernel.org,
	Pekka Enberg <penberg@...helsinki.fi>,
	Pavel Machek <pavel@...e.cz>
Subject: [PATCH] w35und: remove global struct ieee80211_hw

Remove the my_dev global variable from wbusb.c by passing a pointer to struct
ieee80211_hw around so that packet_came() gets it.

Cc: Pavel Machek <pavel@...e.cz>
Signed-off-by: Pekka Enberg <penberg@...helsinki.fi>
---
 drivers/staging/winbond/wb35rx.c    |   29 +++++++++-----
 drivers/staging/winbond/wb35rx_f.h  |    7 ++-
 drivers/staging/winbond/wbhal.c     |   11 +++--
 drivers/staging/winbond/wbhal_f.h   |    2 +-
 drivers/staging/winbond/wblinux.c   |   73 ++++++++++++++++++-----------------
 drivers/staging/winbond/wblinux_f.h |    3 +-
 drivers/staging/winbond/wbusb.c     |    8 +--
 7 files changed, 72 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/winbond/wb35rx.c b/drivers/staging/winbond/wb35rx.c
index 15a0650..cd5a8e1 100644
--- a/drivers/staging/winbond/wb35rx.c
+++ b/drivers/staging/winbond/wb35rx.c
@@ -10,24 +10,29 @@
 //============================================================================
 #include <linux/usb.h>
 
+#include "core.h"
 #include "sysdef.h"
 #include "wb35rx_f.h"
 
-void Wb35Rx_start(phw_data_t pHwData)
+void Wb35Rx_start(struct ieee80211_hw *hw)
 {
+	struct wbsoft_priv *priv = hw->priv;
+	phw_data_t pHwData = &priv->sHwData;
 	PWB35RX pWb35Rx = &pHwData->Wb35Rx;
 
 	// Allow only one thread to run into the Wb35Rx() function
 	if (atomic_inc_return(&pWb35Rx->RxFireCounter) == 1) {
 		pWb35Rx->EP3vm_state = VM_RUNNING;
-		Wb35Rx(pHwData);
+		Wb35Rx(hw);
 	} else
 		atomic_dec(&pWb35Rx->RxFireCounter);
 }
 
 // This function cannot reentrain
-void Wb35Rx(  phw_data_t pHwData )
+void Wb35Rx(struct ieee80211_hw *hw)
 {
+	struct wbsoft_priv *priv = hw->priv;
+	phw_data_t pHwData = &priv->sHwData;
 	PWB35RX	pWb35Rx = &pHwData->Wb35Rx;
 	u8 *	pRxBufferAddress;
 	struct urb *urb = pWb35Rx->RxUrb;
@@ -69,7 +74,7 @@ void Wb35Rx(  phw_data_t pHwData )
 	usb_fill_bulk_urb(urb, pHwData->WbUsb.udev,
 			  usb_rcvbulkpipe(pHwData->WbUsb.udev, 3),
 			  pRxBufferAddress, MAX_USB_RX_BUFFER,
-			  Wb35Rx_Complete, pHwData);
+			  Wb35Rx_Complete, hw);
 
 	pWb35Rx->EP3vm_state = VM_RUNNING;
 
@@ -89,7 +94,9 @@ error:
 
 void Wb35Rx_Complete(struct urb *urb)
 {
-	phw_data_t	pHwData = urb->context;
+	struct ieee80211_hw *hw = urb->context;
+	struct wbsoft_priv *priv = hw->priv;
+	phw_data_t pHwData = &priv->sHwData;
 	PWB35RX		pWb35Rx = &pHwData->Wb35Rx;
 	u8 *		pRxBufferAddress;
 	u32		SizeCheck;
@@ -150,11 +157,11 @@ void Wb35Rx_Complete(struct urb *urb)
 	pWb35Rx->RxBufferSize[ RxBufferId ] = BulkLength;
 
 	if (!pWb35Rx->RxOwner[ RxBufferId ])
-		Wb35Rx_indicate(pHwData);
+		Wb35Rx_indicate(hw);
 
 	kfree(pWb35Rx->pDRx);
 	// Do the next receive
-	Wb35Rx(pHwData);
+	Wb35Rx(hw);
 	return;
 
 error:
@@ -257,11 +264,13 @@ void Wb35Rx_adjust(PDESCRIPTOR pRxDes)
 	pRxDes->buffer_size[0] = BufferSize;
 }
 
-extern void packet_came(char *pRxBufferAddress, int PacketSize);
+extern void packet_came(struct ieee80211_hw *hw, char *pRxBufferAddress, int PacketSize);
 
 
-u16 Wb35Rx_indicate(phw_data_t pHwData)
+u16 Wb35Rx_indicate(struct ieee80211_hw *hw)
 {
+	struct wbsoft_priv *priv = hw->priv;
+	phw_data_t pHwData = &priv->sHwData;
 	DESCRIPTOR	RxDes;
 	PWB35RX	pWb35Rx = &pHwData->Wb35Rx;
 	u8 *		pRxBufferAddress;
@@ -317,7 +326,7 @@ u16 Wb35Rx_indicate(phw_data_t pHwData)
 			RxDes.buffer_total_size = RxDes.buffer_size[0];
 			Wb35Rx_adjust(&RxDes);
 
-			packet_came(pRxBufferAddress, PacketSize);
+			packet_came(hw, pRxBufferAddress, PacketSize);
 
 			// Move RxBuffer point to the next
 			stmp = PacketSize + 3;
diff --git a/drivers/staging/winbond/wb35rx_f.h b/drivers/staging/winbond/wb35rx_f.h
index 9fb2e2a..5585b55 100644
--- a/drivers/staging/winbond/wb35rx_f.h
+++ b/drivers/staging/winbond/wb35rx_f.h
@@ -1,6 +1,7 @@
 #ifndef __WINBOND_WB35RX_F_H
 #define __WINBOND_WB35RX_F_H
 
+#include <net/mac80211.h>
 #include "wbhal_s.h"
 
 //====================================
@@ -10,11 +11,11 @@ void		Wb35Rx_reset_descriptor(  phw_data_t pHwData );
 unsigned char		Wb35Rx_initial(  phw_data_t pHwData );
 void		Wb35Rx_destroy(  phw_data_t pHwData );
 void		Wb35Rx_stop(  phw_data_t pHwData );
-u16		Wb35Rx_indicate(  phw_data_t pHwData );
+u16		Wb35Rx_indicate(struct ieee80211_hw *hw);
 void		Wb35Rx_adjust(  PDESCRIPTOR pRxDes );
-void		Wb35Rx_start(  phw_data_t pHwData );
+void		Wb35Rx_start(struct ieee80211_hw *hw);
 
-void		Wb35Rx(  phw_data_t pHwData );
+void		Wb35Rx(struct ieee80211_hw *hw);
 void		Wb35Rx_Complete(struct urb *urb);
 
 #endif
diff --git a/drivers/staging/winbond/wbhal.c b/drivers/staging/winbond/wbhal.c
index 289ca7e..d2be5fb 100644
--- a/drivers/staging/winbond/wbhal.c
+++ b/drivers/staging/winbond/wbhal.c
@@ -315,9 +315,10 @@ static void hal_led_control(unsigned long data)
 	add_timer(&pHwData->LEDTimer);
 }
 
-
-u8 hal_init_hardware(phw_data_t pHwData, struct wbsoft_priv * adapter)
+u8 hal_init_hardware(struct ieee80211_hw *hw)
 {
+	struct wbsoft_priv *priv = hw->priv;
+	phw_data_t pHwData = &priv->sHwData;
 	u16 SoftwareSet;
 
 	// Initial the variable
@@ -333,7 +334,7 @@ u8 hal_init_hardware(phw_data_t pHwData, struct wbsoft_priv * adapter)
 				pHwData->InitialResource = 4;
 				init_timer(&pHwData->LEDTimer);
 				pHwData->LEDTimer.function = hal_led_control;
-				pHwData->LEDTimer.data = (unsigned long) adapter;
+				pHwData->LEDTimer.data = (unsigned long) priv;
 				pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(1000);
 				add_timer(&pHwData->LEDTimer);
 
@@ -349,8 +350,8 @@ u8 hal_init_hardware(phw_data_t pHwData, struct wbsoft_priv * adapter)
 					return false;
 				#endif
 
-				Wb35Rx_start( pHwData );
-				Wb35Tx_EP2VM_start(adapter);
+				Wb35Rx_start(hw);
+				Wb35Tx_EP2VM_start(priv);
 
 				return true;
 			}
diff --git a/drivers/staging/winbond/wbhal_f.h b/drivers/staging/winbond/wbhal_f.h
index e7a1d61..dc5709f 100644
--- a/drivers/staging/winbond/wbhal_f.h
+++ b/drivers/staging/winbond/wbhal_f.h
@@ -21,7 +21,7 @@ void hal_clear_all_key(  phw_data_t pHwData );
 void hal_get_ethernet_address(  phw_data_t pHwData,  u8 *current_address );
 void hal_set_ethernet_address(  phw_data_t pHwData,  u8 *current_address );
 void hal_get_permanent_address(  phw_data_t pHwData,  u8 *pethernet_address );
-unsigned char hal_init_hardware(  phw_data_t pHwData,  struct wbsoft_priv * adapter );
+u8 hal_init_hardware(struct ieee80211_hw *hw);
 void hal_set_power_save_mode(  phw_data_t pHwData,  unsigned char power_save,  unsigned char wakeup,  unsigned char dtim );
 void hal_get_power_save_mode(  phw_data_t pHwData,   u8 *pin_pwr_save );
 void hal_set_slot_time(  phw_data_t pHwData,  u8 type );
diff --git a/drivers/staging/winbond/wblinux.c b/drivers/staging/winbond/wblinux.c
index 3b02aae..31f2d20 100644
--- a/drivers/staging/winbond/wblinux.c
+++ b/drivers/staging/winbond/wblinux.c
@@ -85,8 +85,9 @@ WbWlanHalt(  struct wbsoft_priv * adapter )
 }
 
 unsigned char
-WbWLanInitialize(struct wbsoft_priv * adapter)
+WbWLanInitialize(struct ieee80211_hw *hw)
 {
+	struct wbsoft_priv *priv = hw->priv;
 	phw_data_t	pHwData;
 	u8		*pMacAddr;
 	u8		*pMacAddr2;
@@ -97,22 +98,22 @@ WbWLanInitialize(struct wbsoft_priv * adapter)
 	//
 	// Setting default value for Linux
 	//
-	adapter->sLocalPara.region_INF = REGION_AUTO;
-	adapter->sLocalPara.TxRateMode = RATE_AUTO;
-	psLOCAL->bMacOperationMode = MODE_802_11_BG;	// B/G mode
-	adapter->Mds.TxRTSThreshold = DEFAULT_RTSThreshold;
-	adapter->Mds.TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD;
-	hal_set_phy_type( &adapter->sHwData, RF_WB_242_1 );
-	adapter->sLocalPara.MTUsize = MAX_ETHERNET_PACKET_SIZE;
-	psLOCAL->bPreambleMode = AUTO_MODE;
-	adapter->sLocalPara.RadioOffStatus.boSwRadioOff = false;
-	pHwData = &adapter->sHwData;
+	priv->sLocalPara.region_INF = REGION_AUTO;
+	priv->sLocalPara.TxRateMode = RATE_AUTO;
+	priv->sLocalPara.bMacOperationMode = MODE_802_11_BG;	// B/G mode
+	priv->Mds.TxRTSThreshold = DEFAULT_RTSThreshold;
+	priv->Mds.TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD;
+	hal_set_phy_type( &priv->sHwData, RF_WB_242_1 );
+	priv->sLocalPara.MTUsize = MAX_ETHERNET_PACKET_SIZE;
+	priv->sLocalPara.bPreambleMode = AUTO_MODE;
+	priv->sLocalPara.RadioOffStatus.boSwRadioOff = false;
+	pHwData = &priv->sHwData;
 	hal_set_phy_type( pHwData, RF_DECIDE_BY_INF );
 
 	//
 	// Initial each module and variable
 	//
-	if (!WBLINUX_Initial(adapter)) {
+	if (!WBLINUX_Initial(priv)) {
 #ifdef _PE_USB_INI_DUMP_
 		WBDEBUG(("[w35und]WBNDIS initialization failed\n"));
 #endif
@@ -120,33 +121,33 @@ WbWLanInitialize(struct wbsoft_priv * adapter)
 	}
 
 	// Initial Software variable
-	adapter->sLocalPara.ShutDowned = false;
+	priv->sLocalPara.ShutDowned = false;
 
 	//added by ws for wep key error detection
-	adapter->sLocalPara.bWepKeyError= false;
-	adapter->sLocalPara.bToSelfPacketReceived = false;
-	adapter->sLocalPara.WepKeyDetectTimerCount= 2 * 100; /// 2 seconds
+	priv->sLocalPara.bWepKeyError= false;
+	priv->sLocalPara.bToSelfPacketReceived = false;
+	priv->sLocalPara.WepKeyDetectTimerCount= 2 * 100; /// 2 seconds
 
 	// Initial USB hal
 	InitStep = 1;
-	pHwData = &adapter->sHwData;
-	if (!hal_init_hardware(pHwData, adapter))
+	pHwData = &priv->sHwData;
+	if (!hal_init_hardware(hw))
 		goto error;
 
 	EEPROM_region = hal_get_region_from_EEPROM( pHwData );
 	if (EEPROM_region != REGION_AUTO)
-		psLOCAL->region = EEPROM_region;
+		priv->sLocalPara.region = EEPROM_region;
 	else {
-		if (psLOCAL->region_INF != REGION_AUTO)
-			psLOCAL->region = psLOCAL->region_INF;
+		if (priv->sLocalPara.region_INF != REGION_AUTO)
+			priv->sLocalPara.region = priv->sLocalPara.region_INF;
 		else
-			psLOCAL->region = REGION_USA;	//default setting
+			priv->sLocalPara.region = REGION_USA;	//default setting
 	}
 
 	// Get Software setting flag from hal
-	adapter->sLocalPara.boAntennaDiversity = false;
+	priv->sLocalPara.boAntennaDiversity = false;
 	if (hal_software_set(pHwData) & 0x00000001)
-		adapter->sLocalPara.boAntennaDiversity = true;
+		priv->sLocalPara.boAntennaDiversity = true;
 
 	//
 	// For TS module
@@ -155,7 +156,7 @@ WbWLanInitialize(struct wbsoft_priv * adapter)
 
 	// For MDS module
 	InitStep = 3;
-	Mds_initial(adapter);
+	Mds_initial(priv);
 
 	//=======================================
 	// Initialize the SME, SCAN, MLME, ROAM
@@ -165,18 +166,18 @@ WbWLanInitialize(struct wbsoft_priv * adapter)
 	InitStep = 6;
 
 	// If no user-defined address in the registry, use the addresss "burned" on the NIC instead.
-	pMacAddr = adapter->sLocalPara.ThisMacAddress;
-	pMacAddr2 = adapter->sLocalPara.PermanentAddress;
-	hal_get_permanent_address( pHwData, adapter->sLocalPara.PermanentAddress );// Reading ethernet address from EEPROM
+	pMacAddr = priv->sLocalPara.ThisMacAddress;
+	pMacAddr2 = priv->sLocalPara.PermanentAddress;
+	hal_get_permanent_address( pHwData, priv->sLocalPara.PermanentAddress );// Reading ethernet address from EEPROM
 	if (memcmp(pMacAddr, "\x00\x00\x00\x00\x00\x00", MAC_ADDR_LENGTH) == 0)
 		memcpy(pMacAddr, pMacAddr2, MAC_ADDR_LENGTH);
 	else {
 		// Set the user define MAC address
-		hal_set_ethernet_address(pHwData, adapter->sLocalPara.ThisMacAddress);
+		hal_set_ethernet_address(pHwData, priv->sLocalPara.ThisMacAddress);
 	}
 
 	//get current antenna
-	psLOCAL->bAntennaNo = hal_get_antenna_number(pHwData);
+	priv->sLocalPara.bAntennaNo = hal_get_antenna_number(pHwData);
 #ifdef _PE_STATE_DUMP_
 	WBDEBUG(("Driver init, antenna no = %d\n", psLOCAL->bAntennaNo));
 #endif
@@ -186,25 +187,25 @@ WbWLanInitialize(struct wbsoft_priv * adapter)
 	while (!hal_idle(pHwData))
 		msleep(10);
 
-	MTO_Init(adapter);
+	MTO_Init(priv);
 
 	HwRadioOff = hal_get_hw_radio_off( pHwData );
-	psLOCAL->RadioOffStatus.boHwRadioOff = !!HwRadioOff;
+	priv->sLocalPara.RadioOffStatus.boHwRadioOff = !!HwRadioOff;
 
-	hal_set_radio_mode( pHwData, (unsigned char)(psLOCAL->RadioOffStatus.boSwRadioOff || psLOCAL->RadioOffStatus.boHwRadioOff) );
+	hal_set_radio_mode( pHwData, (unsigned char)(priv->sLocalPara.RadioOffStatus.boSwRadioOff || priv->sLocalPara.RadioOffStatus.boHwRadioOff) );
 
 	hal_driver_init_OK(pHwData) = 1; // Notify hal that the driver is ready now.
 	//set a tx power for reference.....
-//	sme_set_tx_power_level(adapter, 12);	FIXME?
+//	sme_set_tx_power_level(priv, 12);	FIXME?
 	return true;
 
 error:
 	switch (InitStep) {
 	case 5:
 	case 4:
-	case 3: Mds_Destroy( adapter );
+	case 3: Mds_Destroy( priv );
 	case 2:
-	case 1: WBLINUX_Destroy( adapter );
+	case 1: WBLINUX_Destroy( priv );
 		hal_halt( pHwData, NULL );
 	case 0: break;
 	}
diff --git a/drivers/staging/winbond/wblinux_f.h b/drivers/staging/winbond/wblinux_f.h
index 4b786fc..15e6a65 100644
--- a/drivers/staging/winbond/wblinux_f.h
+++ b/drivers/staging/winbond/wblinux_f.h
@@ -17,6 +17,7 @@ void wb35_set_multicast( struct net_device *netdev );
 struct net_device_stats * wb35_netdev_stats( struct net_device *netdev );
 void WBLINUX_stop(  struct wbsoft_priv *adapter );
 void WbWlanHalt(  struct wbsoft_priv *adapter );
-unsigned char WbWLanInitialize(struct wbsoft_priv *adapter);
+unsigned char WbWLanInitialize(struct ieee80211_hw *hw);
+
 
 #endif
diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c
index a6bc78e..40bb77c 100644
--- a/drivers/staging/winbond/wbusb.c
+++ b/drivers/staging/winbond/wbusb.c
@@ -45,7 +45,6 @@ static struct ieee80211_supported_band wbsoft_band_2GHz = {
 };
 
 int wbsoft_enabled;
-struct ieee80211_hw *my_dev;
 
 static int wbsoft_add_interface(struct ieee80211_hw *dev,
 				 struct ieee80211_if_init_conf *conf)
@@ -225,7 +224,6 @@ static int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id
 		goto error;
 
 	priv = dev->priv;
-	my_dev = dev;
 
 	pWbUsb = &priv->sHwData.WbUsb;
 	pWbUsb->udev = udev;
@@ -238,7 +236,7 @@ static int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id
 		pWbUsb->IsUsb20 = 1;
 	}
 
-	if (!WbWLanInitialize(priv)) {
+	if (!WbWLanInitialize(dev)) {
 		err = -EINVAL;
 		goto error_free_hw;
 	}
@@ -274,7 +272,7 @@ error:
 	return err;
 }
 
-void packet_came(char *pRxBufferAddress, int PacketSize)
+void packet_came(struct ieee80211_hw *hw, char *pRxBufferAddress, int PacketSize)
 {
 	struct sk_buff *skb;
 	struct ieee80211_rx_status rx_status = {0};
@@ -299,7 +297,7 @@ void packet_came(char *pRxBufferAddress, int PacketSize)
 	rx_status.phymode = MODE_IEEE80211B;
 */
 
-	ieee80211_rx_irqsafe(my_dev, skb, &rx_status);
+	ieee80211_rx_irqsafe(hw, skb, &rx_status);
 }
 
 static void wb35_disconnect(struct usb_interface *intf)
-- 
1.5.3.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ