diff options
Diffstat (limited to 'drivers/net/e1000e/es2lan.c')
-rw-r--r-- | drivers/net/e1000e/es2lan.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c index 3ff932f02f29..3f435c16608d 100644 --- a/drivers/net/e1000e/es2lan.c +++ b/drivers/net/e1000e/es2lan.c | |||
@@ -99,6 +99,8 @@ | |||
99 | */ | 99 | */ |
100 | static const u16 e1000_gg82563_cable_length_table[] = | 100 | static const u16 e1000_gg82563_cable_length_table[] = |
101 | { 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF }; | 101 | { 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF }; |
102 | #define GG82563_CABLE_LENGTH_TABLE_SIZE \ | ||
103 | ARRAY_SIZE(e1000_gg82563_cable_length_table) | ||
102 | 104 | ||
103 | static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw); | 105 | static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw); |
104 | static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask); | 106 | static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask); |
@@ -694,20 +696,27 @@ static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw) | |||
694 | static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw) | 696 | static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw) |
695 | { | 697 | { |
696 | struct e1000_phy_info *phy = &hw->phy; | 698 | struct e1000_phy_info *phy = &hw->phy; |
697 | s32 ret_val; | 699 | s32 ret_val = 0; |
698 | u16 phy_data, index; | 700 | u16 phy_data, index; |
699 | 701 | ||
700 | ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data); | 702 | ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data); |
701 | if (ret_val) | 703 | if (ret_val) |
702 | return ret_val; | 704 | goto out; |
703 | 705 | ||
704 | index = phy_data & GG82563_DSPD_CABLE_LENGTH; | 706 | index = phy_data & GG82563_DSPD_CABLE_LENGTH; |
707 | |||
708 | if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5) { | ||
709 | ret_val = -E1000_ERR_PHY; | ||
710 | goto out; | ||
711 | } | ||
712 | |||
705 | phy->min_cable_length = e1000_gg82563_cable_length_table[index]; | 713 | phy->min_cable_length = e1000_gg82563_cable_length_table[index]; |
706 | phy->max_cable_length = e1000_gg82563_cable_length_table[index+5]; | 714 | phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5]; |
707 | 715 | ||
708 | phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; | 716 | phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; |
709 | 717 | ||
710 | return 0; | 718 | out: |
719 | return ret_val; | ||
711 | } | 720 | } |
712 | 721 | ||
713 | /** | 722 | /** |