From: Jerome Pouiller <Jerome.Pouiller@silabs.com> To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>, "Kalle Valo" <kvalo@codeaurora.org>, "David S . Miller" <davem@davemloft.net>, "Jérôme Pouiller" <jerome.pouiller@silabs.com> Subject: [PATCH 16/17] staging: wfx: fix endianness of the field 'channel_number' Date: Mon, 11 May 2020 17:49:29 +0200 [thread overview] Message-ID: <20200511154930.190212-17-Jerome.Pouiller@silabs.com> (raw) In-Reply-To: <20200511154930.190212-1-Jerome.Pouiller@silabs.com> From: Jérôme Pouiller <jerome.pouiller@silabs.com> 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> --- drivers/staging/wfx/hif_api_cmd.h | 15 +++++++++------ drivers/staging/wfx/hif_tx.c | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/wfx/hif_api_cmd.h b/drivers/staging/wfx/hif_api_cmd.h index 8c48477e8797..21cde19cff75 100644 --- a/drivers/staging/wfx/hif_api_cmd.h +++ b/drivers/staging/wfx/hif_api_cmd.h @@ -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; diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index e653ebbe5067..ecc99b765335 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -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)); -- 2.26.2
WARNING: multiple messages have this Message-ID (diff)
From: Jerome Pouiller <Jerome.Pouiller@silabs.com> To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "David S . Miller" <davem@davemloft.net>, Kalle Valo <kvalo@codeaurora.org> Subject: [PATCH 16/17] staging: wfx: fix endianness of the field 'channel_number' Date: Mon, 11 May 2020 17:49:29 +0200 [thread overview] Message-ID: <20200511154930.190212-17-Jerome.Pouiller@silabs.com> (raw) In-Reply-To: <20200511154930.190212-1-Jerome.Pouiller@silabs.com> From: Jérôme Pouiller <jerome.pouiller@silabs.com> 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> --- drivers/staging/wfx/hif_api_cmd.h | 15 +++++++++------ drivers/staging/wfx/hif_tx.c | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/wfx/hif_api_cmd.h b/drivers/staging/wfx/hif_api_cmd.h index 8c48477e8797..21cde19cff75 100644 --- a/drivers/staging/wfx/hif_api_cmd.h +++ b/drivers/staging/wfx/hif_api_cmd.h @@ -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; diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index e653ebbe5067..ecc99b765335 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -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)); -- 2.26.2 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2020-05-11 15:50 UTC|newest] Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-11 15:49 [PATCH 00/17] staging: wfx: fix support for big-endian hosts Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 01/17] staging: wfx: fix use of cpu_to_le32 instead of le32_to_cpu Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 02/17] staging: wfx: take advantage of le32_to_cpup() Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 03/17] staging: wfx: fix cast operator Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 04/17] staging: wfx: fix wrong bytes order Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 05/17] staging: wfx: fix output of rx_stats on big endian hosts Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 06/17] staging: wfx: fix endianness of fields media_delay and tx_queue_delay Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 07/17] staging: wfx: fix endianness of hif_req_read_mib fields Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 08/17] staging: wfx: fix access to le32 attribute 'ps_mode_error' Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 09/17] staging: wfx: fix access to le32 attribute 'event_id' Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 10/17] staging: wfx: fix access to le32 attribute 'indication_type' Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 11/17] staging: wfx: declare the field 'packet_id' with native byte order Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 12/17] staging: wfx: fix endianness of the struct hif_ind_startup Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 13/17] staging: wfx: fix endianness of the field 'len' Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 21:59 ` kbuild test robot 2020-05-11 21:59 ` kbuild test robot 2020-05-11 21:59 ` kbuild test robot 2020-05-12 7:43 ` Geert Uytterhoeven 2020-05-12 7:43 ` Geert Uytterhoeven 2020-05-12 9:25 ` Jérôme Pouiller 2020-05-12 9:25 ` Jérôme Pouiller 2020-05-11 15:49 ` [PATCH 14/17] staging: wfx: fix endianness of the field 'status' Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` [PATCH 15/17] staging: wfx: fix endianness of the field 'num_tx_confs' Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller [this message] 2020-05-11 15:49 ` [PATCH 16/17] staging: wfx: fix endianness of the field 'channel_number' Jerome Pouiller 2020-05-11 15:49 ` [PATCH 17/17] staging: wfx: update TODO Jerome Pouiller 2020-05-11 15:49 ` Jerome Pouiller
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200511154930.190212-17-Jerome.Pouiller@silabs.com \ --to=jerome.pouiller@silabs.com \ --cc=davem@davemloft.net \ --cc=devel@driverdev.osuosl.org \ --cc=gregkh@linuxfoundation.org \ --cc=kvalo@codeaurora.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-wireless@vger.kernel.org \ --cc=netdev@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.