]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
igb: Code to prevent overwriting SFP I2C
authorAkeem G. Abodunrin <akeem.g.abodunrin@intel.com>
Fri, 2 Sep 2011 23:11:19 +0000 (23:11 +0000)
committerJoe Jin <joe.jin@oracle.com>
Thu, 17 May 2012 08:57:29 +0000 (16:57 +0800)
This patch fixes "overwrite" problem. without this fix, SFP I2C EEPROM
data, which is located at A0 can be overwritten by the phy write function.

(cherry picked from commit 76d06521f514e4e7e6bfb848ef0e3f8eb421f46d)
Signed-off-by: "Akeem G. Abodunrin" <akeem.g.abodunrin@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
drivers/net/igb/e1000_phy.c

index e662554c62d6706237edb034c7fa10782c8e669a..7edf31efe756a45bc56844eb672bd025a1dd7fb6 100644 (file)
@@ -306,6 +306,12 @@ s32 igb_write_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 data)
        u32 i, i2ccmd = 0;
        u16 phy_data_swapped;
 
+       /* Prevent overwritting SFP I2C EEPROM which is at A0 address.*/
+       if ((hw->phy.addr == 0) || (hw->phy.addr > 7)) {
+               hw_dbg("PHY I2C Address %d is out of range.\n",
+                         hw->phy.addr);
+               return -E1000_ERR_CONFIG;
+       }
 
        /* Swap the data bytes for the I2C interface */
        phy_data_swapped = ((data >> 8) & 0x00FF) | ((data << 8) & 0xFF00);