]> git.baikalelectronics.ru Git - kernel.git/commitdiff
intel: remove checker warning
authorJesse Brandeburg <jesse.brandeburg@intel.com>
Fri, 26 Mar 2021 00:38:25 +0000 (17:38 -0700)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Wed, 26 May 2021 16:11:40 +0000 (09:11 -0700)
The sparse checker (C=2) found an assignment where we were mixing
types when trying to convert from data read directly from the
device NVM, to an array in CPU order in-memory, which
unfortunately the driver tries to do in-place.

This is easily solved by using the swap operation instead of an
assignment, and is already proven in other Intel drivers to be
functionally correct and the same code, just without a sparse
warning.

The change is the same in all three drivers.

Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Dave Switzer <david.switzer@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/e1000/e1000_ethtool.c
drivers/net/ethernet/intel/igb/igb_ethtool.c
drivers/net/ethernet/intel/igc/igc_ethtool.c

index f976e9daa3d8820fe108e19941c7d3783ef41baa..3c51ee94fa00b847191296af9a90352088044d59 100644 (file)
@@ -513,7 +513,7 @@ static int e1000_set_eeprom(struct net_device *netdev,
        memcpy(ptr, bytes, eeprom->len);
 
        for (i = 0; i < last_word - first_word + 1; i++)
-               eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]);
+               cpu_to_le16s(&eeprom_buff[i]);
 
        ret_val = e1000_write_eeprom(hw, first_word,
                                     last_word - first_word + 1, eeprom_buff);
index 7545da216d8bc9c4003356857a0d4f1327e54579..636a1b1fb7e1d697f869677d845d58d6a3894bd3 100644 (file)
@@ -831,7 +831,7 @@ static int igb_set_eeprom(struct net_device *netdev,
        memcpy(ptr, bytes, eeprom->len);
 
        for (i = 0; i < last_word - first_word + 1; i++)
-               eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]);
+               cpu_to_le16s(&eeprom_buff[i]);
 
        ret_val = hw->nvm.ops.write(hw, first_word,
                                    last_word - first_word + 1, eeprom_buff);
index 9722449d7633d68d9f002181c3d056107482e54e..2cb12431c371a02355890b69334647a6e9d24497 100644 (file)
@@ -554,7 +554,7 @@ static int igc_ethtool_set_eeprom(struct net_device *netdev,
        memcpy(ptr, bytes, eeprom->len);
 
        for (i = 0; i < last_word - first_word + 1; i++)
-               eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]);
+               cpu_to_le16s(&eeprom_buff[i]);
 
        ret_val = hw->nvm.ops.write(hw, first_word,
                                    last_word - first_word + 1, eeprom_buff);