Skip to contentSkip to conversation

staging: wilc1000: handle few full driver review comments

PATCH In review [email protected] 2 participants 6 messages Jan 17, 2020 – Jan 24, 2020 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: wilc1000: handle few full driver review comments

From: Ajay Singh <[email protected]>

The patch series contains changes to address the below code review comments -

1/ Avoid use of infinite loops.
2/ Use separate header file to keep firmware related 'struct'. 3/ Remove unused code.

Ajay Singh (4):
staging: wilc1000: remove use of infinite loop conditions
staging: wilc1000: move firmware API struct's to separate header file
staging: wilc1000: added 'wilc_' prefix for 'struct assoc_resp' name
staging: wilc1000: remove unused code prior to throughput enhancement
in SPI

 drivers/staging/wilc1000/fw.h       | 119 +++++++++++++++++++++++
 drivers/staging/wilc1000/hif.c      |  90 +----------------
 drivers/staging/wilc1000/hif.h      |  19 ----
 drivers/staging/wilc1000/netdev.c   |   7 +-
 drivers/staging/wilc1000/netdev.h   |   1 -
 drivers/staging/wilc1000/spi.c      | 143 +--------------------------
 drivers/staging/wilc1000/wlan.c     |  79 ++++++---------
 drivers/staging/wilc1000/wlan_cfg.c | 144 ++++++++++------------------
 drivers/staging/wilc1000/wlan_if.h  |   1 +
 9 files changed, 209 insertions(+), 394 deletions(-)
 create mode 100644 drivers/staging/wilc1000/fw.h
Signature · 1 line
2.24.0
#1 lore raw

PATCH 1/4 staging: wilc1000: remove use of infinite loop conditions

From: Ajay Singh <[email protected]>

Avoid the use of 'while (1)' infinite loop conditions. It's not recommended to have infinite loop in kernel code because a small bug can cause never ending loops so use terminator condition as suggested in full driver review [1].

[1]. https://lore.kernel.org/linux-wireless/[email protected]/

---
 drivers/staging/wilc1000/netdev.c   |   7 +-
 drivers/staging/wilc1000/wlan.c     |  79 ++++++---------
 drivers/staging/wilc1000/wlan_cfg.c | 144 ++++++++++------------------
 3 files changed, 84 insertions(+), 146 deletions(-)
drivers/staging/wilc1000/netdev.c +4 -3
index 3fd8e008f733..960dbc8d5173 100644
@@ -837,7 +837,7 @@ static const struct net_device_ops wilc_netdev_ops = {
 void wilc_netdev_cleanup(struct wilc *wilc)
 {
 	struct wilc_vif *vif;
-	int srcu_idx;
+	int srcu_idx, ifc_cnt = 0;
 
 	if (!wilc)
 		return;
@@ -858,7 +858,7 @@ void wilc_netdev_cleanup(struct wilc *wilc)
 	flush_workqueue(wilc->hif_workqueue);
 	destroy_workqueue(wilc->hif_workqueue);
 
-	do {
+	while (ifc_cnt < WILC_NUM_CONCURRENT_IFC) {
 		mutex_lock(&wilc->vif_mutex);
 		if (wilc->vif_num <= 0) {
 			mutex_unlock(&wilc->vif_mutex);
@@ -871,7 +871,8 @@ void wilc_netdev_cleanup(struct wilc *wilc)
 		wilc->vif_num--;
 		mutex_unlock(&wilc->vif_mutex);
 		synchronize_srcu(&wilc->srcu);
-	} while (1);
+		ifc_cnt++;
+	}
 
 	wilc_wlan_cfg_deinit(wilc);
 	wlan_deinit_locks(wilc);
drivers/staging/wilc1000/wlan.c +29 -50

126 lines not on this page · raw message

drivers/staging/wilc1000/wlan_cfg.c +51 -93

199 lines not on this page · raw message

Signature · 1 line
2.24.0
#2 lore raw

Re: [PATCH 1/4] staging: wilc1000: remove use of infinite loop conditions

Hey Ajay,

url:    https://github.com/0day-ci/linux/commits/Ajay-Kathat-microchip-com/staging-wilc1000-handle-few-full-driver-review-comments/20200118-064137
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 270f104ba26f0498aff85e5b002e2f4c2249c04b

If you fix the issue, kindly add following tag

smatch warnings:
drivers/staging/wilc1000/wlan.c:663 wilc_wlan_handle_txq() error: double unlocked 'wilc->hif_cs' (orig line 575)

# https://github.com/0day-ci/linux/commit/afb35a84bfc18d51ed5ffebd87d7f4cf07c3b44e
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout afb35a84bfc18d51ed5ffebd87d7f4cf07c3b44e
vim +663 drivers/staging/wilc1000/wlan.c

a41047962ac053 drivers/staging/wilc1000/wilc_wlan.c Chris Park         2016-02-04  528  	if (i == 0)
891256180aea96 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  529  		goto out;
ac087c82c4ec08 drivers/staging/wilc1000/wilc_wlan.c Leo Kim            2015-11-06  530  	vmm_table[i] = 0x0;
a41047962ac053 drivers/staging/wilc1000/wilc_wlan.c Chris Park         2016-02-04  531  
b997b84ffca6ab drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-11-12  532  	acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);

Acquire here.

c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  533  	counter = 0;
f782497c099102 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-16  534  	func = wilc->hif_func;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  535  	do {
f782497c099102 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-16  536  		ret = func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, &reg);
133b22d694c7a4 drivers/staging/wilc1000/wilc_wlan.c Chris Park         2016-02-04  537  		if (!ret)
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  538  			break;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  539  
4ee4b9da2b0142 drivers/staging/wilc1000/wilc_wlan.c Elizabeth Ferdman  2016-09-30  540  		if ((reg & 0x1) == 0)
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  541  			break;
4ee4b9da2b0142 drivers/staging/wilc1000/wilc_wlan.c Elizabeth Ferdman  2016-09-30  542  
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  543  		counter++;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  544  		if (counter > 200) {
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  545  			counter = 0;
891256180aea96 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  546  			ret = func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, 0);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  547  			break;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  548  		}
67e2a07ed8008b drivers/staging/wilc1000/wilc_wlan.c Glen Lee           2015-12-21  549  	} while (!wilc->quit);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  550  
39823a50ff371c drivers/staging/wilc1000/wilc_wlan.c Alison Schofield   2015-10-08  551  	if (!ret)
588bf3c1162604 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  552  		goto out_release_bus;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  553  
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  554  	timeout = 200;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  555  	do {
f782497c099102 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-16  556  		ret = func->hif_block_tx(wilc,
f782497c099102 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-16  557  					 WILC_VMM_TBL_RX_SHADOW_BASE,
f782497c099102 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-16  558  					 (u8 *)vmm_table,
f782497c099102 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-16  559  					 ((i + 1) * 4));
133b22d694c7a4 drivers/staging/wilc1000/wilc_wlan.c Chris Park         2016-02-04  560  		if (!ret)
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  561  			break;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  562  
f782497c099102 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-16  563  		ret = func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x2);
133b22d694c7a4 drivers/staging/wilc1000/wilc_wlan.c Chris Park         2016-02-04  564  		if (!ret)
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  565  			break;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  566  
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  567  		do {
891256180aea96 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  568  			ret = func->hif_read_reg(wilc, WILC_HOST_VMM_CTL, &reg);
133b22d694c7a4 drivers/staging/wilc1000/wilc_wlan.c Chris Park         2016-02-04  569  			if (!ret)
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  570  				break;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  571  			if ((reg >> 2) & 0x1) {
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  572  				entries = ((reg >> 3) & 0x3f);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  573  				break;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  574  			}
b997b84ffca6ab drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-11-12 @575  			release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
                                                                                                                ^^^^^^^^^^^

Bus is released here.

c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  576  		} while (--timeout);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  577  		if (timeout <= 0) {
891256180aea96 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  578  			ret = func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x0);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  579  			break;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  580  		}
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  581  
39823a50ff371c drivers/staging/wilc1000/wilc_wlan.c Alison Schofield   2015-10-08  582  		if (!ret)
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  583  			break;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  584  
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  585  		if (entries == 0) {
891256180aea96 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  586  			ret = func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, &reg);
133b22d694c7a4 drivers/staging/wilc1000/wilc_wlan.c Chris Park         2016-02-04  587  			if (!ret)
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  588  				break;
ffda203c0cf3b5 drivers/staging/wilc1000/wilc_wlan.c Anish Bhatt        2015-09-29  589  			reg &= ~BIT(0);
891256180aea96 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  590  			ret = func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  591  		}
afb35a84bfc18d drivers/staging/wilc1000/wlan.c      Ajay Singh         2020-01-17  592  	} while (0);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  593  
39823a50ff371c drivers/staging/wilc1000/wilc_wlan.c Alison Schofield   2015-10-08  594  	if (!ret)
588bf3c1162604 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  595  		goto out_release_bus;
                                                                                                        ^^^^^^^^^^^^^^^^^^^^
