staging: ks7010: clean up code
PATCH 1/1 staging: ks7010: clean up code
This fixes type warnings generated by sparse, replaces instances of ntohs() with be16_to_cpu() and removes unused fields in structs.
--- drivers/staging/ks7010/ks7010_sdio.c | 12 ++-- drivers/staging/ks7010/ks_hostif.c | 30 +++++---- drivers/staging/ks7010/ks_hostif.h | 124 +++++++++++++++++------------------ drivers/staging/ks7010/ks_wlan.h | 2 +- 4 files changed, 85 insertions(+), 83 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +7 -5
@@ -297,7 +297,8 @@ static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, hdr = (struct hostif_hdr *)buffer;DPRINTK (4 ,"size=%d\n" , hdr->size); -if (hdr->event <HIF_DATA_REQ ||HIF_REQ_MAX < hdr->event) { +if (le16_to_cpu (hdr->event) <HIF_DATA_REQ || +HIF_REQ_MAX <le16_to_cpu (hdr->event)) {DPRINTK (1 ,"unknown event=%04X\n" , hdr->event);return 0 ; }
@@ -361,13 +362,14 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, hdr = (struct hostif_hdr *)p; -if (hdr->event <HIF_DATA_REQ ||HIF_REQ_MAX < hdr->event) { +if (le16_to_cpu (hdr->event) <HIF_DATA_REQ || +HIF_REQ_MAX <le16_to_cpu (hdr->event)) {DPRINTK (1 ,"unknown event=%04X\n" , hdr->event);return 0 ; }/* add event to hostt buffer */ - priv->hostt.buff[priv->hostt.qtail] = hdr->event; + priv->hostt.buff[priv->hostt.qtail] =le16_to_cpu (hdr->event); priv->hostt.qtail = (priv->hostt.qtail +1 ) %SME_EVENT_BUFF_SIZE ;DPRINTK (4 ,"event=%04X\n" , hdr->event);
@@ -406,7 +408,7 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)struct rx_device_buffer *rx_buffer;struct hostif_hdr *hdr;unsigned char read_status; -unsigned short event =0 ; +__le16 event =0 ;DPRINTK (4 ,"\n" );
@@ -459,7 +461,7 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)DPRINTK (4 ,"READ_STATUS=%02X\n" , read_status);if (atomic_read (&priv->psstatus.confirm_wait)) { -if (IS_HIF_CONF (event)) { +if (IS_HIF_CONF (le16_to_cpu (event))) {DPRINTK (4 ,"IS_HIF_CONF true !!\n" );atomic_dec (&priv->psstatus.confirm_wait); }
drivers/staging/ks7010/ks_hostif.c +16 -14
@@ -339,7 +339,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)get_WORD (priv);/* Reserve Area */ eth_hdr = (struct ether_hdr *)(priv->rxp); - eth_proto =ntohs (eth_hdr->h_proto); + eth_proto =be16_to_cpu ((__force __be16 )eth_hdr->h_proto);DPRINTK (3 ,"ether protocol = %04X\n" , eth_proto);/* source address check */
@@ -1200,7 +1200,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet)/* for WPA */ eth_hdr = (struct ether_hdr *)&pp->data[0 ]; - eth_proto =ntohs (eth_hdr->h_proto); + eth_proto =be16_to_cpu ((__force __be16 )eth_hdr->h_proto);/* for MIC FAILURE REPORT check */ if (eth_proto == ETHER_PROTOCOL_TYPE_EAP
@@ -1208,7 +1208,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) aa1x_hdr = (struct ieee802_1x_hdr *)(eth_hdr +1 );if (aa1x_hdr->type ==IEEE802_1X_TYPE_EAPOL_KEY ) { eap_key = (struct wpa_eapol_key *)(aa1x_hdr +1 ); - keyinfo =ntohs (eap_key->key_info); + keyinfo =be16_to_cpu ((__force __be16 )eap_key->key_info); } }
@@ -1867,7 +1867,7 @@ void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,static void hostif_sme_set_wep (struct ks_wlan_private *priv,int type) { -uint32_t val; +__le32 val;switch (type) {case SME_WEP_INDEX_REQUEST :
@@ -1916,13 +1916,13 @@ void hostif_sme_set_wep(struct ks_wlan_private *priv, int type) }struct wpa_suite_t { -unsigned short size; +__le16 size;unsigned char suite[4 ][CIPHER_ID_LEN ]; } __packed;struct rsn_mode_t { -uint32_t rsn_mode; -uint16_t rsn_capability; +__le32 rsn_mode; +__le16 rsn_capability; } __packed; static
@@ -1930,7 +1930,7 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type) {struct wpa_suite_t wpa_suite;struct rsn_mode_t rsn_mode; -uint32_t val; +__le32 val;memset (&wpa_suite,0 ,sizeof (wpa_suite));
@@ -1982,7 +1982,8 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)hostif_mib_set_request (priv,DOT11_RSN_CONFIG_UNICAST_CIPHER ,sizeof (wpa_suite.size) + -CIPHER_ID_LEN * wpa_suite.size, + (CIPHER_ID_LEN * +le16_to_cpu (wpa_suite.size)),MIB_VALUE_TYPE_OSTRING , &wpa_suite);break ;case SME_RSN_MCAST_REQUEST :
@@ -2074,7 +2075,8 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)hostif_mib_set_request (priv,DOT11_RSN_CONFIG_AUTH_SUITE ,sizeof (wpa_suite.size) + -KEY_MGMT_ID_LEN * wpa_suite.size, + (KEY_MGMT_ID_LEN * +le16_to_cpu (wpa_suite.size)),MIB_VALUE_TYPE_OSTRING , &wpa_suite);break ;case SME_RSN_ENABLED_REQUEST :
@@ -2215,7 +2217,7 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)int mc_count;struct netdev_hw_addr *ha;char set_address[NIC_MAX_MCAST_LIST *ETH_ALEN ]; -unsigned long filter_type; +__le32 filter_type;int i =0 ;DPRINTK (3 ,"\n" );
@@ -2324,7 +2326,7 @@ void hostif_sme_sleep_set(struct ks_wlan_private *priv)static void hostif_sme_set_key (struct ks_wlan_private *priv,int type) { -uint32_t val; +__le32 val;switch (type) {case SME_SET_FLAG :
@@ -2383,7 +2385,7 @@ static void hostif_sme_set_pmksa(struct ks_wlan_private *priv) { struct pmk_cache_t { - uint16_t size; + __le16 size; struct { uint8_t bssid[ETH_ALEN]; uint8_t pmkid[IW_PMKID_LEN];
@@ -2414,7 +2416,7 @@ void hostif_sme_set_pmksa(struct ks_wlan_private *priv)static void hostif_sme_execute (struct ks_wlan_private *priv,int event) { -uint32_t val; +__le32 val;DPRINTK (3 ,"event=%d\n" , event);switch (event) {
drivers/staging/ks7010/ks_hostif.h +61 -63
263 lines not on this page · raw message
drivers/staging/ks7010/ks_wlan.h +1 -1
@@ -243,7 +243,7 @@ struct local_ap_t {u8 body[16 ];u8 rate_pad; } rate_set; -u16 capability; +__le16 capability;u8 channel;u8 noise;struct rsn_ie_t wpa_ie;
Signature · 1 line
2.12.0
Quoted 2 lines · Ernestas Kulik
This fixes type warnings generated by sparse, replaces instances of
ntohs()withbe16_to_cpu()and removes unused fields in structs.
There's no real need to convert ntohs to be16_to_cpu
drivers/staging/ks7010/ks7010_sdio.c
Quoted 1 line
drivers/staging/ks7010/ks7010_sdio.c +0
-0
[]
drivers/staging/ks7010/ks7010_sdio.c static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, · line 302
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c +2
-1@@ -297,7 +297,8 @@ static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, hdr = (struct hostif_hdr *)buffer;DPRINTK (4 ,"size=%d\n" , hdr->size); -if (hdr->event <HIF_DATA_REQ ||HIF_REQ_MAX < hdr->event) { +if (le16_to_cpu (hdr->event) <HIF_DATA_REQ || +HIF_REQ_MAX <le16_to_cpu (hdr->event)) {
This isn't mentioned and doesn't match the commit message
Quoted 6 lines · Joe Perches
Quoted 2 lines · Ernestas Kulik
This fixes type warnings generated by sparse, replaces instances of
ntohs()withbe16_to_cpu()and removes unused fields in structs.There's no real need to convert ntohs to
be16_to_cpu
I noticed a patch that was merged that replaces calls to these with the more “generic” be16_to_cpu(), but I can revert that.
This kind of conversion also happened in SeaBIOS, but it’s not exactly the same thing as here.
Quoted 6 lines
drivers/staging/ks7010/ks7010_sdio.c
Quoted 1 line
drivers/staging/ks7010/ks7010_sdio.c +0
-0[]
Quoted 4 lines
drivers/staging/ks7010/ks7010_sdio.c +0
-0@@ -297,7 +297,8 @@ static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, hdr = (struct hostif_hdr *)buffer;
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer,
Quoted 5 lines
drivers/staging/ks7010/ks7010_sdio.c +2
-1DPRINTK (4 ,"size=%d\n" , hdr->size); -if (hdr->event <HIF_DATA_REQ ||HIF_REQ_MAX < hdr->event) { +if (le16_to_cpu (hdr->event) <HIF_DATA_REQ || +HIF_REQ_MAX <le16_to_cpu (hdr->event)) {This isn't mentioned and doesn't match the commit message
It is and it does, but the commit message is a bit vague. I’ll try to expand it.
Quoted 30 lines · Ernestas Kulik
Quoted 6 lines · Joe Perches
Quoted 2 lines · Ernestas Kulik
This fixes type warnings generated by sparse, replaces instances of
ntohs()withbe16_to_cpu()and removes unused fields in structs.There's no real need to convert ntohs to
be16_to_cpuI noticed a patch that was merged that replaces calls to these with the more “generic”
be16_to_cpu(), but I can revert that.This kind of conversion also happened in SeaBIOS, but it’s not exactly the same thing as here.
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c
Quoted 1 line
drivers/staging/ks7010/ks7010_sdio.c +0
-0[]
Quoted 4 lines
drivers/staging/ks7010/ks7010_sdio.c +0
-0@@ -297,7 +297,8 @@ static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, hdr = (struct hostif_hdr *)buffer;Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer,
Quoted 5 lines
drivers/staging/ks7010/ks7010_sdio.c +2
-1DPRINTK (4 ,"size=%d\n" , hdr->size); -if (hdr->event <HIF_DATA_REQ ||HIF_REQ_MAX < hdr->event) { +if (le16_to_cpu (hdr->event) <HIF_DATA_REQ || +HIF_REQ_MAX <le16_to_cpu (hdr->event)) {This isn't mentioned and doesn't match the commit message
Quoted 2 lines
It is and it does, but the commit message is a bit vague. I’ll try to expand it.
Not really.
struct hostif_hdr.event is declared at uint16_t
and not as __le16 so I believe this is incorrect
and actually introduces a sparse error.
Quoted 4 lines · Joe Perches
struct hostif_hdr.event is declared at
uint16_t
and not as__le16so I believe this is incorrect
and actually introduces a sparse error.
Sure, but I change that in the patch. :)
Quoted 7 lines · Ernestas Kulik
struct
hostif_hdr{drivers/staging/ks7010/ks_hostif.h +2
-2-uint16_t size; -uint16_t event; +__le16 size; +__le16 event;}
__packed;
Quoted 7 lines · Ernestas Kulik
Quoted 4 lines · Joe Perches
struct hostif_hdr.event is declared at
uint16_t
and not as__le16so I believe this is incorrect
and actually introduces a sparse error.Sure, but I change that in the patch. :)
More stuff the changelog doesn't show :(
Quoted 2 lines · Ernestas Kulik
This fixes type warnings generated by sparse, replaces instances of
ntohs()withbe16_to_cpu()and removes unused fields in structs.
Quoted 6 lines · Joe Perches
More stuff the changelog doesn't show :(
Quoted 2 lines · Ernestas Kulik
This fixes type warnings generated by sparse, replaces instances of
ntohs()withbe16_to_cpu()and removes unused fields in structs.
I’ve posted a v2 of the patch, reducing the scope so as to not inadvertently break something.