Thread (25 messages) flat view 25 messages, 2 authors, 2016-06-06
STALE3720d

[PATCH 05/22] net: cpsw-phy-sel: Use of_device_match()

From: Thierry Reding <hidden>
Date: 2016-06-06 08:40:52
Also in: lkml
Subsystem: networking drivers, the rest, ti ethernet switch driver (cpsw) · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

From: Thierry Reding <redacted>

This driver uses bus_find_device() to go through every platform device
and match using the driver and device tree node. It's more efficient to
use driver_find_device() to iterate over all devices associated with a
particular driver, in which case the matching is reduced to the device
tree node and can be done using the common implementation.

Signed-off-by: Thierry Reding <redacted>
---
 drivers/net/ethernet/ti/cpsw-phy-sel.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw-phy-sel.c b/drivers/net/ethernet/ti/cpsw-phy-sel.c
index c3e85acfdc70..bb0de7744681 100644
--- a/drivers/net/ethernet/ti/cpsw-phy-sel.c
+++ b/drivers/net/ethernet/ti/cpsw-phy-sel.c
@@ -143,12 +143,6 @@ static void cpsw_gmii_sel_dra7xx(struct cpsw_phy_sel_priv *priv,
 }
 
 static struct platform_driver cpsw_phy_sel_driver;
-static int match(struct device *dev, void *data)
-{
-	struct device_node *node = (struct device_node *)data;
-	return dev->of_node == node &&
-		dev->driver == &cpsw_phy_sel_driver.driver;
-}
 
 void cpsw_phy_sel(struct device *dev, phy_interface_t phy_mode, int slave)
 {
@@ -161,7 +155,8 @@ void cpsw_phy_sel(struct device *dev, phy_interface_t phy_mode, int slave)
 		return;
 	}
 
-	dev = bus_find_device(&platform_bus_type, NULL, node, match);
+	dev = driver_find_device(&cpsw_phy_sel_driver.driver, NULL, node,
+				 of_device_match);
 	priv = dev_get_drvdata(dev);
 
 	priv->cpsw_phy_sel(priv, phy_mode, slave);
-- 
2.8.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help