aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/phy/phy-core.c
diff options
context:
space:
mode:
authorKishon Vijay Abraham I <kishon@ti.com>2014-07-14 06:25:02 -0400
committerKishon Vijay Abraham I <kishon@ti.com>2014-07-22 03:16:11 -0400
commitf0ed817638b59aa927f1f7e9564dd8796b18dc4f (patch)
tree8d33a1dc9b780a2413565d80a19b649b056fb4cd /drivers/phy/phy-core.c
parent2a4c37016ca96e413cd352985d3a0db8cfb7716c (diff)
phy: core: Let node ptr of PHY point to PHY and not of PHY provider
In case of multi-phy PHY providers, each PHY should be modeled as a sub node of the PHY provider. Then each PHY will have a different node pointer (node pointer of sub node) than that of PHY provider. Added this provision in the PHY core. Also fixed all drivers to use the updated API. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Acked-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/phy/phy-core.c')
-rw-r--r--drivers/phy/phy-core.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 527e744a3809..ff5eec5af817 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -415,13 +415,20 @@ struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args
415 struct phy *phy; 415 struct phy *phy;
416 struct class_dev_iter iter; 416 struct class_dev_iter iter;
417 struct device_node *node = dev->of_node; 417 struct device_node *node = dev->of_node;
418 struct device_node *child;
418 419
419 class_dev_iter_init(&iter, phy_class, NULL, NULL); 420 class_dev_iter_init(&iter, phy_class, NULL, NULL);
420 while ((dev = class_dev_iter_next(&iter))) { 421 while ((dev = class_dev_iter_next(&iter))) {
421 phy = to_phy(dev); 422 phy = to_phy(dev);
422 if (node != phy->dev.of_node) 423 if (node != phy->dev.of_node) {
424 for_each_child_of_node(node, child) {
425 if (child == phy->dev.of_node)
426 goto phy_found;
427 }
423 continue; 428 continue;
429 }
424 430
431phy_found:
425 class_dev_iter_exit(&iter); 432 class_dev_iter_exit(&iter);
426 return phy; 433 return phy;
427 } 434 }
@@ -579,13 +586,15 @@ EXPORT_SYMBOL_GPL(devm_of_phy_get);
579/** 586/**
580 * phy_create() - create a new phy 587 * phy_create() - create a new phy
581 * @dev: device that is creating the new phy 588 * @dev: device that is creating the new phy
589 * @node: device node of the phy
582 * @ops: function pointers for performing phy operations 590 * @ops: function pointers for performing phy operations
583 * @init_data: contains the list of PHY consumers or NULL 591 * @init_data: contains the list of PHY consumers or NULL
584 * 592 *
585 * Called to create a phy using phy framework. 593 * Called to create a phy using phy framework.
586 */ 594 */
587struct phy *phy_create(struct device *dev, const struct phy_ops *ops, 595struct phy *phy_create(struct device *dev, struct device_node *node,
588 struct phy_init_data *init_data) 596 const struct phy_ops *ops,
597 struct phy_init_data *init_data)
589{ 598{
590 int ret; 599 int ret;
591 int id; 600 int id;
@@ -620,7 +629,7 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
620 629
621 phy->dev.class = phy_class; 630 phy->dev.class = phy_class;
622 phy->dev.parent = dev; 631 phy->dev.parent = dev;
623 phy->dev.of_node = dev->of_node; 632 phy->dev.of_node = node ?: dev->of_node;
624 phy->id = id; 633 phy->id = id;
625 phy->ops = ops; 634 phy->ops = ops;
626 phy->init_data = init_data; 635 phy->init_data = init_data;
@@ -656,6 +665,7 @@ EXPORT_SYMBOL_GPL(phy_create);
656/** 665/**
657 * devm_phy_create() - create a new phy 666 * devm_phy_create() - create a new phy
658 * @dev: device that is creating the new phy 667 * @dev: device that is creating the new phy
668 * @node: device node of the phy
659 * @ops: function pointers for performing phy operations 669 * @ops: function pointers for performing phy operations
660 * @init_data: contains the list of PHY consumers or NULL 670 * @init_data: contains the list of PHY consumers or NULL
661 * 671 *
@@ -664,8 +674,9 @@ EXPORT_SYMBOL_GPL(phy_create);
664 * On driver detach, release function is invoked on the devres data, 674 * On driver detach, release function is invoked on the devres data,
665 * then, devres data is freed. 675 * then, devres data is freed.
666 */ 676 */
667struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops, 677struct phy *devm_phy_create(struct device *dev, struct device_node *node,
668 struct phy_init_data *init_data) 678 const struct phy_ops *ops,
679 struct phy_init_data *init_data)
669{ 680{
670 struct phy **ptr, *phy; 681 struct phy **ptr, *phy;
671 682
@@ -673,7 +684,7 @@ struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
673 if (!ptr) 684 if (!ptr)
674 return ERR_PTR(-ENOMEM); 685 return ERR_PTR(-ENOMEM);
675 686
676 phy = phy_create(dev, ops, init_data); 687 phy = phy_create(dev, node, ops, init_data);
677 if (!IS_ERR(phy)) { 688 if (!IS_ERR(phy)) {
678 *ptr = phy; 689 *ptr = phy;
679 devres_add(dev, ptr); 690 devres_add(dev, ptr);