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 11/31] staging: wfx: preserve endianness of struct hif_ind_startup
Date: Thu, 13 Jan 2022 09:55:04 +0100 [thread overview]
Message-ID: <20220113085524.1110708-12-Jerome.Pouiller@silabs.com> (raw)
In-Reply-To: <20220113085524.1110708-1-Jerome.Pouiller@silabs.com>
From: Jérôme Pouiller <jerome.pouiller@silabs.com>
The hardware fills struct hif_ind_startup with little endian values. So,
declare it with little endian fields.
It is now a bit more verbose to access to fields of struct
hif_ind_startup, but it is less confusing.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
drivers/staging/wfx/bh.c | 8 ++++----
drivers/staging/wfx/data_tx.c | 4 ++--
drivers/staging/wfx/hif_api_general.h | 12 ++++--------
drivers/staging/wfx/hif_rx.c | 5 -----
4 files changed, 10 insertions(+), 19 deletions(-)
diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c
index a0f9d1b53019..bbcf8d6a39c4 100644
--- a/drivers/staging/wfx/bh.c
+++ b/drivers/staging/wfx/bh.c
@@ -182,9 +182,9 @@ static void tx_helper(struct wfx_dev *wdev, struct hif_msg *hif)
wdev->hif.tx_seqnum = (wdev->hif.tx_seqnum + 1) % (HIF_COUNTER_MAX + 1);
data = hif;
- WARN(len > wdev->hw_caps.size_inp_ch_buf,
- "%s: request exceed the chip capability: %zu > %d\n", __func__,
- len, wdev->hw_caps.size_inp_ch_buf);
+ WARN(len > le16_to_cpu(wdev->hw_caps.size_inp_ch_buf),
+ "request exceed the chip capability: %zu > %d\n",
+ len, le16_to_cpu(wdev->hw_caps.size_inp_ch_buf));
len = wdev->hwbus_ops->align_size(wdev->hwbus_priv, len);
ret = wfx_data_write(wdev, data, len);
if (ret)
@@ -204,7 +204,7 @@ static int bh_work_tx(struct wfx_dev *wdev, int max_msg)
for (i = 0; i < max_msg; i++) {
hif = NULL;
- if (wdev->hif.tx_buffers_used < wdev->hw_caps.num_inp_ch_bufs) {
+ if (wdev->hif.tx_buffers_used < le16_to_cpu(wdev->hw_caps.num_inp_ch_bufs)) {
if (try_wait_for_completion(&wdev->hif_cmd.ready)) {
WARN(!mutex_is_locked(&wdev->hif_cmd.lock), "data locking error");
hif = wdev->hif_cmd.buf_send;
diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c
index 052a19161dc5..5492375fe80a 100644
--- a/drivers/staging/wfx/data_tx.c
+++ b/drivers/staging/wfx/data_tx.c
@@ -359,10 +359,10 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta,
hif_msg->len = cpu_to_le16(skb->len);
hif_msg->id = HIF_REQ_ID_TX;
hif_msg->interface = wvif->id;
- if (skb->len > wvif->wdev->hw_caps.size_inp_ch_buf) {
+ if (skb->len > le16_to_cpu(wvif->wdev->hw_caps.size_inp_ch_buf)) {
dev_warn(wvif->wdev->dev,
"requested frame size (%d) is larger than maximum supported (%d)\n",
- skb->len, wvif->wdev->hw_caps.size_inp_ch_buf);
+ skb->len, le16_to_cpu(wvif->wdev->hw_caps.size_inp_ch_buf));
skb_pull(skb, wmsg_len);
return -EIO;
}
diff --git a/drivers/staging/wfx/hif_api_general.h b/drivers/staging/wfx/hif_api_general.h
index 8244676112a5..a57789ceb209 100644
--- a/drivers/staging/wfx/hif_api_general.h
+++ b/drivers/staging/wfx/hif_api_general.h
@@ -108,16 +108,12 @@ enum hif_api_rate_index {
};
struct hif_ind_startup {
- /* As the others, this struct is interpreted as little endian by the
- * device. However, this struct is also used by the driver. We prefer to
- * declare it in native order and doing byte swap on reception.
- */
__le32 status;
- u16 hardware_id;
+ __le16 hardware_id;
u8 opn[14];
u8 uid[8];
- u16 num_inp_ch_bufs;
- u16 size_inp_ch_buf;
+ __le16 num_inp_ch_bufs;
+ __le16 size_inp_ch_buf;
u8 num_links_ap;
u8 num_interfaces;
u8 mac_addr[2][ETH_ALEN];
@@ -138,7 +134,7 @@ struct hif_ind_startup {
u8 phy1_region:3;
u8 phy0_region:3;
u8 otp_phy_ver:2;
- u32 supported_rate_mask;
+ __le32 supported_rate_mask;
u8 firmware_label[128];
} __packed;
diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c
index 5e675d2c3e82..ea6d192ce28c 100644
--- a/drivers/staging/wfx/hif_rx.c
+++ b/drivers/staging/wfx/hif_rx.c
@@ -81,11 +81,6 @@ static int hif_startup_indication(struct wfx_dev *wdev,
return -EINVAL;
}
memcpy(&wdev->hw_caps, body, sizeof(struct hif_ind_startup));
- le16_to_cpus((__le16 *)&wdev->hw_caps.hardware_id);
- le16_to_cpus((__le16 *)&wdev->hw_caps.num_inp_ch_bufs);
- le16_to_cpus((__le16 *)&wdev->hw_caps.size_inp_ch_buf);
- le32_to_cpus((__le32 *)&wdev->hw_caps.supported_rate_mask);
-
complete(&wdev->firmware_ready);
return 0;
}
--
2.34.1
next prev parent reply other threads:[~2022-01-13 8:56 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-13 8:54 [PATCH 00/31] staging/wfx: apply suggestions from the linux-wireless review Jerome Pouiller
2022-01-13 8:54 ` [PATCH 01/31] staging: wfx: fix Makefile and Kconfig licenses Jerome Pouiller
2022-01-13 8:54 ` [PATCH 02/31] staging: wfx: fix HIF API license Jerome Pouiller
2022-01-13 11:50 ` Kalle Valo
2022-01-13 12:16 ` Jérôme Pouiller
2022-01-13 8:54 ` [PATCH 03/31] staging: wfx: fix missing headers Jerome Pouiller
2022-01-13 8:54 ` [PATCH 04/31] staging: wfx: fix comment correctness Jerome Pouiller
2022-01-13 8:54 ` [PATCH 05/31] staging: wfx: explain uncommon Makefile statement Jerome Pouiller
2022-01-13 8:54 ` [PATCH 06/31] staging: wfx: remove unnecessary braces Jerome Pouiller
2022-01-13 8:55 ` [PATCH 07/31] staging: wfx: remove useless #ifdef Jerome Pouiller
2022-01-13 8:55 ` [PATCH 08/31] staging: wfx: use IS_ALIGNED() Jerome Pouiller
2022-01-13 8:55 ` [PATCH 09/31] staging: wfx: replace magic value by WFX_HIF_BUFFER_SIZE Jerome Pouiller
2022-01-13 8:55 ` [PATCH 10/31] stagigg: wfx: replace magic number by HIF_ID_IS_INDICATION Jerome Pouiller
2022-01-13 8:55 ` Jerome Pouiller [this message]
2022-01-13 8:55 ` [PATCH 12/31] staging: wfx: fix ambiguous function name Jerome Pouiller
2022-01-13 8:55 ` [PATCH 13/31] " Jerome Pouiller
2022-01-13 8:55 ` [PATCH 14/31] staging: wfx: prefix functions from hif_*.h with wfx_ Jerome Pouiller
2022-01-13 8:55 ` [PATCH 15/31] staging: wfx: prefix functions from hwio.h " Jerome Pouiller
2022-01-13 8:55 ` [PATCH 16/31] staging: wfx: prefix functions from debug.h " Jerome Pouiller
2022-01-13 8:55 ` [PATCH 17/31] staging: wfx: prefix tx_policy_is_equal() " Jerome Pouiller
2022-01-13 8:55 ` [PATCH 18/31] staging: wfx: prefix structs hif_* " Jerome Pouiller
2022-01-13 8:55 ` [PATCH 19/31] staging: wfx: prefix structs tx_policy and hwbus_ops " Jerome Pouiller
2022-01-13 8:55 ` [PATCH 20/31] staging: wfx: reformat code on 100 columns Jerome Pouiller
2022-01-13 8:55 ` [PATCH 21/31] staging: wfx: reformat comments " Jerome Pouiller
2022-01-13 8:55 ` [PATCH 22/31] staging: wfx: fix structs alignments Jerome Pouiller
2022-01-13 8:55 ` [PATCH 23/31] staging: wfx: use explicit labels for errors Jerome Pouiller
2022-01-13 8:55 ` [PATCH 24/31] staging: wfx: replace compiletime_assert() by BUILD_BUG_ON_MSG() Jerome Pouiller
2022-01-13 8:55 ` [PATCH 25/31] staging: wfx: do not display functions names in logs Jerome Pouiller
2022-01-13 8:55 ` [PATCH 26/31] staging: wfx: remove force_ps_timeout Jerome Pouiller
2022-01-13 8:55 ` [PATCH 27/31] staging: wfx: map 'compatible' attribute with board name Jerome Pouiller
2022-01-13 8:55 ` [PATCH 28/31] staging: wfx: fix firmware location Jerome Pouiller
2022-01-13 8:55 ` [PATCH 29/31] staging: wfx: drop legacy compatible values Jerome Pouiller
2022-01-13 8:55 ` [PATCH 30/31] staging: wfx: rename "config-file" DT attribute Jerome Pouiller
2022-01-13 8:55 ` [PATCH 31/31] staging: wfx: do not probe the device if not in the DT 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=20220113085524.1110708-12-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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).