Re: [PATCH net-next v3 3/3] net: dp83869: Add speed optimization feature

From: Jakub Kicinski
Date: Sat Sep 05 2020 - 14:38:28 EST


On Thu, 3 Sep 2020 06:42:59 -0500 Dan Murphy wrote:
> +static int dp83869_set_downshift(struct phy_device *phydev, u8 cnt)
> +{
> + int val, count;
> +
> + if (cnt > DP83869_DOWNSHIFT_8_COUNT)
> + return -E2BIG;

ERANGE

> + if (!cnt)
> + return phy_clear_bits(phydev, DP83869_CFG2,
> + DP83869_DOWNSHIFT_EN);
> +
> + switch (cnt) {
> + case DP83869_DOWNSHIFT_1_COUNT:
> + count = DP83869_DOWNSHIFT_1_COUNT_VAL;
> + break;
> + case DP83869_DOWNSHIFT_2_COUNT:
> + count = DP83869_DOWNSHIFT_2_COUNT_VAL;
> + break;
> + case DP83869_DOWNSHIFT_4_COUNT:
> + count = DP83869_DOWNSHIFT_4_COUNT_VAL;
> + break;
> + case DP83869_DOWNSHIFT_8_COUNT:
> + count = DP83869_DOWNSHIFT_8_COUNT_VAL;
> + break;
> + default:
> + phydev_err(phydev,
> + "Downshift count must be 1, 2, 4 or 8\n");
> + return -EINVAL;
> + }
> +
> + val = DP83869_DOWNSHIFT_EN;
> + val |= FIELD_PREP(DP83869_DOWNSHIFT_ATTEMPT_MASK, count);
> +
> + return phy_modify(phydev, DP83869_CFG2,
> + DP83869_DOWNSHIFT_EN | DP83869_DOWNSHIFT_ATTEMPT_MASK,
> + val);
> +}