Fix various compilation issues with wfx driver
cover Fix various compilation issues with wfx driver
From: Jérôme Pouiller <[email protected]>
Most of problems are related to big-endian architectures.
Jérôme Pouiller (7):
staging: wfx: simplify memory allocation in wfx_update_filtering()
staging: wfx: remove misused call to cpu_to_le16()
staging: wfx: le16_to_cpus() takes a reference as parameter
staging: wfx: correctly cast data on big-endian targets
staging: wfx: fix copy_{to,from}_user() usage
staging: wfx: drop calls to BUG_ON()
staging: wfx: avoid namespace contamination
drivers/staging/wfx/bh.c | 8 +++---- drivers/staging/wfx/bus_sdio.c | 4 ++-- drivers/staging/wfx/data_tx.c | 40 ++++++++++++++++---------------- drivers/staging/wfx/data_tx.h | 2 +- drivers/staging/wfx/debug.c | 5 ++-- drivers/staging/wfx/hif_tx_mib.h | 23 ++++++++++++------ drivers/staging/wfx/key.c | 32 ++++++++++++------------- drivers/staging/wfx/queue.c | 6 ++--- drivers/staging/wfx/scan.c | 2 +- drivers/staging/wfx/sta.c | 21 +++++++---------- 10 files changed, 74 insertions(+), 69 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/7 staging: wfx: simplify memory allocation in wfx_update_filtering()
From: Jérôme Pouiller <[email protected]>
Original code did not handle case where kmalloc failed. By the way, it is more convenient to allocate and build HIF message in hif_set_beacon_filter_table() instead of to ask to caller function to build it.
--- drivers/staging/wfx/hif_tx_mib.h | 19 ++++++++++++++----- drivers/staging/wfx/sta.c | 17 +++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-)
drivers/staging/wfx/hif_tx_mib.h +14 -5
@@ -86,13 +86,22 @@ static inline int hif_set_rx_filter(struct wfx_vif *wvif, bool filter_bssid, }static inline int hif_set_beacon_filter_table (struct wfx_vif *wvif, -struct hif_mib_bcn_filter_table *ft) +int tbl_len, +struct hif_ie_table_entry *tbl) { -size_t buf_len =struct_size (ft, ie_table, ft->num_of_info_elmts); +int ret; +struct hif_mib_bcn_filter_table *val; +int buf_len =struct_size (val, ie_table, tbl_len); -cpu_to_le32s (&ft->num_of_info_elmts); -return hif_write_mib (wvif->wdev, wvif->id, -HIF_MIB_ID_BEACON_FILTER_TABLE , ft, buf_len); + val =kzalloc (buf_len,GFP_KERNEL ); +if (!val) +return -ENOMEM ; + val->num_of_info_elmts =cpu_to_le32 (tbl_len); +memcpy (val->ie_table, tbl, tbl_len *sizeof (*tbl)); + ret =hif_write_mib (wvif->wdev, wvif->id, +HIF_MIB_ID_BEACON_FILTER_TABLE , val, buf_len); +kfree (val); +return ret; } static inline int hif_beacon_filter_control(struct wfx_vif *wvif,
drivers/staging/wfx/sta.c +7 -10
@@ -217,14 +217,13 @@ void wfx_update_filtering(struct wfx_vif *wvif)bool filter_bssid = wvif->filter_bssid;bool fwd_probe_req = wvif->fwd_probe_req;struct hif_mib_bcn_filter_enable bf_ctrl; -struct hif_mib_bcn_filter_table *bf_tbl; -struct hif_ie_table_entry ie_tbl[] = { +struct hif_ie_table_entry filter_ies[] = { { .ie_id =WLAN_EID_VENDOR_SPECIFIC , .has_changed =1 , .no_longer =1 , .has_appeared =1 , - .oui = {0x50 ,0x6F ,0x9A }, + .oui = {0x50 ,0x6F ,0x9A }, }, { .ie_id =WLAN_EID_HT_OPERATION , .has_changed =1 ,
@@ -237,36 +236,34 @@ void wfx_update_filtering(struct wfx_vif *wvif) .has_appeared = 1, } }; +int n_filter_ies;if (wvif->state ==WFX_STATE_PASSIVE )return ; - bf_tbl =kmalloc (sizeof (struct hif_mib_bcn_filter_table ) +sizeof (ie_tbl),GFP_KERNEL ); -memcpy (bf_tbl->ie_table, ie_tbl,sizeof (ie_tbl));if (wvif->disable_beacon_filter) { bf_ctrl.enable =0 ; bf_ctrl.bcn_count =1 ; - bf_tbl->num_of_info_elmts =0 ; + n_filter_ies =0 ; }else if (!is_sta) { bf_ctrl.enable =HIF_BEACON_FILTER_ENABLE |HIF_BEACON_FILTER_AUTO_ERP ; bf_ctrl.bcn_count =0 ; - bf_tbl->num_of_info_elmts =2 ; + n_filter_ies =2 ; }else { bf_ctrl.enable =HIF_BEACON_FILTER_ENABLE ; bf_ctrl.bcn_count =0 ; - bf_tbl->num_of_info_elmts =3 ; + n_filter_ies =3 ; } ret =hif_set_rx_filter (wvif, filter_bssid, fwd_probe_req);if (!ret) - ret =hif_set_beacon_filter_table (wvif, bf_tbl); + ret =hif_set_beacon_filter_table (wvif, n_filter_ies, filter_ies);if (!ret) ret =hif_beacon_filter_control (wvif, bf_ctrl.enable, bf_ctrl.bcn_count);if (!ret) ret =wfx_set_mcast_filter (wvif, &wvif->mcast_filter);if (ret)dev_err (wvif->wdev->dev,"update filtering failed: %d\n" , ret); -kfree (bf_tbl); }void wfx_update_filtering_work (struct work_struct *work)
Signature · 1 line
2.20.1
Re: [PATCH 1/7] staging: wfx: simplify memory allocation in wfx_update_filtering()
These patches are good. I just have a few nits to point out for future reference.
drivers/staging/wfx/hif_tx_mib.h static inline int hif_set_rx_filter(struct wfx_vif *wvif, bool filter_bssid, · line 94
Quoted 9 lines · Jerome Pouiller
static inline int hif_set_beacon_filter_table(struct
wfx_vif*wvif,drivers/staging/wfx/hif_tx_mib.h +5
-2- struct hif_mib_bcn_filter_table *ft) +int tbl_len, + struct hif_ie_table_entry *tbl) { -size_t buf_len =struct_size (ft, ie_table, ft->num_of_info_elmts); + int ret; +struct hif_mib_bcn_filter_table *val; +int buf_len =struct_size (val, ie_table, tbl_len);
This is fine for now, but since this is networking code, in the future could you write your declarations in reverse Christmas tree order?
long laskdfjasldfj asldfkj aslkdfj alskdfj askldfj; mid asdfasdflkajdflasjdf lkasjdf; short asdfasd; shortest i;
Quoted 4 lines
drivers/staging/wfx/hif_tx_mib.h +0
-3-cpu_to_le32s (&ft->num_of_info_elmts); -return hif_write_mib (wvif->wdev, wvif->id, -HIF_MIB_ID_BEACON_FILTER_TABLE , ft, buf_len);
[ snip ]
Quoted 8 lines
drivers/staging/wfx/sta.c +0
-0@@ -217,14 +217,13 @@ void wfx_update_filtering(struct wfx_vif *wvif)bool filter_bssid = wvif->filter_bssid;bool fwd_probe_req = wvif->fwd_probe_req;struct hif_mib_bcn_filter_enable bf_ctrl;
drivers/staging/wfx/sta.c void wfx_update_filtering(struct wfx_vif *wvif) · line 226
Quoted 10 lines
drivers/staging/wfx/sta.c +2
-3-struct hif_mib_bcn_filter_table *bf_tbl; -struct hif_ie_table_entry ie_tbl[] = { +struct hif_ie_table_entry filter_ies[] = { { .ie_id =WLAN_EID_VENDOR_SPECIFIC , .has_changed =1 , .no_longer =1 , .has_appeared =1 , - .oui = {0x50 ,0x6F ,0x9A }, + .oui = {0x50 ,0x6F ,0x9A },
Please don't do unrelated white space changes in their own patches.
drivers/staging/wfx/sta.c void wfx_update_filtering(struct wfx_vif *wvif) · line 229
Quoted 3 lines
drivers/staging/wfx/sta.c +0
-0}, { .ie_id = WLAN_EID_HT_OPERATION, .has_changed = 1,
regards,
dan carpenter
PATCH 2/7 staging: wfx: remove misused call to cpu_to_le16()
In reply to Jerome PouillerFrom: Jérôme Pouiller <[email protected]>
Indeed, hif_msg->id is a uint8_t, so use of cpu_to_le16() is a madness.
--- drivers/staging/wfx/data_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wfx/data_tx.c +1 -1
@@ -620,7 +620,7 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, structmemset (skb->data,0 , wmsg_len); hif_msg = (struct hif_msg *) skb->data; hif_msg->len =cpu_to_le16 (skb->len); - hif_msg->id =cpu_to_le16 (HIF_REQ_ID_TX ); + hif_msg->id =HIF_REQ_ID_TX ; hif_msg->interface = wvif->id;if (skb->len > wvif->wdev->hw_caps.size_inp_ch_buf) { dev_warn(wvif->wdev->dev, "requested frame size (%d) is larger than maximum supported (%d)\n",
Signature · 1 line
2.20.1
PATCH 3/7 staging: wfx: le16_to_cpus() takes a reference as parameter
In reply to Jerome PouillerFrom: Jérôme Pouiller <[email protected]>
Original code caused an (100% reproducible) invalid memory access on big-endian targets.
--- drivers/staging/wfx/bh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/wfx/bh.c +2 -2
@@ -83,12 +83,12 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf)// piggyback is probably correct. return piggyback; } -le16_to_cpus (hif->len); +le16_to_cpus (&hif->len); computed_len =round_up (hif->len -sizeof (hif->len),16 ) +sizeof (struct hif_sl_msg ) +sizeof (struct hif_sl_tag ); }else { -le16_to_cpus (hif->len); +le16_to_cpus (&hif->len); computed_len =round_up (hif->len,2 ); }if (computed_len != read_len) {
Signature · 1 line
2.20.1
PATCH 4/7 staging: wfx: correctly cast data on big-endian targets
In reply to Jerome PouillerFrom: Jérôme Pouiller <[email protected]>
When built for a big-endian target, original code caused error:
include/uapi/linux/swab.h:242:29: note: expected '__u32 * {aka unsigned int *}' but argument is of type 'struct hif_mib_protected_mgmt_policy *'
--- drivers/staging/wfx/hif_tx_mib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wfx/hif_tx_mib.h +1 -1
@@ -145,7 +145,7 @@ static inline int hif_set_mfp(struct wfx_vif *wvif, bool capable, bool required) }if (!required) val.unpmf_allowed =1 ; -cpu_to_le32s (&val); +cpu_to_le32s ((uint32_t *) &val);return hif_write_mib (wvif->wdev, wvif->id,HIF_MIB_ID_PROTECTED_MGMT_POLICY , &val,sizeof (val));
Signature · 1 line
2.20.1
Re: [PATCH 4/7] staging: wfx: correctly cast data on big-endian targets
Quoted 19 lines · Jerome Pouiller
From: Jérôme Pouiller <[email protected]>
When built for a big-endian target, original code caused error:
include/uapi/linux/swab.h:242:29: note: expected '__u32* {aka unsigned int *}' but argument is of type 'structhif_mib_protected_mgmt_policy*'Fixes f95a29d40782 ("staging: wfx: add HIF commands helpers")Reported-by kbuild test robot <[email protected]>Reported-by Stephen Rothwell <[email protected]>Signed-off-by Jérôme Pouiller <[email protected]>--- drivers/staging/wfx/hif_tx_mib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/wfx/hif_tx_mib.h +0
-0
drivers/staging/wfx/hif_tx_mib.h static inline int hif_set_mfp(struct wfx_vif *wvif, bool capable, bool required) · line 148
Quoted 5 lines
drivers/staging/wfx/hif_tx_mib.h +1
-1@@ -145,7 +145,7 @@ static inline int hif_set_mfp(struct wfx_vif *wvif, bool capable, bool required) }if (!required) val.unpmf_allowed =1 ; -cpu_to_le32s (&val); +cpu_to_le32s ((uint32_t *) &val);
Again, this is fine for now, but in the future there shouldn't be a space after the cast. It's to mark that it's a high precedence operation.
cpu_to_le32s((uint32_t *)&val);
regards,
dan carpenter
PATCH 5/7 staging: wfx: fix copy_{to,from}_user() usage
In reply to Jerome PouillerFrom: Jérôme Pouiller <[email protected]>
On error, copy_to_user() returns number of bytes remaining. Driver should return -EFAULT.
--- drivers/staging/wfx/debug.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/wfx/debug.c +2 -3
@@ -256,9 +256,8 @@ static ssize_t wfx_send_hif_msg_read(struct file *file, char __user *user_buf,return context->ret;// Be carefull, write() is waiting for a full message while read() // only return a payload - ret =copy_to_user (user_buf, context->reply, count); -if (ret) -return ret; +if (copy_to_user (user_buf, context->reply, count)) +return -EFAULT ;return count; }
Signature · 1 line
2.20.1
PATCH 6/7 staging: wfx: drop calls to BUG_ON()
In reply to Jerome PouillerFrom: Jérôme Pouiller <[email protected]>
Most of calls to BUG_ON() could replaced by WARN().
By the way, this patch also try to favor WARN() (that include a comment about the problem) instead of WARN_ON().
--- drivers/staging/wfx/bh.c | 4 ++-- drivers/staging/wfx/bus_sdio.c | 4 ++-- drivers/staging/wfx/data_tx.c | 4 ++-- drivers/staging/wfx/hif_tx_mib.h | 2 +- drivers/staging/wfx/key.c | 32 ++++++++++++++++---------------- drivers/staging/wfx/queue.c | 6 +++--- drivers/staging/wfx/scan.c | 2 +- drivers/staging/wfx/sta.c | 2 +- 8 files changed, 28 insertions(+), 28 deletions(-)
drivers/staging/wfx/bh.c +2 -2
@@ -56,7 +56,7 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf)int release_count;int piggyback =0 ; -WARN_ON (read_len <4 ); +WARN (read_len <4 ,"corrupted read" );WARN (read_len >round_down (0xFFF ,2 ) *sizeof (u16),"%s: request exceed WFx capability" , __func__);
@@ -173,7 +173,7 @@ static void tx_helper(struct wfx_dev *wdev, struct hif_msg *hif)bool is_encrypted = false;size_t len =le16_to_cpu (hif->len); -BUG_ON (len <sizeof (*hif)); +WARN (len <sizeof (*hif),"try to send corrupted data" ); hif->seqnum = wdev->hif.tx_seqnum; wdev->hif.tx_seqnum = (wdev->hif.tx_seqnum +1 ) % (HIF_COUNTER_MAX +1 );
drivers/staging/wfx/bus_sdio.c +2 -2
@@ -37,7 +37,7 @@ static int wfx_sdio_copy_from_io(void *priv, unsigned int reg_id,unsigned int sdio_addr = reg_id <<2 ;int ret; -BUG_ON (reg_id >7 ); +WARN (reg_id >7 ,"chip only has 7 registers" );WARN (((uintptr_t ) dst) &3 ,"unaligned buffer size" );WARN (count &3 ,"unaligned buffer address" );
@@ -58,7 +58,7 @@ static int wfx_sdio_copy_to_io(void *priv, unsigned int reg_id,unsigned int sdio_addr = reg_id <<2 ;int ret; -BUG_ON (reg_id >7 ); +WARN (reg_id >7 ,"chip only has 7 registers" );WARN (((uintptr_t ) src) &3 ,"unaligned buffer size" );WARN (count &3 ,"unaligned buffer address" );
drivers/staging/wfx/data_tx.c +2 -2
@@ -44,7 +44,7 @@ static void tx_policy_build(struct wfx_vif *wvif, struct tx_policy *policy,size_t count;struct wfx_dev *wdev = wvif->wdev; -BUG_ON (rates[0 ].idx <0 ); +WARN (rates[0 ].idx <0 ,"invalid rate policy" );memset (policy,0 ,sizeof (*policy));for (i =1 ; i <IEEE80211_TX_MAX_RATES ; i++)if (rates[i].idx <0 )
@@ -162,7 +162,7 @@ static int tx_policy_get(struct wfx_vif *wvif, struct ieee80211_tx_rate *rates,tx_policy_build (wvif, &wanted, rates);spin_lock_bh (&cache->lock); -if (WARN_ON_ONCE (list_empty (&cache->free))) { +if (WARN_ON (list_empty (&cache->free))) {spin_unlock_bh (&cache->lock);return WFX_INVALID_RATE_ID ; }
drivers/staging/wfx/hif_tx_mib.h +1 -1
@@ -138,7 +138,7 @@ static inline int hif_set_mfp(struct wfx_vif *wvif, bool capable, bool required) {struct hif_mib_protected_mgmt_policy val = { }; -WARN_ON (required && !capable); +WARN (required && !capable,"incoherent arguments" );if (capable) { val.pmf_enable =1 ; val.host_enc_auth_frames =1 ;
drivers/staging/wfx/key.c +16 -16
@@ -26,7 +26,7 @@ static int wfx_alloc_key(struct wfx_dev *wdev)static void wfx_free_key (struct wfx_dev *wdev,int idx) { -BUG_ON (!(wdev->key_map &BIT (idx))); +WARN (!(wdev->key_map &BIT (idx)),"inconsistent key allocation" );memset (&wdev->keys[idx],0 ,sizeof (wdev->keys[idx])); wdev->key_map &= ~BIT (idx); }
@@ -34,7 +34,7 @@ static void wfx_free_key(struct wfx_dev *wdev, int idx)static uint8_t fill_wep_pair (struct hif_wep_pairwise_key *msg,struct ieee80211_key_conf *key,u8 *peer_addr) { -WARN_ON (key->keylen >sizeof (msg->key_data)); +WARN (key->keylen >sizeof (msg->key_data),"inconsistent data" ); msg->key_length = key->keylen;memcpy (msg->key_data, key->key, key->keylen);ether_addr_copy (msg->peer_address, peer_addr);
@@ -44,7 +44,7 @@ static uint8_t fill_wep_pair(struct hif_wep_pairwise_key *msg,static uint8_t fill_wep_group (struct hif_wep_group_key *msg,struct ieee80211_key_conf *key) { -WARN_ON (key->keylen >sizeof (msg->key_data)); +WARN (key->keylen >sizeof (msg->key_data),"inconsistent data" ); msg->key_id = key->keyidx; msg->key_length = key->keylen;memcpy (msg->key_data, key->key, key->keylen);
@@ -56,9 +56,9 @@ static uint8_t fill_tkip_pair(struct hif_tkip_pairwise_key *msg, {uint8_t *keybuf = key->key; -WARN_ON (key->keylen !=sizeof (msg->tkip_key_data) - +sizeof (msg->tx_mic_key) - +sizeof (msg->rx_mic_key)); +WARN (key->keylen !=sizeof (msg->tkip_key_data) + +sizeof (msg->tx_mic_key) + +sizeof (msg->rx_mic_key),"inconsistent data" );memcpy (msg->tkip_key_data, keybuf,sizeof (msg->tkip_key_data)); keybuf +=sizeof (msg->tkip_key_data);memcpy (msg->tx_mic_key, keybuf,sizeof (msg->tx_mic_key));
@@ -75,8 +75,8 @@ static uint8_t fill_tkip_group(struct hif_tkip_group_key *msg, {uint8_t *keybuf = key->key; -WARN_ON (key->keylen !=sizeof (msg->tkip_key_data) - +2 *sizeof (msg->rx_mic_key)); +WARN (key->keylen !=sizeof (msg->tkip_key_data) + +2 *sizeof (msg->rx_mic_key),"inconsistent data" ); msg->key_id = key->keyidx;memcpy (msg->rx_sequence_counter, &seq->tkip.iv16,sizeof (seq->tkip.iv16));memcpy (msg->rx_sequence_counter +sizeof (uint16_t ), &seq->tkip.iv32,sizeof (seq->tkip.iv32));
@@ -94,7 +94,7 @@ static uint8_t fill_tkip_group(struct hif_tkip_group_key *msg,static uint8_t fill_ccmp_pair (struct hif_aes_pairwise_key *msg,struct ieee80211_key_conf *key,u8 *peer_addr) { -WARN_ON (key->keylen !=sizeof (msg->aes_key_data)); +WARN (key->keylen !=sizeof (msg->aes_key_data),"inconsistent data" );ether_addr_copy (msg->peer_address, peer_addr);memcpy (msg->aes_key_data, key->key, key->keylen);return HIF_KEY_TYPE_AES_PAIRWISE ;
@@ -104,7 +104,7 @@ static uint8_t fill_ccmp_group(struct hif_aes_group_key *msg,struct ieee80211_key_conf *key, struct ieee80211_key_seq *seq) { - WARN_ON(key->keylen != sizeof(msg->aes_key_data)); + WARN(key->keylen != sizeof(msg->aes_key_data), "inconsistent data");memcpy (msg->aes_key_data, key->key, key->keylen);memcpy (msg->rx_sequence_counter, seq->ccmp.pn,sizeof (seq->ccmp.pn));memreverse (msg->rx_sequence_counter,sizeof (seq->ccmp.pn));
@@ -117,8 +117,8 @@ static uint8_t fill_sms4_pair(struct hif_wapi_pairwise_key *msg, {uint8_t *keybuf = key->key; -WARN_ON (key->keylen !=sizeof (msg->wapi_key_data) - +sizeof (msg->mic_key_data)); +WARN (key->keylen !=sizeof (msg->wapi_key_data) + +sizeof (msg->mic_key_data),"inconsistent data" );ether_addr_copy (msg->peer_address, peer_addr);memcpy (msg->wapi_key_data, keybuf,sizeof (msg->wapi_key_data)); keybuf +=sizeof (msg->wapi_key_data);
@@ -132,8 +132,8 @@ static uint8_t fill_sms4_group(struct hif_wapi_group_key *msg, {uint8_t *keybuf = key->key; -WARN_ON (key->keylen !=sizeof (msg->wapi_key_data) - +sizeof (msg->mic_key_data)); +WARN (key->keylen !=sizeof (msg->wapi_key_data) + +sizeof (msg->mic_key_data),"inconsistent data" );memcpy (msg->wapi_key_data, keybuf,sizeof (msg->wapi_key_data)); keybuf +=sizeof (msg->wapi_key_data);memcpy (msg->mic_key_data, keybuf,sizeof (msg->mic_key_data));
@@ -145,7 +145,7 @@ static uint8_t fill_aes_cmac_group(struct hif_igtk_group_key *msg,struct ieee80211_key_conf *key, struct ieee80211_key_seq *seq) { - WARN_ON(key->keylen != sizeof(msg->igtk_key_data)); + WARN(key->keylen != sizeof(msg->igtk_key_data), "inconsistent data");memcpy (msg->igtk_key_data, key->key, key->keylen);memcpy (msg->ipn, seq->aes_cmac.pn,sizeof (seq->aes_cmac.pn));memreverse (msg->ipn,sizeof (seq->aes_cmac.pn));
@@ -163,7 +163,7 @@ static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta,int idx =wfx_alloc_key (wvif->wdev);bool pairwise = key->flags &IEEE80211_KEY_FLAG_PAIRWISE ; -WARN_ON (key->flags &IEEE80211_KEY_FLAG_PAIRWISE && !sta); +WARN (key->flags &IEEE80211_KEY_FLAG_PAIRWISE && !sta,"inconsistent data" );ieee80211_get_key_rx_seq (key,0 , &seq);if (idx <0 )return -EINVAL ;
drivers/staging/wfx/queue.c +3 -3
@@ -78,7 +78,7 @@ void wfx_tx_queues_unlock(struct wfx_dev *wdev)for (i =0 ; i <IEEE80211_NUM_ACS ; ++i) { queue = &wdev->tx_queue[i];spin_lock_bh (&queue->queue.lock); -BUG_ON (!queue->tx_locked_cnt); +WARN (!queue->tx_locked_cnt,"queue already unlocked" );if (--queue->tx_locked_cnt ==0 )ieee80211_wake_queue (wdev->hw, queue->queue_id);spin_unlock_bh (&queue->queue.lock);
@@ -295,8 +295,8 @@ struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id)return skb; } } -WARN_ON (1 );spin_unlock_bh (&stats->pending.lock); +WARN (1 ,"cannot find packet in pending queue" );return NULL ; }
@@ -408,7 +408,7 @@ static bool hif_handle_tx_data(struct wfx_vif *wvif, struct sk_buff *skb,switch (action) {case do_drop: -BUG_ON (wfx_pending_remove (wvif->wdev, skb)); +wfx_pending_remove (wvif->wdev, skb); handled = true;break ;case do_wep:
drivers/staging/wfx/scan.c +1 -1
@@ -107,7 +107,7 @@ int wfx_hw_scan(struct ieee80211_hw *hw,wfx_tx_lock_flush (wdev); -BUG_ON (wvif->scan.req); +WARN (wvif->scan.req,"unexpected concurrent scan" ); wvif->scan.req = req; wvif->scan.n_ssids =0 ; wvif->scan.status =0 ;
drivers/staging/wfx/sta.c +1 -1
@@ -1454,6 +1454,7 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) }, }; +BUILD_BUG_ON (ARRAY_SIZE (default_edca_params) !=ARRAY_SIZE (wvif->edca.params));if (wfx_api_older_than (wdev,2 ,0 )) { default_edca_params[IEEE80211_AC_BE ].queue_id =HIF_QUEUE_ID_BACKGROUND ; default_edca_params[IEEE80211_AC_BK ].queue_id =HIF_QUEUE_ID_BESTEFFORT ;
@@ -1526,7 +1527,6 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)mutex_unlock (&wdev->conf_mutex);hif_set_macaddr (wvif, vif->addr); -BUG_ON (ARRAY_SIZE (default_edca_params) !=ARRAY_SIZE (wvif->edca.params));for (i =0 ; i <IEEE80211_NUM_ACS ; i++) {memcpy (&wvif->edca.params[i], &default_edca_params[i],sizeof (default_edca_params[i])); wvif->edca.uapsd_enable[i] = false;
Signature · 1 line
2.20.1
Re: [PATCH 6/7] staging: wfx: drop calls to BUG_ON()
drivers/staging/wfx/key.c static uint8_t fill_tkip_pair(struct hif_tkip_pairwise_key *msg, · line 61
Quoted 10 lines · Jerome Pouiller
drivers/staging/wfx/key.c +3
-3@@ -56,9 +56,9 @@ static uint8_t fill_tkip_pair(struct hif_tkip_pairwise_key *msg, {uint8_t *keybuf = key->key; -WARN_ON (key->keylen !=sizeof (msg->tkip_key_data) - +sizeof (msg->tx_mic_key) - +sizeof (msg->rx_mic_key)); +WARN (key->keylen !=sizeof (msg->tkip_key_data) + +sizeof (msg->tx_mic_key) + +sizeof (msg->rx_mic_key),"inconsistent data" );
This is not a comment on the patch since the code was like that originally, but the " +" should go of the first line:
WARN(key->keylen != sizeof(msg->tkip_key_data) + sizeof(msg->tx_mic_key) + sizeof(msg->rx_mic_key), "inconsistent data");
That doesn't look too good still... The error message is sort of rubbish also. Anyway the operator goes on the first line.
regards,
dan carpenter
PATCH 7/7 staging: wfx: avoid namespace contamination
In reply to Jerome PouillerFrom: Jérôme Pouiller <[email protected]>
tx_policy_init() was already defined in driver cw1200. So, compilation failed when wfx and cw1200 were both built-in.
In order to keep a coherent naming scheme, this patch prefixes all "tx_policy_*" functions with "wfx_".
--- drivers/staging/wfx/data_tx.c | 34 +++++++++++++++++----------------- drivers/staging/wfx/data_tx.h | 2 +- drivers/staging/wfx/sta.c | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-)
drivers/staging/wfx/data_tx.c +17 -17
@@ -37,7 +37,7 @@ static int wfx_get_hw_rate(struct wfx_dev *wdev, const struct ieee80211_tx_rate/* TX policy cache implementation */ -static void tx_policy_build (struct wfx_vif *wvif,struct tx_policy *policy, +static void wfx_tx_policy_build (struct wfx_vif *wvif,struct tx_policy *policy,struct ieee80211_tx_rate *rates) {int i;
@@ -124,7 +124,7 @@ static bool tx_policy_is_equal(const struct tx_policy *a, const struct tx_policyreturn !memcmp (a->rates, b->rates,sizeof (a->rates)); } -static int tx_policy_find (struct tx_policy_cache *cache,struct tx_policy *wanted) +static int wfx_tx_policy_find (struct tx_policy_cache *cache,struct tx_policy *wanted) {struct tx_policy *it;
@@ -137,13 +137,13 @@ static int tx_policy_find(struct tx_policy_cache *cache, struct tx_policy *wantereturn -1 ; } -static void tx_policy_use (struct tx_policy_cache *cache,struct tx_policy *entry) +static void wfx_tx_policy_use (struct tx_policy_cache *cache,struct tx_policy *entry) { ++entry->usage_count;list_move (&entry->link, &cache->used); } -static int tx_policy_release (struct tx_policy_cache *cache,struct tx_policy *entry) +static int wfx_tx_policy_release (struct tx_policy_cache *cache,struct tx_policy *entry) {int ret = --entry->usage_count;
@@ -152,21 +152,21 @@ static int tx_policy_release(struct tx_policy_cache *cache, struct tx_policy *enreturn ret; } -static int tx_policy_get (struct wfx_vif *wvif,struct ieee80211_tx_rate *rates, +static int wfx_tx_policy_get (struct wfx_vif *wvif,struct ieee80211_tx_rate *rates,bool *renew) {int idx;struct tx_policy_cache *cache = &wvif->tx_policy_cache;struct tx_policy wanted; -tx_policy_build (wvif, &wanted, rates); +wfx_tx_policy_build (wvif, &wanted, rates);spin_lock_bh (&cache->lock);if (WARN_ON (list_empty (&cache->free))) {spin_unlock_bh (&cache->lock);return WFX_INVALID_RATE_ID ; } - idx =tx_policy_find (cache, &wanted); + idx =wfx_tx_policy_find (cache, &wanted);if (idx >=0 ) { *renew = false; }else {
@@ -181,7 +181,7 @@ static int tx_policy_get(struct wfx_vif *wvif, struct ieee80211_tx_rate *rates, entry->usage_count =0 ; idx = entry - cache->cache; } -tx_policy_use (cache, &cache->cache[idx]); +wfx_tx_policy_use (cache, &cache->cache[idx]);if (list_empty (&cache->free)) {/* Lock TX queues. */ wfx_tx_queues_lock (wvif->wdev);
@@ -190,14 +190,14 @@ static int tx_policy_get(struct wfx_vif *wvif, struct ieee80211_tx_rate *rates,return idx; } -static void tx_policy_put (struct wfx_vif *wvif,int idx) +static void wfx_tx_policy_put (struct wfx_vif *wvif,int idx) {int usage, locked;struct tx_policy_cache *cache = &wvif->tx_policy_cache;spin_lock_bh (&cache->lock); locked =list_empty (&cache->free); - usage =tx_policy_release (cache, &cache->cache[idx]); + usage =wfx_tx_policy_release (cache, &cache->cache[idx]);if (locked && !usage) {/* Unlock TX queues. */ wfx_tx_queues_unlock (wvif->wdev);
@@ -205,7 +205,7 @@ static void tx_policy_put(struct wfx_vif *wvif, int idx)spin_unlock_bh (&cache->lock); } -static int tx_policy_upload (struct wfx_vif *wvif) +static int wfx_tx_policy_upload (struct wfx_vif *wvif) {int i;struct tx_policy_cache *cache = &wvif->tx_policy_cache;
@@ -238,18 +238,18 @@ static int tx_policy_upload(struct wfx_vif *wvif)return 0 ; } -static void tx_policy_upload_work (struct work_struct *work) +static void wfx_tx_policy_upload_work (struct work_struct *work) {struct wfx_vif *wvif = container_of(work, struct wfx_vif, tx_policy_upload_work); -tx_policy_upload (wvif); +wfx_tx_policy_upload (wvif);wfx_tx_unlock (wvif->wdev);wfx_tx_queues_unlock (wvif->wdev); } -void tx_policy_init (struct wfx_vif *wvif) +void wfx_tx_policy_init (struct wfx_vif *wvif) {struct tx_policy_cache *cache = &wvif->tx_policy_cache;int i;
@@ -259,7 +259,7 @@ void tx_policy_init(struct wfx_vif *wvif)spin_lock_init (&cache->lock);INIT_LIST_HEAD (&cache->used);INIT_LIST_HEAD (&cache->free); -INIT_WORK (&wvif->tx_policy_upload_work, tx_policy_upload_work); +INIT_WORK (&wvif->tx_policy_upload_work, wfx_tx_policy_upload_work);for (i =0 ; i <HIF_MIB_NUM_TX_RATE_RETRY_POLICIES ; ++i)list_add (&cache->cache[i].link, &cache->free);
@@ -527,7 +527,7 @@ static uint8_t wfx_tx_get_rate_id(struct wfx_vif *wvif, struct ieee80211_tx_infobool tx_policy_renew = false;uint8_t rate_id; - rate_id =tx_policy_get (wvif, tx_info->driver_rates, &tx_policy_renew); + rate_id =wfx_tx_policy_get (wvif, tx_info->driver_rates, &tx_policy_renew);WARN (rate_id ==WFX_INVALID_RATE_ID ,"unable to get a valid Tx policy" );if (tx_policy_renew) {
@@ -794,6 +794,6 @@ void wfx_skb_dtor(struct wfx_dev *wdev, struct sk_buff *skb)WARN_ON (!wvif);skb_pull (skb, offset);wfx_notify_buffered_tx (wvif, skb, req); -tx_policy_put (wvif, req->tx_flags.retry_policy_index); +wfx_tx_policy_put (wvif, req->tx_flags.retry_policy_index);ieee80211_tx_status_irqsafe (wdev->hw, skb); }
drivers/staging/wfx/data_tx.h +1 -1
@@ -60,7 +60,7 @@ struct wfx_tx_priv {uint8_t tid; } __packed; -void tx_policy_init (struct wfx_vif *wvif); +void wfx_tx_policy_init (struct wfx_vif *wvif);void wfx_tx (struct ieee80211_hw *hw,struct ieee80211_tx_control *control,struct sk_buff *skb);
drivers/staging/wfx/sta.c +1 -1
@@ -1534,7 +1534,7 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) }wfx_set_uapsd_param (wvif, &wvif->edca); -tx_policy_init (wvif); +wfx_tx_policy_init (wvif); wvif =NULL ;while ((wvif =wvif_iterate (wdev, wvif)) !=NULL ) {// Combo mode does not support Block Acks. We can re-enable them
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerQuoted 3 lines · Jerome Pouiller
From: Jérôme Pouiller <[email protected]>
Most of problems are related to big-endian architectures.
kbuild still reports 2 errors with these patches applied:
Regressions in current branch:
drivers/staging/wfx/hif_tx.c:82:2-8: preceding lock on line 65 drivers/staging/wfx/main.c:188:14-21: ERROR: PTR_ERR applied after initialization to constant on line 183
Can you please fix those up as well?
thanks,
greg k-h
Quoted 10 lines · On Tuesday 8 October 2019 17:10:56 CEST Greg Kroah-Hartman wrote:
Quoted 3 lines · Jerome Pouiller
From: Jérôme Pouiller <[email protected]>
Most of problems are related to big-endian architectures.
kbuild still reports 2 errors with these patches applied:
Regressions in current branch:
drivers/staging/wfx/hif_tx.c:82:2-8: preceding lock on line 65
As I replied to Julia, this behavior is intended.
Quoted 1 line
drivers/staging/wfx/main.c:188:14-21: ERROR:
PTR_ERRapplied after initialization to constant on line 183
This is a false positive, as confirmed by Dan.
You may also notice:
drivers/staging/wfx/scan.c:207 wfx_scan_work() warn: inconsistent returns 'sem:&wvif->scan.lock'
I also consider it as a false positive.
Quoted 1 line
Can you please fix those up as well?
Beside these ones, I will address the other reported problems.
Signature · 1 line
Jérôme Pouiller
Quoted 16 lines · Jerome Pouiller
Quoted 10 lines · On Tuesday 8 October 2019 17:10:56 CEST Greg Kroah-Hartman wrote:
Quoted 3 lines · Jerome Pouiller
From: Jérôme Pouiller <[email protected]>
Most of problems are related to big-endian architectures.
kbuild still reports 2 errors with these patches applied:
Regressions in current branch:
drivers/staging/wfx/hif_tx.c:82:2-8: preceding lock on line 65
As I replied to Julia, this behavior is intended.
Quoted 1 line
drivers/staging/wfx/main.c:188:14-21: ERROR:
PTR_ERRapplied after initialization to constant on line 183
Quoted 7 lines
This is a false positive, as confirmed by Dan.
You may also notice:
drivers/staging/wfx/scan.c:207wfx_scan_work()warn: inconsistent returns 'sem:&wvif->scan.lock'I also consider it as a false positive.
Yeah. I thought it might be. The beauty of 0day bot is that normally the warnings come really quick after the original author wrote the code so it's fresh in their heads. I suspected it might be a false positive but I wasn't sure either way and I try not to spend a lot of time reviewing those warnings.
regards,
dan carpenter