All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] emaclite: improve error handling and minor cleanup
@ 2022-04-29 19:49 Radhey Shyam Pandey
  2022-04-29 19:49 ` [PATCH net v2 1/2] net: emaclite: Don't advertise 1000BASE-T and do auto negotiation Radhey Shyam Pandey
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Radhey Shyam Pandey @ 2022-04-29 19:49 UTC (permalink / raw)
  To: davem, kuba, pabeni, michal.simek, andrew
  Cc: netdev, linux-kernel, git, Radhey Shyam Pandey

This patchset does error handling for of_address_to_resource() and also
removes "Don't advertise 1000BASE-T" and auto negotiation.


Changes for v2:
- Added Andrew's reviewed by tag in 1/2 patch.
- Move ret to down to align with reverse xmas tree style in 2/2 patch.
- Also add fixes tag in 2/2 patch.
- Specify tree name in subject prefix.

Shravya Kumbham (2):
  net: emaclite: Don't advertise 1000BASE-T and do auto negotiation
  net: emaclite: Add error handling for of_address_to_resource()

 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 30 +++++++++++----------------
 1 file changed, 12 insertions(+), 18 deletions(-)

-- 
2.7.4


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

* [PATCH net v2 1/2] net: emaclite: Don't advertise 1000BASE-T and do auto negotiation
  2022-04-29 19:49 [PATCH net v2 0/2] emaclite: improve error handling and minor cleanup Radhey Shyam Pandey
@ 2022-04-29 19:49 ` Radhey Shyam Pandey
  2022-04-29 19:49 ` [PATCH net v2 2/2] net: emaclite: Add error handling for of_address_to_resource() Radhey Shyam Pandey
  2022-04-30  2:03 ` [PATCH net v2 0/2] emaclite: improve error handling and minor cleanup Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Radhey Shyam Pandey @ 2022-04-29 19:49 UTC (permalink / raw)
  To: davem, kuba, pabeni, michal.simek, andrew
  Cc: netdev, linux-kernel, git, Shravya Kumbham, Radhey Shyam Pandey

From: Shravya Kumbham <shravya.kumbham@xilinx.com>

In xemaclite_open() function we are setting the max speed of
emaclite to 100Mb using phy_set_max_speed() function so,
there is no need to write the advertising registers to stop
giga-bit speed and the phy_start() function starts the
auto-negotiation so, there is no need to handle it separately
using advertising registers. Remove the phy_read and phy_write
of advertising registers in xemaclite_open() function.

Signed-off-by: Shravya Kumbham <shravya.kumbham@xilinx.com>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
Changes for v2:
Added Andrew's Reviewed-by tag.
---
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 7a86ae82fcc1..f9cf86e26936 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -907,8 +907,6 @@ static int xemaclite_open(struct net_device *dev)
 	xemaclite_disable_interrupts(lp);
 
 	if (lp->phy_node) {
-		u32 bmcr;
-
 		lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node,
 					     xemaclite_adjust_link, 0,
 					     PHY_INTERFACE_MODE_MII);
@@ -919,19 +917,6 @@ static int xemaclite_open(struct net_device *dev)
 
 		/* EmacLite doesn't support giga-bit speeds */
 		phy_set_max_speed(lp->phy_dev, SPEED_100);
-
-		/* Don't advertise 1000BASE-T Full/Half duplex speeds */
-		phy_write(lp->phy_dev, MII_CTRL1000, 0);
-
-		/* Advertise only 10 and 100mbps full/half duplex speeds */
-		phy_write(lp->phy_dev, MII_ADVERTISE, ADVERTISE_ALL |
-			  ADVERTISE_CSMA);
-
-		/* Restart auto negotiation */
-		bmcr = phy_read(lp->phy_dev, MII_BMCR);
-		bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
-		phy_write(lp->phy_dev, MII_BMCR, bmcr);
-
 		phy_start(lp->phy_dev);
 	}
 
-- 
2.7.4


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

