Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ice: use __le16 types for explicitly Little Endian values

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>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

authored by

Jacob Keller and committed by
Jeff Kirsher
2efefb56 0d7043f3

+7 -5
+7 -5
drivers/net/ethernet/intel/ice/ice_nvm.c
··· 80 80 * @hw: pointer to the HW structure 81 81 * @offset: offset in words from module start 82 82 * @words: number of words to read 83 - * @data: buffer for words reads from Shadow RAM 83 + * @data: storage for the words read from Shadow RAM (Little Endian) 84 84 * @last_command: tells the AdminQ that this is the last command 85 85 * 86 - * Reads 16-bit word buffers from the Shadow RAM using the admin command. 86 + * Reads 16-bit Little Endian word buffers from the Shadow RAM using the admin 87 + * command. 87 88 */ 88 89 static enum ice_status 89 - ice_read_sr_aq(struct ice_hw *hw, u32 offset, u16 words, u16 *data, 90 + ice_read_sr_aq(struct ice_hw *hw, u32 offset, u16 words, __le16 *data, 90 91 bool last_command) 91 92 { 92 93 enum ice_status status; ··· 117 116 ice_read_sr_word_aq(struct ice_hw *hw, u16 offset, u16 *data) 118 117 { 119 118 enum ice_status status; 119 + __le16 data_local; 120 120 121 - status = ice_read_sr_aq(hw, offset, 1, data, true); 121 + status = ice_read_sr_aq(hw, offset, 1, &data_local, true); 122 122 if (!status) 123 - *data = le16_to_cpu(*(__force __le16 *)data); 123 + *data = le16_to_cpu(data_local); 124 124 125 125 return status; 126 126 }