diff mbox

[RFC,net-next,4/8] net: mv643xx_eth: Handle Ethernet switches as PHY devices

Message ID 1430359064-23454-5-git-send-email-f.fainelli@gmail.com
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Florian Fainelli April 30, 2015, 1:57 a.m. UTC
In preparation for allowing Ethernet switches to be real PHY devices,
adjust the mv643x_eth driver to do two things in case such a PHY device
is detected:

- do not program the PHY polling unit to watch for this PHY since it
  would yield inconsistent results, reading from the pseudo-PHY address,
  not regular MII_BMSR registers

- force the link indication since this is the CPU-facing port of the
  switch which is always up and running

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/marvell/mv643xx_eth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

David Miller May 4, 2015, 2:06 a.m. UTC | #1
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Wed, 29 Apr 2015 18:57:40 -0700

> @@ -2321,7 +2321,7 @@ static void port_start(struct mv643xx_eth_private *mp)
>  	wrlp(mp, PORT_SERIAL_CONTROL, pscr);
>  
>  	pscr |= DO_NOT_FORCE_LINK_FAIL;
> -	if (mp->phy == NULL)
> +	if (mp->phy == NULL || (mp->phy && phy_is_ethswitch(mp->phy)))
>  		pscr |= FORCE_LINK_PASS;

Maybe it looks clearer to you in this form, but the C language
guarentees that:

	if (!ptr || ptr->foo)

will not perform a NULL pointer deref.

So I'm pretty sure you could simply this statement to:

	if (mp->phy == NULL || phy_is_ethswitch(mp->phy))
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 1c75829eb166..72ce27562d6f 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2321,7 +2321,7 @@  static void port_start(struct mv643xx_eth_private *mp)
 	wrlp(mp, PORT_SERIAL_CONTROL, pscr);
 
 	pscr |= DO_NOT_FORCE_LINK_FAIL;
-	if (mp->phy == NULL)
+	if (mp->phy == NULL || (mp->phy && phy_is_ethswitch(mp->phy)))
 		pscr |= FORCE_LINK_PASS;
 	wrlp(mp, PORT_SERIAL_CONTROL, pscr);
 
@@ -3101,7 +3101,7 @@  static int mv643xx_eth_probe(struct platform_device *pdev)
 					 PHY_INTERFACE_MODE_GMII);
 		if (!mp->phy)
 			err = -ENODEV;
-		else
+		else if (!phy_is_ethswitch(mp->phy))
 			phy_addr_set(mp, mp->phy->addr);
 	} else if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
 		mp->phy = phy_scan(mp, pd->phy_addr);