Currently, sparse generates many warnings for the driver. This commit changes the types of struct fields/function variables to match the endianness at their assignment. Signed-off-by: Ernestas Kulik <ernestas.kulik@xxxxxxxxx> --- Changes from v1: * Change the type of the variable being passed to ntohs() instead of casting it * Don’t remove any struct fields drivers/staging/ks7010/eap_packet.h | 4 +- drivers/staging/ks7010/ks7010_sdio.c | 12 +++-- drivers/staging/ks7010/ks_hostif.c | 24 +++++----- drivers/staging/ks7010/ks_hostif.h | 90 ++++++++++++++++++------------------ drivers/staging/ks7010/ks_wlan.h | 2 +- 5 files changed, 68 insertions(+), 64 deletions(-) diff --git a/drivers/staging/ks7010/eap_packet.h b/drivers/staging/ks7010/eap_packet.h index df7f760e4110..fd39d28be834 100644 --- a/drivers/staging/ks7010/eap_packet.h +++ b/drivers/staging/ks7010/eap_packet.h @@ -16,7 +16,7 @@ struct ether_hdr { unsigned char h_source_snap; unsigned char h_command; unsigned char h_vendor_id[3]; - unsigned short h_proto; /* packet type ID field */ + __be16 h_proto; /* packet type ID field */ #define ETHER_PROTOCOL_TYPE_EAP 0x888e #define ETHER_PROTOCOL_TYPE_IP 0x0800 #define ETHER_PROTOCOL_TYPE_ARP 0x0806 @@ -86,7 +86,7 @@ struct ieee802_1x_eapol_key { struct wpa_eapol_key { unsigned char type; - unsigned short key_info; + __be16 key_info; unsigned short key_length; unsigned char replay_counter[WPA_REPLAY_COUNTER_LEN]; unsigned char key_nonce[WPA_NONCE_LEN]; diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 6f9f746a3a61..8e644ff8eca8 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -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); } diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index da7c42ef05f5..6ffc505d2cd8 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -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) { diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h index 30c49b699d62..f3a24c016662 100644 --- a/drivers/staging/ks7010/ks_hostif.h +++ b/drivers/staging/ks7010/ks_hostif.h @@ -62,13 +62,13 @@ */ struct hostif_hdr { - uint16_t size; - uint16_t event; + __le16 size; + __le16 event; } __packed; struct hostif_data_request_t { struct hostif_hdr header; - uint16_t auth_type; + __le16 auth_type; #define TYPE_DATA 0x0000 #define TYPE_AUTH 0x0001 uint16_t reserved; @@ -143,12 +143,12 @@ struct channel_list_t { struct hostif_mib_get_request_t { struct hostif_hdr header; - uint32_t mib_attribute; + __le32 mib_attribute; } __packed; struct hostif_mib_value_t { - uint16_t size; - uint16_t type; + __le16 size; + __le16 type; #define MIB_VALUE_TYPE_NULL 0 #define MIB_VALUE_TYPE_INT 1 #define MIB_VALUE_TYPE_BOOL 2 @@ -170,7 +170,7 @@ struct hostif_mib_get_confirm_t { struct hostif_mib_set_request_t { struct hostif_hdr header; - uint32_t mib_attribute; + __le32 mib_attribute; struct hostif_mib_value_t mib_value; } __packed; @@ -182,13 +182,13 @@ struct hostif_mib_set_confirm_t { struct hostif_power_mngmt_request_t { struct hostif_hdr header; - uint32_t mode; + __le32 mode; #define POWER_ACTIVE 1 #define POWER_SAVE 2 - uint32_t wake_up; + __le32 wake_up; #define SLEEP_FALSE 0 #define SLEEP_TRUE 1 /* not used */ - uint32_t receiveDTIMs; + __le32 receiveDTIMs; #define DTIM_FALSE 0 #define DTIM_TRUE 1 } __packed; @@ -213,7 +213,7 @@ struct hostif_power_mngmt_confirm_t { struct hostif_start_request_t { struct hostif_hdr header; - uint16_t mode; + __le16 mode; #define MODE_PSEUDO_ADHOC 0 #define MODE_INFRASTRUCTURE 1 #define MODE_AP 2 /* not used */ @@ -284,7 +284,7 @@ struct ap_info_t { uint8_t noise; /* +08 */ uint8_t pad0; /* +09 */ uint16_t beacon_period; /* +10 */ - uint16_t capability; /* +12 */ + __le16 capability; /* +12 */ #define BSS_CAP_ESS (1<<0) #define BSS_CAP_IBSS (1<<1) #define BSS_CAP_CF_POLABLE (1<<2) @@ -311,7 +311,7 @@ struct link_ap_info_t { uint8_t noise; /* +08 */ uint8_t pad0; /* +09 */ uint16_t beacon_period; /* +10 */ - uint16_t capability; /* +12 */ + __le16 capability; /* +12 */ struct rate_set8_t rate_set; /* +14 */ struct FhParms_t fh_parameter; /* +24 */ struct DsParms_t ds_parameter; /* +29 */ @@ -350,19 +350,19 @@ struct hostif_stop_confirm_t { struct hostif_ps_adhoc_set_request_t { struct hostif_hdr header; - uint16_t phy_type; + __le16 phy_type; #define D_11B_ONLY_MODE 0 #define D_11G_ONLY_MODE 1 #define D_11BG_COMPATIBLE_MODE 2 #define D_11A_ONLY_MODE 3 - uint16_t cts_mode; + __le16 cts_mode; #define CTS_MODE_FALSE 0 #define CTS_MODE_TRUE 1 - uint16_t channel; + __le16 channel; struct rate_set16_t rate_set; - uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + __le16 capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ - uint16_t scan_type; + __le16 scan_type; } __packed; struct hostif_ps_adhoc_set_confirm_t { @@ -372,34 +372,34 @@ struct hostif_ps_adhoc_set_confirm_t { struct hostif_infrastructure_set_request_t { struct hostif_hdr header; - uint16_t phy_type; - uint16_t cts_mode; + __le16 phy_type; + __le16 cts_mode; struct rate_set16_t rate_set; struct ssid_t ssid; - uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + __le16 capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ - uint16_t beacon_lost_count; - uint16_t auth_type; + __le16 beacon_lost_count; + __le16 auth_type; #define AUTH_TYPE_OPEN_SYSTEM 0 #define AUTH_TYPE_SHARED_KEY 1 struct channel_list_t channel_list; - uint16_t scan_type; + __le16 scan_type; } __packed; struct hostif_infrastructure_set2_request_t { struct hostif_hdr header; - uint16_t phy_type; - uint16_t cts_mode; + __le16 phy_type; + __le16 cts_mode; struct rate_set16_t rate_set; struct ssid_t ssid; - uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + __le16 capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ - uint16_t beacon_lost_count; - uint16_t auth_type; + __le16 beacon_lost_count; + __le16 auth_type; #define AUTH_TYPE_OPEN_SYSTEM 0 #define AUTH_TYPE_SHARED_KEY 1 struct channel_list_t channel_list; - uint16_t scan_type; + __le16 scan_type; uint8_t bssid[ETH_ALEN]; } __packed; @@ -410,26 +410,26 @@ struct hostif_infrastructure_set_confirm_t { struct hostif_adhoc_set_request_t { struct hostif_hdr header; - uint16_t phy_type; - uint16_t cts_mode; - uint16_t channel; + __le16 phy_type; + __le16 cts_mode; + __le16 channel; struct rate_set16_t rate_set; struct ssid_t ssid; - uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + __le16 capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ - uint16_t scan_type; + __le16 scan_type; } __packed; struct hostif_adhoc_set2_request_t { struct hostif_hdr header; - uint16_t phy_type; - uint16_t cts_mode; + __le16 phy_type; + __le16 cts_mode; uint16_t reserved; struct rate_set16_t rate_set; struct ssid_t ssid; - uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + __le16 capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ - uint16_t scan_type; + __le16 scan_type; struct channel_list_t channel_list; uint8_t bssid[ETH_ALEN]; } __packed; @@ -480,8 +480,8 @@ struct hostif_bss_scan_request_t { #define ACTIVE_SCAN 0 #define PASSIVE_SCAN 1 uint8_t pad[3]; - uint32_t ch_time_min; - uint32_t ch_time_max; + __le32 ch_time_min; + __le32 ch_time_max; struct channel_list_t channel_list; struct ssid_t ssid; } __packed; @@ -494,10 +494,10 @@ struct hostif_bss_scan_confirm_t { struct hostif_phy_information_request_t { struct hostif_hdr header; - uint16_t type; + __le16 type; #define NORMAL_TYPE 0 #define TIME_TYPE 1 - uint16_t time; /* unit 100ms */ + __le16 time; /* unit 100ms */ } __packed; struct hostif_phy_information_confirm_t { @@ -526,8 +526,8 @@ struct hostif_sleep_confirm_t { struct hostif_mic_failure_request_t { struct hostif_hdr header; - uint16_t failure_count; - uint16_t timer; + __le16 failure_count; + __le16 timer; } __packed; struct hostif_mic_failure_confirm_t { diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index 9ab80e1f123e..a4655a04005c 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -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; -- 2.12.0 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel