[PATCH 05/17] rtl8192e: Store priv data like mac80211

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Mike McCormack <mikem@xxxxxxxxxx>
---
 drivers/staging/rtl8192e/ieee80211/ieee80211.h     |    4 +-
 .../staging/rtl8192e/ieee80211/ieee80211_module.c  |   15 +++++-
 drivers/staging/rtl8192e/r8192E_core.c             |   45 ++++++++++----------
 drivers/staging/rtl8192e/r819xE_phy.c              |   13 +++---
 4 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211.h b/drivers/staging/rtl8192e/ieee80211/ieee80211.h
index 0b26fbd..79007ed 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211.h
@@ -2200,9 +2200,7 @@ struct ieee80211_device {
 	bool (*GetHalfNmodeSupportByAPsHandler)(struct ieee80211_device *ieee80211);
 	void (*InitialGainHandler)(struct ieee80211_device *ieee80211, u8 Operation);
 
-	/* This must be the last item so that it points to the data
-	 * allocated beyond this structure by alloc_ieee80211 */
-	u8 priv[0];
+	void *priv;
 };
 
 #define	RT_RF_OFF_LEVL_ASPM			BIT0	// PCI ASPM
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
index a3acd6e..e182e27 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
@@ -103,15 +103,19 @@ struct net_device *alloc_ieee80211(int sizeof_priv, const struct ieee80211_ops *
 
 	IEEE80211_DEBUG_INFO("Initializing...\n");
 
-	dev = alloc_etherdev(sizeof(struct ieee80211_device) + sizeof_priv);
+	dev = alloc_etherdev(sizeof *ieee);
 	if (!dev) {
 		IEEE80211_ERROR("Unable to network device.\n");
 		goto failed;
 	}
 
 	ieee = netdev_priv(dev);
+	memset(ieee, 0, sizeof *ieee);
+
+	ieee->priv = kzalloc(sizeof_priv, GFP_KERNEL);
+	if (!ieee->priv)
+		goto failed;
 
-	memset(ieee, 0, sizeof(struct ieee80211_device) + sizeof_priv);
 	ieee->ops = ops;
 	ieee->dev = dev;
 
@@ -185,8 +189,11 @@ struct net_device *alloc_ieee80211(int sizeof_priv, const struct ieee80211_ops *
 	return dev;
 
 failed:
-	if (dev)
+	if (dev) {
+		if (ieee->priv)
+			kfree(ieee->priv);
 		free_netdev(dev);
+	}
 	return NULL;
 }
 
@@ -213,6 +220,8 @@ void free_ieee80211(struct net_device *dev)
 	}
 
 	ieee80211_networks_free(ieee);
+	if (ieee->priv)
+		kfree(ieee->priv);
 	free_netdev(dev);
 }
 
diff --git a/drivers/staging/rtl8192e/r8192E_core.c b/drivers/staging/rtl8192e/r8192E_core.c
index 195373c..728c7e3 100644
--- a/drivers/staging/rtl8192e/r8192E_core.c
+++ b/drivers/staging/rtl8192e/r8192E_core.c
@@ -273,7 +273,7 @@ u8 rtl8192e_ap_sec_type(struct ieee80211_device *ieee)
 
 void rtl8192e_SetHwReg(struct ieee80211_device *ieee80211, u8 variable, u8 *val)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
