aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/atlx/atl2.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/net/atlx/atl2.c b/drivers/net/atlx/atl2.c
index e637e9f28fd4..937ef1afa5db 100644
--- a/drivers/net/atlx/atl2.c
+++ b/drivers/net/atlx/atl2.c
@@ -1996,13 +1996,15 @@ static int atl2_set_eeprom(struct net_device *netdev,
1996 if (!eeprom_buff) 1996 if (!eeprom_buff)
1997 return -ENOMEM; 1997 return -ENOMEM;
1998 1998
1999 ptr = (u32 *)eeprom_buff; 1999 ptr = eeprom_buff;
2000 2000
2001 if (eeprom->offset & 3) { 2001 if (eeprom->offset & 3) {
2002 /* need read/modify/write of first changed EEPROM word */ 2002 /* need read/modify/write of first changed EEPROM word */
2003 /* only the second byte of the word is being modified */ 2003 /* only the second byte of the word is being modified */
2004 if (!atl2_read_eeprom(hw, first_dword*4, &(eeprom_buff[0]))) 2004 if (!atl2_read_eeprom(hw, first_dword*4, &(eeprom_buff[0]))) {
2005 return -EIO; 2005 ret_val = -EIO;
2006 goto out;
2007 }
2006 ptr++; 2008 ptr++;
2007 } 2009 }
2008 if (((eeprom->offset + eeprom->len) & 3)) { 2010 if (((eeprom->offset + eeprom->len) & 3)) {
@@ -2011,18 +2013,22 @@ static int atl2_set_eeprom(struct net_device *netdev,
2011 * only the first byte of the word is being modified 2013 * only the first byte of the word is being modified
2012 */ 2014 */
2013 if (!atl2_read_eeprom(hw, last_dword * 4, 2015 if (!atl2_read_eeprom(hw, last_dword * 4,
2014 &(eeprom_buff[last_dword - first_dword]))) 2016 &(eeprom_buff[last_dword - first_dword]))) {
2015 return -EIO; 2017 ret_val = -EIO;
2018 goto out;
2019 }
2016 } 2020 }
2017 2021
2018 /* Device's eeprom is always little-endian, word addressable */ 2022 /* Device's eeprom is always little-endian, word addressable */
2019 memcpy(ptr, bytes, eeprom->len); 2023 memcpy(ptr, bytes, eeprom->len);
2020 2024
2021 for (i = 0; i < last_dword - first_dword + 1; i++) { 2025 for (i = 0; i < last_dword - first_dword + 1; i++) {
2022 if (!atl2_write_eeprom(hw, ((first_dword+i)*4), eeprom_buff[i])) 2026 if (!atl2_write_eeprom(hw, ((first_dword+i)*4), eeprom_buff[i])) {
2023 return -EIO; 2027 ret_val = -EIO;
2028 goto out;
2029 }
2024 } 2030 }
2025 2031 out:
2026 kfree(eeprom_buff); 2032 kfree(eeprom_buff);
2027 return ret_val; 2033 return ret_val;
2028} 2034}