aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Zary <linux@rainbow-software.org>2015-10-16 15:04:13 -0400
committerKalle Valo <kvalo@codeaurora.org>2015-10-28 14:54:35 -0400
commitf675f93a797a18fc1f82030d56d02286039d0fb3 (patch)
tree87fe5b6f98d61acbb63b799563006f3e16bb02db
parentb3bcb1b27203c24fbf181748cec6eec10419678d (diff)
airo: Track APList_rid in struct airo_info
Instead of dynamically allocating APList, make it a member of struct airo_info to always track state of APList_rid. This simplifies suspend/resume and allows removal of readAPListRid. Signed-off-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
-rw-r--r--drivers/net/wireless/airo.c57
1 files changed, 19 insertions, 38 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 8ae838d96a9e..4ef2f986888b 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -1231,7 +1231,7 @@ struct airo_info {
1231 dma_addr_t shared_dma; 1231 dma_addr_t shared_dma;
1232 pm_message_t power; 1232 pm_message_t power;
1233 SsidRid *SSID; 1233 SsidRid *SSID;
1234 APListRid *APList; 1234 APListRid APList;
1235#define PCI_SHARED_LEN 2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE 1235#define PCI_SHARED_LEN 2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE
1236 char proc_name[IFNAMSIZ]; 1236 char proc_name[IFNAMSIZ];
1237 1237
@@ -1848,11 +1848,6 @@ static int readStatusRid(struct airo_info *ai, StatusRid *statr, int lock)
1848 return PC4500_readrid(ai, RID_STATUS, statr, sizeof(*statr), lock); 1848 return PC4500_readrid(ai, RID_STATUS, statr, sizeof(*statr), lock);
1849} 1849}
1850 1850
1851static int readAPListRid(struct airo_info *ai, APListRid *aplr)
1852{
1853 return PC4500_readrid(ai, RID_APLIST, aplr, sizeof(*aplr), 1);
1854}
1855
1856static int writeAPListRid(struct airo_info *ai, APListRid *aplr, int lock) 1851static int writeAPListRid(struct airo_info *ai, APListRid *aplr, int lock)
1857{ 1852{
1858 return PC4500_writerid(ai, RID_APLIST, aplr, sizeof(*aplr), lock); 1853 return PC4500_writerid(ai, RID_APLIST, aplr, sizeof(*aplr), lock);
@@ -2413,7 +2408,6 @@ void stop_airo_card( struct net_device *dev, int freeres )
2413 2408
2414 kfree(ai->flash); 2409 kfree(ai->flash);
2415 kfree(ai->rssi); 2410 kfree(ai->rssi);
2416 kfree(ai->APList);
2417 kfree(ai->SSID); 2411 kfree(ai->SSID);
2418 if (freeres) { 2412 if (freeres) {
2419 /* PCMCIA frees this stuff, so only for PCI and ISA */ 2413 /* PCMCIA frees this stuff, so only for PCI and ISA */
@@ -2809,6 +2803,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2809 init_waitqueue_head (&ai->thr_wait); 2803 init_waitqueue_head (&ai->thr_wait);
2810 ai->tfm = NULL; 2804 ai->tfm = NULL;
2811 add_airo_dev(ai); 2805 add_airo_dev(ai);
2806 ai->APList.len = cpu_to_le16(sizeof(struct APListRid));
2812 2807
2813 if (airo_networks_allocate (ai)) 2808 if (airo_networks_allocate (ai))
2814 goto err_out_free; 2809 goto err_out_free;
@@ -3852,8 +3847,6 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
3852 tdsRssiRid rssi_rid; 3847 tdsRssiRid rssi_rid;
3853 CapabilityRid cap_rid; 3848 CapabilityRid cap_rid;
3854 3849
3855 kfree(ai->APList);
3856 ai->APList = NULL;
3857 kfree(ai->SSID); 3850 kfree(ai->SSID);
3858 ai->SSID = NULL; 3851 ai->SSID = NULL;
3859 // general configuration (read/modify/write) 3852 // general configuration (read/modify/write)
@@ -5130,31 +5123,31 @@ static void proc_APList_on_close( struct inode *inode, struct file *file ) {
5130 struct proc_data *data = file->private_data; 5123 struct proc_data *data = file->private_data;
5131 struct net_device *dev = PDE_DATA(inode); 5124 struct net_device *dev = PDE_DATA(inode);
5132 struct airo_info *ai = dev->ml_priv; 5125 struct airo_info *ai = dev->ml_priv;
5133 APListRid APList_rid; 5126 APListRid *APList_rid = &ai->APList;
5134 int i; 5127 int i;
5135 5128
5136 if ( !data->writelen ) return; 5129 if ( !data->writelen ) return;
5137 5130
5138 memset( &APList_rid, 0, sizeof(APList_rid) ); 5131 memset(APList_rid, 0, sizeof(*APList_rid));
5139 APList_rid.len = cpu_to_le16(sizeof(APList_rid)); 5132 APList_rid->len = cpu_to_le16(sizeof(*APList_rid));
5140 5133
5141 for( i = 0; i < 4 && data->writelen >= (i+1)*6*3; i++ ) { 5134 for( i = 0; i < 4 && data->writelen >= (i+1)*6*3; i++ ) {
5142 int j; 5135 int j;
5143 for( j = 0; j < 6*3 && data->wbuffer[j+i*6*3]; j++ ) { 5136 for( j = 0; j < 6*3 && data->wbuffer[j+i*6*3]; j++ ) {
5144 switch(j%3) { 5137 switch(j%3) {
5145 case 0: 5138 case 0:
5146 APList_rid.ap[i][j/3]= 5139 APList_rid->ap[i][j/3]=
5147 hex_to_bin(data->wbuffer[j+i*6*3])<<4; 5140 hex_to_bin(data->wbuffer[j+i*6*3])<<4;
5148 break; 5141 break;
5149 case 1: 5142 case 1:
5150 APList_rid.ap[i][j/3]|= 5143 APList_rid->ap[i][j/3]|=
5151 hex_to_bin(data->wbuffer[j+i*6*3]); 5144 hex_to_bin(data->wbuffer[j+i*6*3]);
5152 break; 5145 break;
5153 } 5146 }
5154 } 5147 }
5155 } 5148 }
5156 disable_MAC(ai, 1); 5149 disable_MAC(ai, 1);
5157 writeAPListRid(ai, &APList_rid, 1); 5150 writeAPListRid(ai, APList_rid, 1);
5158 enable_MAC(ai, 1); 5151 enable_MAC(ai, 1);
5159} 5152}
5160 5153
@@ -5408,7 +5401,7 @@ static int proc_APList_open( struct inode *inode, struct file *file ) {
5408 struct airo_info *ai = dev->ml_priv; 5401 struct airo_info *ai = dev->ml_priv;
5409 int i; 5402 int i;
5410 char *ptr; 5403 char *ptr;
5411 APListRid APList_rid; 5404 APListRid *APList_rid = &ai->APList;
5412 5405
5413 if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) 5406 if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
5414 return -ENOMEM; 5407 return -ENOMEM;
@@ -5426,13 +5419,12 @@ static int proc_APList_open( struct inode *inode, struct file *file ) {
5426 } 5419 }
5427 data->on_close = proc_APList_on_close; 5420 data->on_close = proc_APList_on_close;
5428 5421
5429 readAPListRid(ai, &APList_rid);
5430 ptr = data->rbuffer; 5422 ptr = data->rbuffer;
5431 for( i = 0; i < 4; i++ ) { 5423 for( i = 0; i < 4; i++ ) {
5432// We end when we find a zero MAC 5424// We end when we find a zero MAC
5433 if ( !*(int*)APList_rid.ap[i] && 5425 if ( !*(int*)APList_rid->ap[i] &&
5434 !*(int*)&APList_rid.ap[i][2]) break; 5426 !*(int*)&APList_rid->ap[i][2]) break;
5435 ptr += sprintf(ptr, "%pM\n", APList_rid.ap[i]); 5427 ptr += sprintf(ptr, "%pM\n", APList_rid->ap[i]);
5436 } 5428 }
5437 if (i==0) ptr += sprintf(ptr, "Not using specific APs\n"); 5429 if (i==0) ptr += sprintf(ptr, "Not using specific APs\n");
5438 5430
@@ -5596,15 +5588,10 @@ static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state)
5596 Cmd cmd; 5588 Cmd cmd;
5597 Resp rsp; 5589 Resp rsp;
5598 5590
5599 if (!ai->APList)
5600 ai->APList = kmalloc(sizeof(APListRid), GFP_KERNEL);
5601 if (!ai->APList)
5602 return -ENOMEM;
5603 if (!ai->SSID) 5591 if (!ai->SSID)
5604 ai->SSID = kmalloc(sizeof(SsidRid), GFP_KERNEL); 5592 ai->SSID = kmalloc(sizeof(SsidRid), GFP_KERNEL);
5605 if (!ai->SSID) 5593 if (!ai->SSID)
5606 return -ENOMEM; 5594 return -ENOMEM;
5607 readAPListRid(ai, ai->APList);
5608 readSsidRid(ai, ai->SSID); 5595 readSsidRid(ai, ai->SSID);
5609 memset(&cmd, 0, sizeof(cmd)); 5596 memset(&cmd, 0, sizeof(cmd));
5610 /* the lock will be released at the end of the resume callback */ 5597 /* the lock will be released at the end of the resume callback */
@@ -5652,11 +5639,7 @@ static int airo_pci_resume(struct pci_dev *pdev)
5652 kfree(ai->SSID); 5639 kfree(ai->SSID);
5653 ai->SSID = NULL; 5640 ai->SSID = NULL;
5654 } 5641 }
5655 if (ai->APList) { 5642 writeAPListRid(ai, &ai->APList, 0);
5656 writeAPListRid(ai, ai->APList, 0);
5657 kfree(ai->APList);
5658 ai->APList = NULL;
5659 }
5660 writeConfigRid(ai, 0); 5643 writeConfigRid(ai, 0);
5661 enable_MAC(ai, 0); 5644 enable_MAC(ai, 0);
5662 ai->power = PMSG_ON; 5645 ai->power = PMSG_ON;
@@ -5954,7 +5937,7 @@ static int airo_set_wap(struct net_device *dev,
5954 struct airo_info *local = dev->ml_priv; 5937 struct airo_info *local = dev->ml_priv;
5955 Cmd cmd; 5938 Cmd cmd;
5956 Resp rsp; 5939 Resp rsp;
5957 APListRid APList_rid; 5940 APListRid *APList_rid = &local->APList;
5958 5941
5959 if (awrq->sa_family != ARPHRD_ETHER) 5942 if (awrq->sa_family != ARPHRD_ETHER)
5960 return -EINVAL; 5943 return -EINVAL;
@@ -5967,11 +5950,11 @@ static int airo_set_wap(struct net_device *dev,
5967 issuecommand(local, &cmd, &rsp); 5950 issuecommand(local, &cmd, &rsp);
5968 up(&local->sem); 5951 up(&local->sem);
5969 } else { 5952 } else {
5970 memset(&APList_rid, 0, sizeof(APList_rid)); 5953 memset(APList_rid, 0, sizeof(*APList_rid));
5971 APList_rid.len = cpu_to_le16(sizeof(APList_rid)); 5954 APList_rid->len = cpu_to_le16(sizeof(*APList_rid));
5972 memcpy(APList_rid.ap[0], awrq->sa_data, ETH_ALEN); 5955 memcpy(APList_rid->ap[0], awrq->sa_data, ETH_ALEN);
5973 disable_MAC(local, 1); 5956 disable_MAC(local, 1);
5974 writeAPListRid(local, &APList_rid, 1); 5957 writeAPListRid(local, APList_rid, 1);
5975 enable_MAC(local, 1); 5958 enable_MAC(local, 1);
5976 } 5959 }
5977 return 0; 5960 return 0;
@@ -7505,10 +7488,8 @@ static int airo_config_commit(struct net_device *dev,
7505 * parameters. It's now time to commit them in the card */ 7488 * parameters. It's now time to commit them in the card */
7506 disable_MAC(local, 1); 7489 disable_MAC(local, 1);
7507 if (test_bit (FLAG_RESET, &local->flags)) { 7490 if (test_bit (FLAG_RESET, &local->flags)) {
7508 APListRid APList_rid;
7509 SsidRid SSID_rid; 7491 SsidRid SSID_rid;
7510 7492
7511 readAPListRid(local, &APList_rid);
7512 readSsidRid(local, &SSID_rid); 7493 readSsidRid(local, &SSID_rid);
7513 if (test_bit(FLAG_MPI,&local->flags)) 7494 if (test_bit(FLAG_MPI,&local->flags))
7514 setup_card(local, dev->dev_addr, 1 ); 7495 setup_card(local, dev->dev_addr, 1 );
@@ -7516,7 +7497,7 @@ static int airo_config_commit(struct net_device *dev,
7516 reset_airo_card(dev); 7497 reset_airo_card(dev);
7517 disable_MAC(local, 1); 7498 disable_MAC(local, 1);
7518 writeSsidRid(local, &SSID_rid, 1); 7499 writeSsidRid(local, &SSID_rid, 1);
7519 writeAPListRid(local, &APList_rid, 1); 7500 writeAPListRid(local, &local->APList, 1);
7520 } 7501 }
7521 if (down_interruptible(&local->sem)) 7502 if (down_interruptible(&local->sem))
7522 return -ERESTARTSYS; 7503 return -ERESTARTSYS;