e1000_get_cable_length(struct e1000_hw *hw,                       uint16_t *min_length,                       uint16_t *max_length){    int32_t ret_val;    uint16_t agc_value = 0;    uint16_t cur_agc, min_agc = IGP01E1000_AGC_LENGTH_TABLE_SIZE;    uint16_t i, phy_data;    uint16_t cable_length;    DEBUGFUNC("e1000_get_cable_length");    *min_length = *max_length = 0;    /* Use old method for Phy older than IGP */    if(hw->phy_type == e1000_phy_m88) {        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,                                     &phy_data);        if(ret_val)            return ret_val;        cable_length = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >>                       M88E1000_PSSR_CABLE_LENGTH_SHIFT;        /* Convert the enum value to ranged values */        switch (cable_length) {        case e1000_cable_length_50:            *min_length = 0;            *max_length = e1000_igp_cable_length_50;            break;        case e1000_cable_length_50_80:            *min_length = e1000_igp_cable_length_50;            *max_length = e1000_igp_cable_length_80;            break;        case e1000_cable_length_80_110:            *min_length = e1000_igp_cable_length_80;            *max_length = e1000_igp_cable_length_110;            break;        case e1000_cable_length_110_140:            *min_length = e1000_igp_cable_length_110;            *max_length = e1000_igp_cable_length_140;            break;        case e1000_cable_length_140:            *min_length = e1000_igp_cable_length_140;            *max_length = e1000_igp_cable_length_170;            break;        default:            return -E1000_ERR_PHY;            break;        }    } else if(hw->phy_type == e1000_phy_igp) { /* For IGP PHY */        uint16_t agc_reg_array[IGP01E1000_PHY_CHANNEL_NUM] =                                                         {IGP01E1000_PHY_AGC_A,                                                          IGP01E1000_PHY_AGC_B,                                                          IGP01E1000_PHY_AGC_C,                                                          IGP01E1000_PHY_AGC_D};        /* Read the AGC registers for all channels */        for(i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {            ret_val = e1000_read_phy_reg(hw, agc_reg_array[i], &phy_data);            if(ret_val)                return ret_val;            cur_agc = phy_data >> IGP01E1000_AGC_LENGTH_SHIFT;            /* Array bound check. */            if((cur_agc >= IGP01E1000_AGC_LENGTH_TABLE_SIZE - 1) ||               (cur_agc == 0))                return -E1000_ERR_PHY;            agc_value += cur_agc;            /* Update minimal AGC value. */            if(min_agc > cur_agc)                min_agc = cur_agc;        }        /* Remove the minimal AGC result for length < 50m */        if(agc_value < IGP01E1000_PHY_CHANNEL_NUM * e1000_igp_cable_length_50) {            agc_value -= min_agc;            /* Get the average length of the remaining 3 channels */            agc_value /= (IGP01E1000_PHY_CHANNEL_NUM - 1);        } else {            /* Get the average length of all the 4 channels. */            agc_value /= IGP01E1000_PHY_CHANNEL_NUM;        }        /* Set the range of the calculated length. */        *min_length = ((e1000_igp_cable_length_table[agc_value] -                       IGP01E1000_AGC_RANGE) > 0) ?                       (e1000_igp_cable_length_table[agc_value] -                       IGP01E1000_AGC_RANGE) : 0;        *max_length = e1000_igp_cable_length_table[agc_value] +                      IGP01E1000_AGC_RANGE;    }    return E1000_SUCCESS;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/2d7edb923a823660b081bd4c660300ee19adca8d/e1000_hw.c/clean/drivers/net/e1000/e1000_hw.c