[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240104130337.GG31813@kernel.org>
Date: Thu, 4 Jan 2024 13:03:37 +0000
From: Simon Horman <horms@...nel.org>
To: Christian Marangi <ansuelsmth@...il.com>
Cc: Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [net-next PATCH v3 2/4] net: phy: at803x: refactor qca808x cable
test get status function
On Wed, Jan 03, 2024 at 01:46:33PM +0100, Christian Marangi wrote:
> Refactor qca808x cable test get status function to remove code
> duplication and clean things up.
>
> The same logic is applied to each pair hence it can be generalized and
> moved to a common function.
>
> Signed-off-by: Christian Marangi <ansuelsmth@...il.com>
> ---
> drivers/net/phy/at803x.c | 65 +++++++++++++++++++++-------------------
> 1 file changed, 34 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index acf483fa0887..b87293ee736c 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -2037,10 +2037,39 @@ static int qca808x_cable_test_start(struct phy_device *phydev)
> return 0;
> }
>
> +static void qca808x_cable_test_get_pair_status(struct phy_device *phydev, u8 pair,
> + u16 status)
> +{
> + u16 pair_code;
> + int length;
> +
> + switch (pair) {
> + case ETHTOOL_A_CABLE_PAIR_A:
> + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_A, status);
> + break;
> + case ETHTOOL_A_CABLE_PAIR_B:
> + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_B, status);
> + break;
> + case ETHTOOL_A_CABLE_PAIR_C:
> + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_C, status);
> + break;
> + case ETHTOOL_A_CABLE_PAIR_D:
> + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_D, status);
> + break;
> + }
Hi Christian,
I don't think this can actually happen given current usage,
but if pair doesn't match one of the cases above,
then pair_code is used uninitialised below.
Flagged by Smatch.
> +
> + ethnl_cable_test_result(phydev, pair,
> + qca808x_cable_test_result_trans(pair_code));
> +
> + if (qca808x_cdt_fault_length_valid(pair_code)) {
> + length = qca808x_cdt_fault_length(phydev, pair);
> + ethnl_cable_test_fault_length(phydev, pair, length);
> + }
> +}
> +
> static int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished)
> {
> int ret, val;
> - int pair_a, pair_b, pair_c, pair_d;
>
> *finished = false;
>
...
Powered by blists - more mailing lists