diff mbox series

[2/2] net/phy/mdio-mscc-miim: Move the setting of mii_bus structure members in mscc_miim_probe()

Message ID fe3ecdd2-a011-e4ed-5ef2-c3a8a02b343c@web.de
State Deferred
Delegated to: David Miller
Headers show
Series net/phy/mdio-mscc-miim: Adjustments for mscc_miim_probe() | expand

Commit Message

Markus Elfring Sept. 20, 2019, 7:03 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 20 Sep 2019 20:42:42 +0200

Move the modification of some members in the data structure “mii_bus”
for the local variable “bus” directly before the call of
the function “of_mdiobus_register” so that this change will be performed
only after previous resource allocations succeeded.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/phy/mdio-mscc-miim.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

--
2.23.0

Comments

Andrew Lunn Sept. 20, 2019, 7:13 p.m. UTC | #1
On Fri, Sep 20, 2019 at 09:03:57PM +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 20 Sep 2019 20:42:42 +0200
> 
> Move the modification of some members in the data structure “mii_bus”
> for the local variable “bus” directly before the call of
> the function “of_mdiobus_register” so that this change will be performed
> only after previous resource allocations succeeded.

Hi Markus

I'm not sure it is worth making this change. The resource allocations
succeeds 99.9999% of the time. It is a chunk of MMIO, not some gpio,
or i2c device which might give us EPROBE_DEFERRED. So we are not
wasting anything in reality.

	Andrew
diff mbox series

Patch

diff --git a/drivers/net/phy/mdio-mscc-miim.c b/drivers/net/phy/mdio-mscc-miim.c
index b36fe81b6e6d..c46e0c78402e 100644
--- a/drivers/net/phy/mdio-mscc-miim.c
+++ b/drivers/net/phy/mdio-mscc-miim.c
@@ -123,13 +123,6 @@  static int mscc_miim_probe(struct platform_device *pdev)
 	if (!bus)
 		return -ENOMEM;

-	bus->name = "mscc_miim";
-	bus->read = mscc_miim_read;
-	bus->write = mscc_miim_write;
-	bus->reset = mscc_miim_reset;
-	snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev));
-	bus->parent = &pdev->dev;
-
 	dev = bus->priv;
 	dev->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(dev->regs)) {
@@ -143,6 +136,12 @@  static int mscc_miim_probe(struct platform_device *pdev)
 		return PTR_ERR(dev->phy_regs);
 	}

+	bus->name = "mscc_miim";
+	bus->read = mscc_miim_read;
+	bus->write = mscc_miim_write;
+	bus->reset = mscc_miim_reset;
+	snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev));
+	bus->parent = &pdev->dev;
 	ret = of_mdiobus_register(bus, pdev->dev.of_node);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret);