All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] net: davinci_emac: Restore the internal MDIO accessors return values
@ 2016-08-20  8:56 Karl Beldan
  2016-08-22 17:47 ` Joe Hershberger
  2016-08-23  2:28 ` [U-Boot] " Joe Hershberger
  0 siblings, 2 replies; 3+ messages in thread
From: Karl Beldan @ 2016-08-20  8:56 UTC (permalink / raw)
  To: u-boot

The spatch series converting legacy drivers from miiphy_register to
mdio_register changed the return convention of the davinci_emac internal
MDIO accessors, making the internal code relying on it misbehaving:
no mdiodev get registered and U-Boot crashes when using net cmds in the
context of the old legacy net API.

ATM davinci_emac_initialize and cpu_eth_init don't return a proper value
in that case but fixing them would not avoid the crash.

This change is just a follow-up to the spatch pass, the MDIO accessors
of the mdiodev introduced by the spatch pass retain their proper values.

Signed-off-by: Karl Beldan <karl.beldan+oss@gmail.com>
---
 drivers/net/davinci_emac.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index ca457b8..3103441 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -243,10 +243,10 @@ int davinci_eth_phy_read(u_int8_t phy_addr, u_int8_t reg_num, u_int16_t *data)
 
 	if (tmp & MDIO_USERACCESS0_ACK) {
 		*data = tmp & 0xffff;
-		return 0;
+		return 1;
 	}
 
-	return -EIO;
+	return 0;
 }
 
 /* Write to a PHY register via MDIO inteface. Blocks until operation is complete. */
@@ -267,7 +267,7 @@ int davinci_eth_phy_write(u_int8_t phy_addr, u_int8_t reg_num, u_int16_t data)
 	while (readl(&adap_mdio->USERACCESS0) & MDIO_USERACCESS0_GO)
 		;
 
-	return 0;
+	return 1;
 }
 
 /* PHY functions for a generic PHY */
@@ -394,15 +394,14 @@ static int davinci_mii_phy_read(struct mii_dev *bus, int addr, int devad,
 {
 	unsigned short value = 0;
 	int retval = davinci_eth_phy_read(addr, reg, &value);
-	if (retval < 0)
-		return retval;
-	return value;
+
+	return retval ? value : -EIO;
 }
 
 static int davinci_mii_phy_write(struct mii_dev *bus, int addr, int devad,
 				 int reg, u16 value)
 {
-	return davinci_eth_phy_write(addr, reg, value);
+	return davinci_eth_phy_write(addr, reg, value) ? 0 : 1;
 }
 #endif
 
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] net: davinci_emac: Restore the internal MDIO accessors return values
  2016-08-20  8:56 [U-Boot] [PATCH] net: davinci_emac: Restore the internal MDIO accessors return values Karl Beldan
@ 2016-08-22 17:47 ` Joe Hershberger
  2016-08-23  2:28 ` [U-Boot] " Joe Hershberger
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Hershberger @ 2016-08-22 17:47 UTC (permalink / raw)
  To: u-boot

On Sat, Aug 20, 2016 at 3:56 AM, Karl Beldan <karl.beldan@gmail.com> wrote:
> The spatch series converting legacy drivers from miiphy_register to
> mdio_register changed the return convention of the davinci_emac internal
> MDIO accessors, making the internal code relying on it misbehaving:
> no mdiodev get registered and U-Boot crashes when using net cmds in the
> context of the old legacy net API.
>
> ATM davinci_emac_initialize and cpu_eth_init don't return a proper value
> in that case but fixing them would not avoid the crash.
>
> This change is just a follow-up to the spatch pass, the MDIO accessors
> of the mdiodev introduced by the spatch pass retain their proper values.
>
> Signed-off-by: Karl Beldan <karl.beldan+oss@gmail.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] net: davinci_emac: Restore the internal MDIO accessors return values
  2016-08-20  8:56 [U-Boot] [PATCH] net: davinci_emac: Restore the internal MDIO accessors return values Karl Beldan
  2016-08-22 17:47 ` Joe Hershberger
@ 2016-08-23  2:28 ` Joe Hershberger
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Hershberger @ 2016-08-23  2:28 UTC (permalink / raw)
  To: u-boot

Hi karl,

https://patchwork.ozlabs.org/patch/661116/ was applied to u-boot-net.git.

Thanks!
-Joe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-23  2:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-20  8:56 [U-Boot] [PATCH] net: davinci_emac: Restore the internal MDIO accessors return values Karl Beldan
2016-08-22 17:47 ` Joe Hershberger
2016-08-23  2:28 ` [U-Boot] " Joe Hershberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.