+	struct r8192_priv *priv = ieee80211->priv;
 
 	switch(variable)
 	{
@@ -585,7 +585,7 @@ static void rtl8192_proc_init_one(struct r8192_priv *priv)
 
 static short check_nic_enough_desc(struct ieee80211_device *ieee, int prio)
 {
-    struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+    struct r8192_priv *priv = ieee->priv;
     struct rtl8192_tx_ring *ring = &priv->tx_ring[prio];
 
     /* for now we reserve two free descriptor as a safety boundary
@@ -661,7 +661,7 @@ static void rtl8192_set_chan(struct ieee80211_device *ieee80211, short ch)
 
 static int rtl8192_config(struct ieee80211_device *ieee, u32 changed)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+	struct r8192_priv *priv = ieee->priv;
 
 	priv->chan = ieee->current_network.channel;
 
@@ -759,7 +759,7 @@ void PHY_SetRtl8192eRfOff(struct r8192_priv *priv)
 
 static void rtl8192_stop(struct ieee80211_device *ieee)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+	struct r8192_priv *priv = ieee->priv;
 	int i;
 	u8 OpMode;
 	u32 ulRegRead;
@@ -825,7 +825,7 @@ static void rtl8192_data_hard_resume(struct ieee80211_device *ieee80211)
 static void rtl8192_hard_data_xmit(struct sk_buff *skb,
 				   struct ieee80211_device *ieee80211, int rate)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
+	struct r8192_priv *priv = ieee80211->priv;
 	int ret;
 	cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
 	u8 queue_index = tcb_desc->queue_index;
@@ -859,7 +859,7 @@ static void rtl8192_hard_data_xmit(struct sk_buff *skb,
  */
 static int rtl8192_hard_start_xmit(struct ieee80211_device *ieee80211, struct sk_buff *skb)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
+	struct r8192_priv *priv = ieee80211->priv;
 	int ret;
         cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
         u8 queue_index = tcb_desc->queue_index;
@@ -1472,7 +1472,7 @@ static void rtl8192_pci_resetdescring(struct r8192_priv *priv)
 
 static void rtl8192_link_change(struct ieee80211_device *ieee)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+	struct r8192_priv *priv = ieee->priv;
 
 	if (ieee->state == IEEE80211_LINKED)
 	{
@@ -1607,7 +1607,7 @@ static int rtl8192_handle_beacon(struct ieee80211_device *ieee,
                               struct ieee80211_beacon * beacon,
                               struct ieee80211_network * network)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+	struct r8192_priv *priv = ieee->priv;
 
 	rtl8192_qos_handle_probe_response(priv,1,network);
 
@@ -1673,7 +1673,7 @@ static int rtl8192_handle_assoc_response(struct ieee80211_device *ieee,
                                      struct ieee80211_assoc_response_frame *resp,
                                      struct ieee80211_network *network)
 {
-        struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+        struct r8192_priv *priv = ieee->priv;
         rtl8192_qos_association_resp(priv, network);
         return 0;
 }
@@ -1750,7 +1750,7 @@ static u8 rtl8192_getSupportedWireleeMode(void)
 
 static void rtl8192_SetWirelessMode(struct ieee80211_device *ieee, u8 wireless_mode)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+	struct r8192_priv *priv = ieee->priv;
 	u8 bSupportMode = rtl8192_getSupportedWireleeMode();
 
 	if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode&bSupportMode)==0))
