Skip to content

Commit 45c77fb

Browse files
author
Paolo Abeni
committed
Merge branch 'emaclite-improve-error-handling-and-minor-cleanup'
Radhey Shyam Pandey says: ==================== emaclite: improve error handling and minor cleanup This patchset does error handling for of_address_to_resource() and also removes "Don't advertise 1000BASE-T" and auto negotiation. Changes for v3: - Resolve git apply conflicts for 2/2 patch. 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. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 7939693 + 7a6bc33 commit 45c77fb

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

drivers/net/ethernet/xilinx/xilinx_emaclite.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -823,10 +823,10 @@ static int xemaclite_mdio_write(struct mii_bus *bus, int phy_id, int reg,
823823
static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
824824
{
825825
struct mii_bus *bus;
826-
int rc;
827826
struct resource res;
828827
struct device_node *np = of_get_parent(lp->phy_node);
829828
struct device_node *npp;
829+
int rc, ret;
830830

831831
/* Don't register the MDIO bus if the phy_node or its parent node
832832
* can't be found.
@@ -836,8 +836,14 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
836836
return -ENODEV;
837837
}
838838
npp = of_get_parent(np);
839-
840-
of_address_to_resource(npp, 0, &res);
839+
ret = of_address_to_resource(npp, 0, &res);
840+
of_node_put(npp);
841+
if (ret) {
842+
dev_err(dev, "%s resource error!\n",
843+
dev->of_node->full_name);
844+
of_node_put(np);
845+
return ret;
846+
}
841847
if (lp->ndev->mem_start != res.start) {
842848
struct phy_device *phydev;
843849
phydev = of_phy_find_device(lp->phy_node);
@@ -846,6 +852,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
846852
"MDIO of the phy is not registered yet\n");
847853
else
848854
put_device(&phydev->mdio.dev);
855+
of_node_put(np);
849856
return 0;
850857
}
851858

@@ -858,6 +865,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
858865
bus = mdiobus_alloc();
859866
if (!bus) {
860867
dev_err(dev, "Failed to allocate mdiobus\n");
868+
of_node_put(np);
861869
return -ENOMEM;
862870
}
863871

@@ -870,6 +878,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
870878
bus->parent = dev;
871879

872880
rc = of_mdiobus_register(bus, np);
881+
of_node_put(np);
873882
if (rc) {
874883
dev_err(dev, "Failed to register mdio bus.\n");
875884
goto err_register;
@@ -926,8 +935,6 @@ static int xemaclite_open(struct net_device *dev)
926935
xemaclite_disable_interrupts(lp);
927936

928937
if (lp->phy_node) {
929-
u32 bmcr;
930-
931938
lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node,
932939
xemaclite_adjust_link, 0,
933940
PHY_INTERFACE_MODE_MII);
@@ -938,19 +945,6 @@ static int xemaclite_open(struct net_device *dev)
938945

939946
/* EmacLite doesn't support giga-bit speeds */
940947
phy_set_max_speed(lp->phy_dev, SPEED_100);
941-
942-
/* Don't advertise 1000BASE-T Full/Half duplex speeds */
943-
phy_write(lp->phy_dev, MII_CTRL1000, 0);
944-
945-
/* Advertise only 10 and 100mbps full/half duplex speeds */
946-
phy_write(lp->phy_dev, MII_ADVERTISE, ADVERTISE_ALL |
947-
ADVERTISE_CSMA);
948-
949-
/* Restart auto negotiation */
950-
bmcr = phy_read(lp->phy_dev, MII_BMCR);
951-
bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
952-
phy_write(lp->phy_dev, MII_BMCR, bmcr);
953-
954948
phy_start(lp->phy_dev);
955949
}
956950

0 commit comments

Comments
 (0)