39823a50ff371c drivers/staging/wilc1000/wilc_wlan.c Alison Schofield   2015-10-08  596  
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  597  	if (entries == 0) {
68b4f745cf1963 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-11-12  598  		ret = -ENOBUFS;
588bf3c1162604 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  599  		goto out_release_bus;
                                                                                                        ^^^^^^^^^^^^^^^^^^^^

Released again in these gotos.

c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  600  	}
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  601  
b997b84ffca6ab drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-11-12  602  	release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  603  
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  604  	offset = 0;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  605  	i = 0;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  606  	do {
fbc2fe16afa3f3 drivers/staging/wilc1000/wilc_wlan.c Chaehyun Lim       2015-09-15  607  		u32 header, buffer_offset;
82059dcec99e50 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  608  		char *bssid;
82059dcec99e50 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  609  
82059dcec99e50 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  610  		tqe = wilc_wlan_txq_remove_from_head(dev);
82059dcec99e50 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  611  		if (!tqe)
82059dcec99e50 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  612  			break;
82059dcec99e50 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  613  
9bc061e8805487 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2019-06-26  614  		vif = tqe->vif;
82059dcec99e50 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  615  		if (vmm_table[i] == 0)
82059dcec99e50 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  616  			break;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  617  
02211edc9a1f71 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-08-01  618  		le32_to_cpus(&vmm_table[i]);
ac087c82c4ec08 drivers/staging/wilc1000/wilc_wlan.c Leo Kim            2015-11-06  619  		vmm_sz = (vmm_table[i] & 0x3ff);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  620  		vmm_sz *= 4;
ab12d8c773f86c drivers/staging/wilc1000/wilc_wlan.c Leo Kim            2015-11-06  621  		header = (tqe->type << 31) |
ab12d8c773f86c drivers/staging/wilc1000/wilc_wlan.c Leo Kim            2015-11-06  622  			 (tqe->buffer_size << 15) |
ab12d8c773f86c drivers/staging/wilc1000/wilc_wlan.c Leo Kim            2015-11-06  623  			 vmm_sz;
78174adaf59e85 drivers/staging/wilc1000/wilc_wlan.c Chandra S Gorentla 2015-08-08  624  		if (tqe->type == WILC_MGMT_PKT)
ffda203c0cf3b5 drivers/staging/wilc1000/wilc_wlan.c Anish Bhatt        2015-09-29  625  			header |= BIT(30);
78174adaf59e85 drivers/staging/wilc1000/wilc_wlan.c Chandra S Gorentla 2015-08-08  626  		else
ffda203c0cf3b5 drivers/staging/wilc1000/wilc_wlan.c Anish Bhatt        2015-09-29  627  			header &= ~BIT(30);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  628  
02211edc9a1f71 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-08-01  629  		cpu_to_le32s(&header);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  630  		memcpy(&txb[offset], &header, 4);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  631  		if (tqe->type == WILC_CFG_PKT) {
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  632  			buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET;
590c0a39650f02 drivers/staging/wilc1000/wilc_wlan.c Leo Kim            2015-11-06  633  		} else if (tqe->type == WILC_NET_PKT) {
9bc061e8805487 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2019-06-26  634  			bssid = tqe->vif->bssid;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  635  			buffer_offset = ETH_ETHERNET_HDR_OFFSET;
1bbf6a6d4091af drivers/staging/wilc1000/wilc_wlan.c Aditya Shankar     2017-11-03  636  			memcpy(&txb[offset + 8], bssid, 6);
590c0a39650f02 drivers/staging/wilc1000/wilc_wlan.c Leo Kim            2015-11-06  637  		} else {
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  638  			buffer_offset = HOST_HDR_OFFSET;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  639  		}
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  640  
ab12d8c773f86c drivers/staging/wilc1000/wilc_wlan.c Leo Kim            2015-11-06  641  		memcpy(&txb[offset + buffer_offset],
ab12d8c773f86c drivers/staging/wilc1000/wilc_wlan.c Leo Kim            2015-11-06  642  		       tqe->buffer, tqe->buffer_size);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  643  		offset += vmm_sz;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  644  		i++;
ac087c82c4ec08 drivers/staging/wilc1000/wilc_wlan.c Leo Kim            2015-11-06  645  		tqe->status = 1;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  646  		if (tqe->tx_complete_func)
82059dcec99e50 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  647  			tqe->tx_complete_func(tqe->priv, tqe->status);
f31e5584dc555f drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-09-04  648  		if (tqe->ack_idx != NOT_TCP_ACK &&
f31e5584dc555f drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-09-04  649  		    tqe->ack_idx < MAX_PENDING_ACKS)
f31e5584dc555f drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-09-04  650  			vif->ack_filter.pending_acks[tqe->ack_idx].txqe = NULL;
a18dd63047a86e drivers/staging/wilc1000/wilc_wlan.c Greg Kroah-Hartman 2015-09-03  651  		kfree(tqe);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  652  	} while (--entries);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  653  
b997b84ffca6ab drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-11-12  654  	acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  655  
f782497c099102 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-16  656  	ret = func->hif_clear_int_ext(wilc, ENABLE_TX_VMM);
133b22d694c7a4 drivers/staging/wilc1000/wilc_wlan.c Chris Park         2016-02-04  657  	if (!ret)
588bf3c1162604 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  658  		goto out_release_bus;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  659  
f782497c099102 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-16  660  	ret = func->hif_block_tx_ext(wilc, 0, txb, offset);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  661  
588bf3c1162604 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  662  out_release_bus:
b997b84ffca6ab drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-11-12 @663  	release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
891256180aea96 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  664  
891256180aea96 drivers/staging/wilc1000/wilc_wlan.c Ajay Singh         2018-02-26  665  out:
334bed089d3d74 drivers/staging/wilc1000/wilc_wlan.c Binoy Jayan        2016-06-15  666  	mutex_unlock(&wilc->txq_add_to_head_cs);
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  667  
67e2a07ed8008b drivers/staging/wilc1000/wilc_wlan.c Glen Lee           2015-12-21  668  	*txq_count = wilc->txq_entries;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  669  	return ret;
c5c77ba18ea66a drivers/staging/wilc1000/wilc_wlan.c Johnny Kim         2015-05-11  670  }

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation

#3 lore raw

PATCH 2/4 staging: wilc1000: move firmware API struct's to separate header file

In reply to [email protected]

From: Ajay Singh <[email protected]>

It's recommended to keep the 'struct' used for passing data to firmware in separate header file. So added 'fw.h' header file to keep struct's used to pass data to firmware.

---
 drivers/staging/wilc1000/fw.h      | 119 +++++++++++++++++++++++++++++
 drivers/staging/wilc1000/hif.c     |  88 ---------------------
 drivers/staging/wilc1000/hif.h     |  19 -----
 drivers/staging/wilc1000/netdev.h  |   1 -
 drivers/staging/wilc1000/wlan_if.h |   1 +
 5 files changed, 120 insertions(+), 108 deletions(-)
 create mode 100644 drivers/staging/wilc1000/fw.h
drivers/staging/wilc1000/fw.h new file +119 -0
new file mode 100644
index 000000000000..21d71a9e8b47
@@ -0,0 +1,119 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_FW_H
+#define WILC_FW_H
+
+#include <linux/ieee80211.h>
+
+#define WILC_MAX_NUM_STA			9
+#define WILC_MAX_RATES_SUPPORTED		12
+#define WILC_MAX_NUM_PMKIDS			16
+#define WILC_MAX_NUM_SCANNED_CH			14
+
+struct assoc_resp {
+	__le16 capab_info;
+	__le16 status_code;
+	__le16 aid;
+} __packed;
+
+struct wilc_pmkid {
+	u8 bssid[ETH_ALEN];
+	u8 pmkid[WLAN_PMKID_LEN];
+} __packed;
+
+struct wilc_pmkid_attr {
+	u8 numpmkid;
+	struct wilc_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS];
+} __packed;
+
+struct wilc_reg_frame {
+	u8 reg;
+	u8 reg_id;
+	__le16 frame_type;
+} __packed;
+
+struct wilc_drv_handler {
+	__le32 handler;
+	u8 mode;
+} __packed;
+
+struct wilc_wep_key {
+	u8 index;
+	u8 key_len;
+	u8 key[0];
+} __packed;
+
+struct wilc_sta_wpa_ptk {
+	u8 mac_addr[ETH_ALEN];
+	u8 key_len;
+	u8 key[0];
+} __packed;
+
+struct wilc_ap_wpa_ptk {
+	u8 mac_addr[ETH_ALEN];
+	u8 index;
+	u8 key_len;
+	u8 key[0];
+} __packed;
+
+struct wilc_gtk_key {
+	u8 mac_addr[ETH_ALEN];
+	u8 rsc[8];
+	u8 index;
+	u8 key_len;
+	u8 key[0];
+} __packed;
+
+struct wilc_op_mode {
+	__le32 mode;
+} __packed;
+
+struct wilc_noa_opp_enable {
+	u8 ct_window;
+	u8 cnt;
+	__le32 duration;
+	__le32 interval;
+	__le32 start_time;
+} __packed;
+
+struct wilc_noa_opp_disable {
+	u8 cnt;
+	__le32 duration;
+	__le32 interval;
+	__le32 start_time;
+} __packed;
+
+struct wilc_join_bss_param {
+	char ssid[IEEE80211_MAX_SSID_LEN];
+	u8 ssid_terminator;
+	u8 bss_type;
+	u8 ch;
+	__le16 cap_info;
+	u8 sa[ETH_ALEN];
+	u8 bssid[ETH_ALEN];
+	__le16 beacon_period;
+	u8 dtim_period;
+	u8 supp_rates[WILC_MAX_RATES_SUPPORTED + 1];
+	u8 wmm_cap;
+	u8 uapsd_cap;
+	u8 ht_capable;
+	u8 rsn_found;
+	u8 rsn_grp_policy;
+	u8 mode_802_11i;
+	u8 p_suites[3];
+	u8 akm_suites[3];
+	u8 rsn_cap[2];
+	u8 noa_enabled;
+	__le32 tsf_lo;
+	u8 idx;
+	u8 opp_enabled;
+	union {
+		struct wilc_noa_opp_disable opp_dis;
+		struct wilc_noa_opp_enable opp_en;
+	};
+} __packed;
+#endif
drivers/staging/wilc1000/hif.c +0 -88