@@ -1798,7 +1798,7 @@ static bool GetHalfNmodeSupportByAPs819xPci(struct ieee80211_device* ieee)
 static short rtl8192_is_tx_queue_empty(struct ieee80211_device *ieee)
 {
 	int i=0;
-	struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+	struct r8192_priv *priv = ieee->priv;
 
 	for (i=0; i<=MGNT_QUEUE; i++)
 	{
@@ -1819,7 +1819,7 @@ static void rtl8192_hw_sleep_down(struct r8192_priv *priv)
 
 static void rtl8192_hw_wakeup(struct ieee80211_device *ieee)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+	struct r8192_priv *priv = ieee->priv;
 	MgntActSet_RF_State(priv, eRfOn, RF_CHANGE_BY_PS);
 }
 
@@ -1835,7 +1835,7 @@ static void rtl8192_hw_wakeup_wq (struct work_struct *work)
 #define MAX_SLEEP_TIME 10000
 static void rtl8192_hw_to_sleep(struct ieee80211_device *ieee, u32 th, u32 tl)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+	struct r8192_priv *priv = ieee->priv;
 	u32 tmp;
 	u32 rb = jiffies;
 
@@ -2511,7 +2511,7 @@ static void rtl8192_hwconfig(struct r8192_priv *priv)
 
 static int rtl8192_start(struct ieee80211_device *ieee)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+	struct r8192_priv *priv = ieee->priv;
 	struct net_device *dev = priv->ieee80211->dev;
 	u32 ulRegRead;
 	RT_STATUS rtStatus;
@@ -2852,7 +2852,7 @@ static void rtl8192_prepare_beacon(unsigned long arg)
  */
 static void rtl8192_start_beacon(struct ieee80211_device *ieee80211)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
+	struct r8192_priv *priv = ieee80211->priv;
 	struct ieee80211_network *net = &priv->ieee80211->current_network;
 	u16 BcnTimeCfg = 0;
         u16 BcnCW = 6;
@@ -3069,7 +3069,7 @@ bool MgntActSet_802_11_PowerSaveMode(struct r8192_priv *priv, u8 rtPsMode)
 /* Enter the leisure power save mode. */
 void LeisurePSEnter(struct ieee80211_device *ieee80211)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
+	struct r8192_priv *priv = ieee80211->priv;
 	PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl;
 
 	if(!((priv->ieee80211->iw_mode == IW_MODE_INFRA) &&
@@ -3099,7 +3099,7 @@ void LeisurePSEnter(struct ieee80211_device *ieee80211)
 /* Leave leisure power save mode. */
 void LeisurePSLeave(struct ieee80211_device *ieee80211)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
+	struct r8192_priv *priv = ieee80211->priv;
 	PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl;
 
 	if (pPSC->bLeisurePs)
@@ -3169,9 +3169,8 @@ void IPSLeave(struct r8192_priv *priv)
 void IPSLeave_wq(struct work_struct *work)
 {
 	struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, ips_leave_wq);
-	struct net_device *dev = ieee->dev;
 
-	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+	struct r8192_priv *priv = ieee->priv;
 	down(&priv->ieee80211->ips_sem);
 	IPSLeave(priv);
 	up(&priv->ieee80211->ips_sem);
@@ -3179,7 +3178,7 @@ void IPSLeave_wq(struct work_struct *work)
 
 void ieee80211_ips_leave_wq(struct ieee80211_device *ieee80211)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
+	struct r8192_priv *priv = ieee80211->priv;
 	RT_RF_POWER_STATE	rtState;
 	rtState = priv->eRFPowerState;
 
@@ -3200,7 +3199,7 @@ void ieee80211_ips_leave_wq(struct ieee80211_device *ieee80211)
 //added by amy 090331 end
 void ieee80211_ips_leave(struct ieee80211_device *ieee80211)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
+	struct r8192_priv *priv = ieee80211->priv;
 	down(&ieee80211->ips_sem);
 	IPSLeave(priv);
 	up(&ieee80211->ips_sem);
@@ -3581,7 +3580,7 @@ static void r8192e_set_hw_key(struct r8192_priv *priv, struct ieee_param *ipw)
 /* based on ipw2200 driver */
 static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+	struct r8192_priv *priv = ieee80211_priv(dev);
 	struct iwreq *wrq = (struct iwreq *)rq;
 	int ret=-1;
 	struct iw_point *p = &wrq->u.data;
@@ -4559,7 +4558,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev,
 	//pci_set_wmi(pdev);
 	pci_set_dma_mask(pdev, 0xffffff00ULL);
 	pci_set_consistent_dma_mask(pdev,0xffffff00ULL);
-	dev = alloc_ieee80211(sizeof(struct r8192_priv), &r8192e_ops);
+	dev = alloc_ieee80211(sizeof *priv, &r8192e_ops);
 	if (!dev) {
 		ret = -ENOMEM;
 		goto fail_free;
diff --git a/drivers/staging/rtl8192e/r819xE_phy.c b/drivers/staging/rtl8192e/r819xE_phy.c
index dfa4e11..b1d9355 100644
--- a/drivers/staging/rtl8192e/r819xE_phy.c
+++ b/drivers/staging/rtl8192e/r819xE_phy.c
@@ -1850,9 +1850,9 @@ void rtl8192_SwChnl_WorkItem(struct r8192_priv *priv)
  *  return:  return code show if workitem is scheduled(1:pass, 0:fail)
  *    Note:  Delay may be required for RF configuration
  * ***************************************************************************/
-u8 rtl8192_phy_SwChnl(struct ieee80211_device *ieee80211, u8 channel)
+u8 rtl8192_phy_SwChnl(struct ieee80211_device *ieee, u8 channel)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
+	struct r8192_priv *priv = ieee->priv;
 
 	RT_TRACE(COMP_PHY, "=====>%s()\n", __FUNCTION__);
         if(!priv->up)
@@ -1864,7 +1864,7 @@ u8 rtl8192_phy_SwChnl(struct ieee80211_device *ieee80211, u8 channel)
 //		return;
 
 	//--------------------------------------------
-	switch(priv->ieee80211->mode)
+	switch (ieee->mode)
 	{
 	case WIRELESS_MODE_A:
 	case WIRELESS_MODE_N_5G:
@@ -2127,13 +2127,12 @@ void rtl8192_SetBWModeWorkItem(struct r8192_priv *priv)
  * ***************************************************************************/
 void rtl8192_SetBWMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset)
 {
-	struct r8192_priv *priv = ieee80211_priv(ieee->dev);
-
+	struct r8192_priv *priv = ieee->priv;
 
 	if(priv->SetBWModeInProgress)
 		return;
 
-	 atomic_inc(&(priv->ieee80211->atm_swbw));
+	atomic_inc(&ieee->atm_swbw);
 	priv->SetBWModeInProgress= true;
 
 	priv->CurrentChannelBW = Bandwidth;
@@ -2156,7 +2155,7 @@ void InitialGain819xPci(struct ieee80211_device *ieee, u8 Operation)
 {
 #define SCAN_RX_INITIAL_GAIN	0x17
 #define POWER_DETECTION_TH	0x08
-	struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+	struct r8192_priv *priv = ieee->priv;
 	u32					BitMask;
 	u8					initial_gain;
 
-- 
1.7.0.4


_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux