netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: netdev <netdev@vger.kernel.org>, Andrew Lunn <andrew@lunn.ch>
Subject: [RFC PATCH net-next 12/24] of: phy: Only register a phy device for phys
Date: Mon,  4 Jan 2016 18:36:50 +0100	[thread overview]
Message-ID: <1451929022-5580-13-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1451929022-5580-1-git-send-email-andrew@lunn.ch>

We will soon support devices other than phys on the mdio bus. Look at
a child's compatibility string to determine if it is a phy, before
registering a phy device.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/of/of_mdio.c | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 25bace4db85a..75a415d7cf8c 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -114,6 +114,31 @@ int of_mdio_parse_addr(struct device *dev, const struct device_node *np)
 }
 EXPORT_SYMBOL(of_mdio_parse_addr);
 
+/*
+ * Return true if the child node is for a phy. It must either:
+ * o Compatible string of "ethernet-phy-idX.X"
+ * o Compatible string of "ethernet-phy-ieee802.3-c45"
+ * o No compatibility string
+ *
+ * A device which is not a phy is expected to have a compatible string
+ * indicating what sort of device it is.
+ */
+static bool of_mdiobus_child_is_phy(struct device_node *child)
+{
+	u32 phy_id;
+
+	if (of_get_phy_id(child, &phy_id) != -EINVAL)
+		return true;
+
+	if (of_device_is_compatible(child, "ethernet-phy-ieee802.3-c45"))
+		return true;
+
+	if (!of_find_property(child, "compatible", NULL))
+		return true;
+
+	return false;
+}
+
 /**
  * of_mdiobus_register - Register mii_bus and create PHYs from the device tree
  * @mdio: pointer to mii_bus structure
@@ -145,7 +170,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
 	if (rc)
 		return rc;
 
-	/* Loop over the child nodes and register a phy_device for each one */
+	/* Loop over the child nodes and register a phy_device for each phy */
 	for_each_available_child_of_node(np, child) {
 		addr = of_mdio_parse_addr(&mdio->dev, child);
 		if (addr < 0) {
@@ -153,9 +178,8 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
 			continue;
 		}
 
-		rc = of_mdiobus_register_phy(mdio, child, addr);
-		if (rc)
-			continue;
+		if (of_mdiobus_child_is_phy(child))
+			of_mdiobus_register_phy(mdio, child, addr);
 	}
 
 	if (!scanphys)
@@ -177,9 +201,8 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
 			dev_info(&mdio->dev, "scan phy %s at address %i\n",
 				 child->name, addr);
 
-			rc = of_mdiobus_register_phy(mdio, child, addr);
-			if (rc)
-				continue;
+			if (of_mdiobus_child_is_phy(child))
+				of_mdiobus_register_phy(mdio, child, addr);
 		}
 	}
 
-- 
2.6.4

  parent reply	other threads:[~2016-01-04 17:38 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-04 17:36 [RFC PATCH net-next 00/24] Support MDIO devices Andrew Lunn
2016-01-04 17:36 ` [RFC PATCH net-next 01/24] phy: Consistently use addr for address on an MII bus Andrew Lunn
2016-01-04 20:01   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 02/24] mdio: Move mdiobus_read/write operatings into mdio.h Andrew Lunn
2016-01-04 20:02   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 03/24] phy: Use phy_read() instead of mdiobus_read() Andrew Lunn
2016-01-04 20:07   ` Florian Fainelli
2016-01-05 13:40     ` Andrew Lunn
2016-01-04 17:36 ` [RFC PATCH net-next 04/24] phy: Add phydev_err() and phydev_dbg() macros Andrew Lunn
2016-01-04 20:08   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 05/24] phy: add phydev_name() macro Andrew Lunn
2016-01-04 17:48   ` Joe Perches
2016-01-04 17:36 ` [RFC PATCH net-next 06/24] net: dnet: Use phy_find_first() helper Andrew Lunn
2016-01-04 20:08   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 07/24] phy: phy_{read|write}_mmd_indirect: get addr from phydev Andrew Lunn
2016-01-04 20:10   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 08/24] phy: Centralise print about attached phy Andrew Lunn
2016-01-04 20:15   ` Florian Fainelli
2016-01-04 21:16     ` Andrew Lunn
2016-01-04 17:36 ` [RFC PATCH net-next 09/24] phy: mdio-octeon: Use devm_mdiobus_alloc_size() Andrew Lunn
2016-01-04 20:18   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 10/24] mdio: Move allocation of interrupts into core Andrew Lunn
2016-01-04 20:17   ` Florian Fainelli
2016-01-06 14:07   ` Shaohui Xie
2016-01-04 17:36 ` [RFC PATCH net-next 11/24] phy: Add an mdio_device structure Andrew Lunn
2016-01-05  1:53   ` Florian Fainelli
2016-01-04 17:36 ` Andrew Lunn [this message]
2016-01-04 20:01   ` [RFC PATCH net-next 12/24] of: phy: Only register a phy device for phys Florian Fainelli
2016-01-04 21:04     ` Andrew Lunn
2016-01-04 17:36 ` [RFC PATCH net-next 13/24] phy: Add API for {un{registering an mdio device to a bus Andrew Lunn
2016-01-05  1:55   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 14/24] phy_device: Move phy attributes into phy_device Andrew Lunn
2016-01-05  1:57   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 15/24] dsa: Register netdev before phy Andrew Lunn
2016-01-05  1:59   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 16/24] phy: Move PHY PM operations into phy_device Andrew Lunn
2016-01-05  2:00   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 17/24] phy: Centralize setting driver module owner Andrew Lunn
2016-01-05  2:00   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 18/24] phy: Move phy specific bus match into phy_device Andrew Lunn
2016-01-05  2:01   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 19/24] mdio_bus: Generalise of_mdiobus_link_phydev() Andrew Lunn
2016-01-05  2:01   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 20/24] mdio_bus: Add comment to mdiobus_scan() and __mdiobus_register() Andrew Lunn
2016-01-05  2:02   ` Florian Fainelli
2016-01-04 17:36 ` [RFC PATCH net-next 21/24] mdio: Add support for mdio drivers Andrew Lunn
2016-01-05  2:03   ` Florian Fainelli
2016-01-04 17:37 ` [RFC PATCH net-next 22/24] mdio: Abstract device_remove() and device_free() Andrew Lunn
2016-01-05  2:04   ` Florian Fainelli
2016-01-04 17:37 ` [RFC PATCH net-next 23/24] mdio: mdio-nop: Dummy driver to testing Andrew Lunn
2016-01-04 17:37 ` [RFC PATCH net-next 24/24] Add linux,mdio-nop support for testing Andrew Lunn
2016-01-05  2:21 ` [RFC PATCH net-next 00/24] Support MDIO devices Florian Fainelli
2016-01-05  2:57   ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1451929022-5580-13-git-send-email-andrew@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).