106 lines not on this page · raw message

drivers/staging/wilc1000/hif.h +0 -19
index 22ee6fffd599..db9179171f05 100644
@@ -17,14 +17,11 @@ enum {
 	WILC_CLIENT_MODE = 0x4
 };
 
-#define WILC_MAX_NUM_STA			9
-#define WILC_MAX_NUM_SCANNED_CH			14
 #define WILC_MAX_NUM_PROBED_SSID		10
 
 #define WILC_TX_MIC_KEY_LEN			8
 #define WILC_RX_MIC_KEY_LEN			8
 
-#define WILC_MAX_NUM_PMKIDS			16
 #define WILC_ADD_STA_LENGTH			40
 #define WILC_NUM_CONCURRENT_IFC			2
 
@@ -35,12 +32,6 @@ enum {
 
 #define WILC_MAX_ASSOC_RESP_FRAME_SIZE   256
 
-struct assoc_resp {
-	__le16 capab_info;
-	__le16 status_code;
-	__le16 aid;
-} __packed;
-
 struct rf_info {
 	u8 link_speed;
 	s8 rssi;
@@ -59,16 +50,6 @@ enum host_if_state {
 	HOST_IF_FORCE_32BIT		= 0xFFFFFFFF
 };
 
-struct wilc_pmkid {
-	u8 bssid[ETH_ALEN];
-	u8 pmkid[WLAN_PMKID_LEN];
-} __packed;
-
-struct wilc_pmkid_attr {
-	u8 numpmkid;
-	struct wilc_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS];
-} __packed;
-
 struct cfg_param_attr {
 	u32 flag;
 	u16 short_retry_limit;
drivers/staging/wilc1000/netdev.h +0 -1
index cd8f0d72caaa..d5f7a6037fbc 100644
@@ -21,7 +21,6 @@
 #define FLOW_CONTROL_LOWER_THRESHOLD		128
 #define FLOW_CONTROL_UPPER_THRESHOLD		256
 
-#define WILC_MAX_NUM_PMKIDS			16
 #define PMKID_FOUND				1
 #define NUM_STA_ASSOCIATED			8
 
drivers/staging/wilc1000/wlan_if.h +1 -0
index 7c7ee66c35f5..f85fd575136d 100644
@@ -8,6 +8,7 @@
 #define WILC_WLAN_IF_H
 
 #include <linux/netdevice.h>
+#include "fw.h"
 
 /********************************************
  *
Signature · 1 line
2.24.0
#4 lore raw

PATCH 3/4 staging: wilc1000: added 'wilc_' prefix for 'struct assoc_resp' name

In reply to [email protected]

From: Ajay Singh <[email protected]>

Use 'wilc_' prefix for 'assoc_resp' struct to have proper naming convention.

---
 drivers/staging/wilc1000/fw.h  | 2 +-
 drivers/staging/wilc1000/hif.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/wilc1000/fw.h +1 -1
index 21d71a9e8b47..a76e1dea4345 100644
@@ -14,7 +14,7 @@
 #define WILC_MAX_NUM_PMKIDS			16
 #define WILC_MAX_NUM_SCANNED_CH			14
 
-struct assoc_resp {
+struct wilc_assoc_resp {
 	__le16 capab_info;
 	__le16 status_code;
 	__le16 aid;
drivers/staging/wilc1000/hif.c +1 -1
index 1ee3d7274bd6..658790bd465b 100644
@@ -552,7 +552,7 @@ static s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len,
 {
 	u8 *ies;
 	u16 ies_len;
-	struct assoc_resp *res = (struct assoc_resp *)buffer;
+	struct wilc_assoc_resp *res = (struct wilc_assoc_resp *)buffer;
 
 	ret_conn_info->status = le16_to_cpu(res->status_code);
 	if (ret_conn_info->status == WLAN_STATUS_SUCCESS) {
Signature · 1 line
2.24.0
#5 lore raw

PATCH 4/4 staging: wilc1000: remove unused code prior to throughput enhancement in SPI

In reply to [email protected]

From: Ajay Singh <[email protected]>

The firmware now uses throughput enhancement code by default for SPI so remove the previous implementation as its not used anymore. Removed the use of 'has_thrpt_enh' element as its always true.

---
 drivers/staging/wilc1000/spi.c | 143 +--------------------------------
 1 file changed, 4 insertions(+), 139 deletions(-)
drivers/staging/wilc1000/spi.c +4 -139
index 8694ab5fcb22..4b883a933b44 100644
@@ -13,7 +13,6 @@
 struct wilc_spi {
 	int crc_off;
 	int nint;
-	int has_thrpt_enh;
 };
 
 static const struct wilc_hif_func wilc_hif_spi;
@@ -897,8 +896,6 @@ static int wilc_spi_init(struct wilc *wilc, bool resume)
 		return 0;
 	}
 
-	spi_priv->has_thrpt_enh = 1;
-
 	isinit = 1;
 
 	return 1;
@@ -906,154 +903,22 @@ static int wilc_spi_init(struct wilc *wilc, bool resume)
 
 static int wilc_spi_read_size(struct wilc *wilc, u32 *size)
 {
-	struct spi_device *spi = to_spi_device(wilc->dev);
-	struct wilc_spi *spi_priv = wilc->bus_data;
 	int ret;
 
-	if (spi_priv->has_thrpt_enh) {
-		ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE,
-					size);
-		*size = *size  & IRQ_DMA_WD_CNT_MASK;
-	} else {
-		u32 tmp;
-		u32 byte_cnt;
-
-		ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE,
-					&byte_cnt);
-		if (!ret) {
-			dev_err(&spi->dev,
-				"Failed read WILC_VMM_TO_HOST_SIZE ...\n");
-			return ret;
-		}
-		tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
-		*size = tmp;
-	}
+	ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, size);
+	*size = *size & IRQ_DMA_WD_CNT_MASK;
 
 	return ret;
 }
 
 static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 {
-	struct spi_device *spi = to_spi_device(wilc->dev);
-	struct wilc_spi *spi_priv = wilc->bus_data;
-	int ret;
-	u32 tmp;
-	u32 byte_cnt;
-	bool unexpected_irq;
-	int j;
-	u32 unknown_mask;
-	u32 irq_flags;
-	int k = IRG_FLAGS_OFFSET + 5;
-
-	if (spi_priv->has_thrpt_enh)
-		return spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE,
-					 int_status);
-	ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE, &byte_cnt);
-	if (!ret) {
-		dev_err(&spi->dev,
-			"Failed read WILC_VMM_TO_HOST_SIZE ...\n");
-		return ret;
-	}
-	tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
-
-	j = 0;
-	do {
-		wilc_spi_read_reg(wilc, 0x1a90, &irq_flags);
-		tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET);
-
-		if (spi_priv->nint > 5) {
-			wilc_spi_read_reg(wilc, 0x1a94, &irq_flags);
-			tmp |= (((irq_flags >> 0) & 0x7) << k);
-		}
-
-		unknown_mask = ~((1ul << spi_priv->nint) - 1);
-
-		unexpected_irq = (tmp >> IRG_FLAGS_OFFSET) & unknown_mask;
-		if (unexpected_irq) {
-			dev_err(&spi->dev,
-				"Unexpected interrupt(2):j=%d,tmp=%x,mask=%x\n",
-				j, tmp, unknown_mask);
-		}
-
-		j++;
-	} while (unexpected_irq);
-
-	*int_status = tmp;
-
-	return ret;
+	return spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, int_status);
 }
 
 static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val)
 {
-	struct spi_device *spi = to_spi_device(wilc->dev);
-	struct wilc_spi *spi_priv = wilc->bus_data;
-	int ret;
-	u32 flags;
-	u32 tbl_ctl;
-
-	if (spi_priv->has_thrpt_enh) {
-		return spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE,
-					  val);
-	}
-
-	flags = val & (BIT(MAX_NUM_INT) - 1);
-	if (flags) {
-		int i;
-
-		ret = 1;
-		for (i = 0; i < spi_priv->nint; i++) {
-			/*
-			 * No matter what you write 1 or 0,
-			 * it will clear interrupt.
-			 */
-			if (flags & 1)
-				ret = wilc_spi_write_reg(wilc,
-							 0x10c8 + i * 4, 1);
-			if (!ret)
-				break;
-			flags >>= 1;
-		}
-		if (!ret) {
-			dev_err(&spi->dev,
-				"Failed wilc_spi_write_reg, set reg %x ...\n",
-				0x10c8 + i * 4);
-			return ret;
-		}
-		for (i = spi_priv->nint; i < MAX_NUM_INT; i++) {
-			if (flags & 1)
-				dev_err(&spi->dev,
-					"Unexpected interrupt cleared %d...\n",
-					i);
-			flags >>= 1;
-		}
-	}
-
-	tbl_ctl = 0;
-	/* select VMM table 0 */
-	if (val & SEL_VMM_TBL0)
-		tbl_ctl |= BIT(0);
-	/* select VMM table 1 */
-	if (val & SEL_VMM_TBL1)
-		tbl_ctl |= BIT(1);
-
-	ret = wilc_spi_write_reg(wilc, WILC_VMM_TBL_CTL, tbl_ctl);
-	if (!ret) {
-		dev_err(&spi->dev, "fail write reg vmm_tbl_ctl...\n");
-		return ret;
-	}
-
-	if (val & EN_VMM) {
-		/*
-		 * enable vmm transfer.
-		 */
-		ret = wilc_spi_write_reg(wilc, WILC_VMM_CORE_CTL, 1);
-		if (!ret) {
-			dev_err(&spi->dev, "fail write reg vmm_core_ctl...\n");
-			return ret;
-		}
-	}
-
-	return ret;
+	return spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE, val);
 }
 
 static int wilc_spi_sync_ext(struct wilc *wilc, int nint)
Signature · 1 line
2.24.0