From: Jacob Keller <jacob.e.keller@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH 1/8] ice: use __le16 types for explicitly Little Endian values
Date: Wed, 11 Mar 2020 14:33:12 -0700 [thread overview]
Message-ID: <20200311213319.783841-2-jacob.e.keller@intel.com> (raw)
In-Reply-To: <20200311213319.783841-1-jacob.e.keller@intel.com>
The ice_read_sr_aq function returns words in the Little Endian format.
Remove the need for __force and typecasting by using a local variable in
the ice_read_sr_word_aq function.
Additionally clarify explicitly that the ice_read_sr_aq function takes
storage for __le16 values instead of using u16.
Being explicit about the endianness of this data helps when using tools
like sparse to catch endian-related issues.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
---
drivers/net/ethernet/intel/ice/ice_nvm.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_nvm.c b/drivers/net/ethernet/intel/ice/ice_nvm.c
index f6e25db22c23..5597ec50a662 100644
--- a/drivers/net/ethernet/intel/ice/ice_nvm.c
+++ b/drivers/net/ethernet/intel/ice/ice_nvm.c
@@ -80,13 +80,14 @@ ice_check_sr_access_params(struct ice_hw *hw, u32 offset, u16 words)
* @hw: pointer to the HW structure
* @offset: offset in words from module start
* @words: number of words to read
- * @data: buffer for words reads from Shadow RAM
+ * @data: storage for the words read from Shadow RAM (Little Endian)
* @last_command: tells the AdminQ that this is the last command
*
- * Reads 16-bit word buffers from the Shadow RAM using the admin command.
+ * Reads 16-bit Little Endian word buffers from the Shadow RAM using the admin
+ * command.
*/
static enum ice_status
-ice_read_sr_aq(struct ice_hw *hw, u32 offset, u16 words, u16 *data,
+ice_read_sr_aq(struct ice_hw *hw, u32 offset, u16 words, __le16 *data,
bool last_command)
{
enum ice_status status;
@@ -116,10 +117,11 @@ static enum ice_status
ice_read_sr_word_aq(struct ice_hw *hw, u16 offset, u16 *data)
{
enum ice_status status;
+ __le16 data_local;
- status = ice_read_sr_aq(hw, offset, 1, data, true);
+ status = ice_read_sr_aq(hw, offset, 1, &data_local, true);
if (!status)
- *data = le16_to_cpu(*(__force __le16 *)data);
+ *data = le16_to_cpu(data_local);
return status;
}
--
2.24.1
next prev parent reply other threads:[~2020-03-11 21:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-11 21:33 [Intel-wired-lan] [PATCH 0/8] ice devlink support Jacob Keller
2020-03-11 21:33 ` Jacob Keller [this message]
2020-03-11 21:33 ` [Intel-wired-lan] [PATCH 2/8] ice: create function to read a section of the NVM and Shadow RAM Jacob Keller
2020-03-11 21:33 ` [Intel-wired-lan] [PATCH 3/8] ice: store NVM version info in extracted format Jacob Keller
2020-03-11 21:33 ` [Intel-wired-lan] [PATCH 4/8] ice: discover and store size of available flash Jacob Keller
2020-03-11 21:33 ` [Intel-wired-lan] [PATCH 5/8] ice: implement full NVM read from ETHTOOL_GEEPROM Jacob Keller
2020-03-11 21:33 ` [Intel-wired-lan] [PATCH 6/8] ice: enable initial devlink support Jacob Keller
2020-03-11 21:33 ` [Intel-wired-lan] [PATCH 7/8] ice: add basic handler for devlink .info_get Jacob Keller
2020-03-11 23:50 ` Jakub Kicinski
2020-03-12 1:07 ` Jacob Keller
2020-03-11 21:33 ` [Intel-wired-lan] [PATCH 8/8] ice: add board identifier info to " Jacob Keller
2020-03-11 23:49 ` Jakub Kicinski
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=20200311213319.783841-2-jacob.e.keller@intel.com \
--to=jacob.e.keller@intel.com \
--cc=intel-wired-lan@osuosl.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