public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Simon Horman <horms@kernel.org>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [net-next PATCH v3 2/4] net: phy: at803x: refactor qca808x cable test get status function
Date: Thu, 4 Jan 2024 14:15:59 +0100	[thread overview]
Message-ID: <6596af8f.5d0a0220.1b372.4858@mx.google.com> (raw)
In-Reply-To: <20240104130337.GG31813@kernel.org>

On Thu, Jan 04, 2024 at 01:03:37PM +0000, Simon Horman wrote:
> 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@gmail.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.
>

In theory it would trigger a warning for the switch case not handled?

But yes I will add a default case.

> > +
> > +	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;
> >  
> 
> ...

-- 
	Ansuel

  reply	other threads:[~2024-01-04 13:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-03 12:46 [net-next PATCH v3 0/4] net: phy: at803x: even more generalization Christian Marangi
2024-01-03 12:46 ` [net-next PATCH v3 1/4] net: phy: at803x: generalize cdt fault length function Christian Marangi
2024-01-04 13:07   ` Simon Horman
2024-01-03 12:46 ` [net-next PATCH v3 2/4] net: phy: at803x: refactor qca808x cable test get status function Christian Marangi
2024-01-04 13:03   ` Simon Horman
2024-01-04 13:15     ` Christian Marangi [this message]
2024-01-03 12:46 ` [net-next PATCH v3 3/4] net: phy: at803x: add support for cdt cross short test for qca808x Christian Marangi
2024-01-03 12:46 ` [net-next PATCH v3 4/4] net: phy: at803x: make read_status more generic Christian Marangi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6596af8f.5d0a0220.1b372.4858@mx.google.com \
    --to=ansuelsmth@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox