staging: wfx: fix endianness of the field 'channel_number'

The field 'channel_number' from the structs hif_ind_rx and hif_req_start
is a __le32. Sparse complains this field is not always correctly
accessed:

    drivers/staging/wfx/data_rx.c:95:55: warning: incorrect type in argument 1 (different base types)
    drivers/staging/wfx/data_rx.c:95:55:    expected int chan
    drivers/staging/wfx/data_rx.c:95:55:    got restricted __le16 const [usertype] channel_number

However, the value of channel_number cannot be greater than 14 (this
device only support 2.4Ghz band). So, we only have to access to the
least significant byte. It is finally easier to declare it as an array
of bytes and only access to the first one.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200512150414.267198-17-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jérôme Pouiller 2020-05-12 17:04:13 +02:00 committed by Greg Kroah-Hartman
parent 8008b480e2
commit d99ce4a1e5
2 changed files with 11 additions and 8 deletions

View File

@ -321,7 +321,8 @@ struct hif_rx_flags {
struct hif_ind_rx {
__le32 status;
__le16 channel_number;
u8 channel_number;
u8 reserved;
u8 rxed_rate;
u8 rcpi_rssi;
struct hif_rx_flags rx_flags;
@ -356,7 +357,8 @@ struct hif_req_join {
u8 infrastructure_bss_mode:1;
u8 reserved1:7;
u8 band;
__le16 channel_number;
u8 channel_number;
u8 reserved;
u8 bssid[ETH_ALEN];
__le16 atim_window;
u8 short_preamble:1;
@ -421,13 +423,14 @@ struct hif_ind_set_pm_mode_cmpl {
struct hif_req_start {
u8 mode;
u8 band;
__le16 channel_number;
__le32 reserved1;
u8 channel_number;
u8 reserved1;
__le32 reserved2;
__le32 beacon_interval;
u8 dtim_period;
u8 short_preamble:1;
u8 reserved2:7;
u8 reserved3;
u8 reserved3:7;
u8 reserved4;
u8 ssid_length;
u8 ssid[HIF_API_SSID_SIZE];
__le32 basic_rate_set;

View File

@ -309,7 +309,7 @@ int hif_join(struct wfx_vif *wvif, const struct ieee80211_bss_conf *conf,
body->probe_for_join = 0;
else
body->probe_for_join = 1;
body->channel_number = cpu_to_le16(channel->hw_value);
body->channel_number = channel->hw_value;
body->beacon_interval = cpu_to_le32(conf->beacon_int);
body->basic_rate_set =
cpu_to_le32(wfx_rate_mask_to_hw(wvif->wdev, conf->basic_rates));
@ -435,7 +435,7 @@ int hif_start(struct wfx_vif *wvif, const struct ieee80211_bss_conf *conf,
WARN_ON(!conf->beacon_int);
body->dtim_period = conf->dtim_period;
body->short_preamble = conf->use_short_preamble;
body->channel_number = cpu_to_le16(channel->hw_value);
body->channel_number = channel->hw_value;
body->beacon_interval = cpu_to_le32(conf->beacon_int);
body->basic_rate_set =
cpu_to_le32(wfx_rate_mask_to_hw(wvif->wdev, conf->basic_rates));