* [PATCH net v2 2/2] net: emaclite: Add error handling for of_address_to_resource()
  2022-04-29 19:49 [PATCH net v2 0/2] emaclite: improve error handling and minor cleanup Radhey Shyam Pandey
  2022-04-29 19:49 ` [PATCH net v2 1/2] net: emaclite: Don't advertise 1000BASE-T and do auto negotiation Radhey Shyam Pandey
@ 2022-04-29 19:49 ` Radhey Shyam Pandey
  2022-04-30  2:03 ` [PATCH net v2 0/2] emaclite: improve error handling and minor cleanup Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Radhey Shyam Pandey @ 2022-04-29 19:49 UTC (permalink / raw)
  To: davem, kuba, pabeni, michal.simek, andrew
  Cc: netdev, linux-kernel, git, Shravya Kumbham, Radhey Shyam Pandey

From: Shravya Kumbham <shravya.kumbham@xilinx.com>

check the return value of of_address_to_resource() and also add
missing of_node_put() for np and npp nodes.

Fixes: e0a3bc65448c ("net: emaclite: Support multiple phys connected to one MDIO bus")
Addresses-Coverity: Event check_return value.
Signed-off-by: Shravya Kumbham <shravya.kumbham@xilinx.com>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
---
Changes for v2:
Move ret further down to align with RXT as suggested by Andrew.
Add Fixes tag.
---
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index f9cf86e26936..016a9c4f2c6c 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -803,10 +803,10 @@ static int xemaclite_mdio_write(struct mii_bus *bus, int phy_id, int reg,
 static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
 {
 	struct mii_bus *bus;
-	int rc;
 	struct resource res;
 	struct device_node *np = of_get_parent(lp->phy_node);
 	struct device_node *npp;
+	int rc, ret;
 
 	/* Don't register the MDIO bus if the phy_node or its parent node
 	 * can't be found.
@@ -816,8 +816,14 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
 		return -ENODEV;
 	}
 	npp = of_get_parent(np);
-
-	of_address_to_resource(npp, 0, &res);
+	ret = of_address_to_resource(npp, 0, &res);
+	of_node_put(npp);
+	if (ret) {
+		dev_err(dev, "%s resource error!\n",
+			dev->of_node->full_name);
+		of_node_put(np);
+		return ret;
+	}
 	if (lp->ndev->mem_start != res.start) {
 		struct phy_device *phydev;
 
@@ -827,6 +833,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
 				 "MDIO of the phy is not registered yet\n");
 		else
 			put_device(&phydev->mdio.dev);
+		of_node_put(np);
 		return 0;
 	}
 
@@ -839,6 +846,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
 	bus = mdiobus_alloc();
 	if (!bus) {
 		dev_err(dev, "Failed to allocate mdiobus\n");
+		of_node_put(np);
 		return -ENOMEM;
 	}
 
@@ -851,6 +859,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
 	bus->parent = dev;
 
 	rc = of_mdiobus_register(bus, np);
+	of_node_put(np);
 	if (rc) {
 		dev_err(dev, "Failed to register mdio bus.\n");
 		goto err_register;
-- 
2.7.4


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

* Re: [PATCH net v2 0/2] emaclite: improve error handling and minor cleanup
  2022-04-29 19:49 [PATCH net v2 0/2] emaclite: improve error handling and minor cleanup Radhey Shyam Pandey
  2022-04-29 19:49 ` [PATCH net v2 1/2] net: emaclite: Don't advertise 1000BASE-T and do auto negotiation Radhey Shyam Pandey
  2022-04-29 19:49 ` [PATCH net v2 2/2] net: emaclite: Add error handling for of_address_to_resource() Radhey Shyam Pandey
@ 2022-04-30  2:03 ` Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2022-04-30  2:03 UTC (permalink / raw)
  To: Radhey Shyam Pandey
  Cc: davem, pabeni, michal.simek, andrew, netdev, linux-kernel, git

On Sat, 30 Apr 2022 01:19:28 +0530 Radhey Shyam Pandey wrote:
> This patchset does error handling for of_address_to_resource() and also
> removes "Don't advertise 1000BASE-T" and auto negotiation.

Appears not to apply to net.

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

end of thread, other threads:[~2022-04-30  2:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-29 19:49 [PATCH net v2 0/2] emaclite: improve error handling and minor cleanup Radhey Shyam Pandey
2022-04-29 19:49 ` [PATCH net v2 1/2] net: emaclite: Don't advertise 1000BASE-T and do auto negotiation Radhey Shyam Pandey
2022-04-29 19:49 ` [PATCH net v2 2/2] net: emaclite: Add error handling for of_address_to_resource() Radhey Shyam Pandey
2022-04-30  2:03 ` [PATCH net v2 0/2] emaclite: improve error handling and minor cleanup Jakub Kicinski

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.