From 848e691cf36a039f7a7cefac11df49230c71e806 Mon Sep 17 00:00:00 2001 From: Vivek Gautam Date: Thu, 13 Nov 2014 18:33:51 +0530 Subject: [PATCH RFC] phy: core: Use phy pointer with phy_lookup_table Signed-off-by: Vivek Gautam --- drivers/phy/phy-core.c | 31 +++++++++---------------------- include/linux/phy/phy.h | 1 + 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 0b279d3..a4a67e2 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -99,6 +99,7 @@ int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id) pl->phy_name = dev_name(phy->dev.parent); pl->dev_id = dev_id; pl->con_id = con_id; + pl->phy = phy; phy_register_lookup(pl); @@ -167,18 +168,10 @@ static struct phy *phy_find(struct device *dev, const char *con_id) } } - if (pl) { - struct class_dev_iter iter; - struct device *phy_dev; - - class_dev_iter_init(&iter, phy_class, NULL, NULL); - while ((phy_dev = class_dev_iter_next(&iter))) { - if (!strcmp(dev_name(phy_dev->parent), pl->phy_name)) { - phy = to_phy(phy_dev); - break; - } - } - class_dev_iter_exit(&iter); + if (pl && pl->phy) { + phy = pl->phy; + if (!try_module_get(phy->ops->owner)) + phy = ERR_PTR(-EPROBE_DEFER); } return phy; } @@ -549,7 +542,6 @@ EXPORT_SYMBOL_GPL(of_phy_simple_xlate); */ struct phy *phy_get(struct device *dev, const char *string) { - int index = 0; struct phy *phy; if (string == NULL) { @@ -557,19 +549,14 @@ struct phy *phy_get(struct device *dev, const char *string) return ERR_PTR(-EINVAL); } - if (dev->of_node) { - index = of_property_match_string(dev->of_node, "phy-names", - string); - phy = _of_phy_get(dev->of_node, index); - } else { + if (dev->of_node) + phy = of_phy_get(dev->of_node, string); + else phy = phy_find(dev, string); - } + if (IS_ERR(phy)) return phy; - if (!try_module_get(phy->ops->owner)) - return ERR_PTR(-EPROBE_DEFER); - get_device(&phy->dev); return phy; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index d983051..4b21d72 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -88,6 +88,7 @@ struct phy_lookup { const char *phy_name; const char *dev_id; const char *con_id; + struct phy *phy; }; #define PHY_LOOKUP(a, b, c) \ -- 1.7.10.4