* [PATCH] phy: remove the old lookup method
@ 2014-11-22 8:27 Kishon Vijay Abraham I
2014-11-22 8:33 ` Kishon Vijay Abraham I
2014-11-28 11:57 ` Linus Walleij
0 siblings, 2 replies; 5+ messages in thread
From: Kishon Vijay Abraham I @ 2014-11-22 8:27 UTC (permalink / raw)
To: heikki.krogerus, gautam.vivek, andrew.kim, linus.walleij,
swarren, thierry.reding, gnurou
Cc: kishon, linux-kernel
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
The users of the old method are now converted to the new one.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
[ kishon@ti.com : made phy-berlin-usb.c and phy-miphy28lp.c to use the updated
devm_phy_create API.]
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
Two new PHY drivers phy-berlin-usb.c and phy-miphy28lp.c were added which was using the old
devm_phy_create signature. Made it to use the new devm_phy_create signatiure.
drivers/phy/phy-bcm-kona-usb2.c | 2 +-
drivers/phy/phy-berlin-sata.c | 2 +-
drivers/phy/phy-berlin-usb.c | 3 +--
drivers/phy/phy-core.c | 49 +++-------------------------------
drivers/phy/phy-exynos-dp-video.c | 2 +-
drivers/phy/phy-exynos-mipi-video.c | 2 +-
drivers/phy/phy-exynos5-usbdrd.c | 3 +--
drivers/phy/phy-exynos5250-sata.c | 2 +-
drivers/phy/phy-hix5hd2-sata.c | 2 +-
drivers/phy/phy-miphy28lp.c | 2 +-
drivers/phy/phy-miphy365x.c | 2 +-
drivers/phy/phy-mvebu-sata.c | 2 +-
drivers/phy/phy-omap-usb2.c | 2 +-
drivers/phy/phy-qcom-apq8064-sata.c | 3 +--
drivers/phy/phy-qcom-ipq806x-sata.c | 3 +--
drivers/phy/phy-rcar-gen2.c | 2 +-
drivers/phy/phy-samsung-usb2.c | 3 +--
drivers/phy/phy-spear1310-miphy.c | 2 +-
drivers/phy/phy-spear1340-miphy.c | 2 +-
drivers/phy/phy-stih407-usb.c | 2 +-
drivers/phy/phy-stih41x-usb.c | 2 +-
drivers/phy/phy-sun4i-usb.c | 2 +-
drivers/phy/phy-ti-pipe3.c | 2 +-
drivers/phy/phy-twl4030-usb.c | 2 +-
drivers/phy/phy-xgene.c | 2 +-
drivers/pinctrl/pinctrl-tegra-xusb.c | 4 +--
include/linux/phy/phy.h | 38 +++-----------------------
27 files changed, 34 insertions(+), 110 deletions(-)
diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
index c1e0ca3..ef2dc1a 100644
--- a/drivers/phy/phy-bcm-kona-usb2.c
+++ b/drivers/phy/phy-bcm-kona-usb2.c
@@ -117,7 +117,7 @@ static int bcm_kona_usb2_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, phy);
- gphy = devm_phy_create(dev, NULL, &ops, NULL);
+ gphy = devm_phy_create(dev, NULL, &ops);
if (IS_ERR(gphy))
return PTR_ERR(gphy);
diff --git a/drivers/phy/phy-berlin-sata.c b/drivers/phy/phy-berlin-sata.c
index 873e7a8..3e599dc 100644
--- a/drivers/phy/phy-berlin-sata.c
+++ b/drivers/phy/phy-berlin-sata.c
@@ -249,7 +249,7 @@ static int phy_berlin_sata_probe(struct platform_device *pdev)
if (!phy_desc)
return -ENOMEM;
- phy = devm_phy_create(dev, NULL, &phy_berlin_sata_ops, NULL);
+ phy = devm_phy_create(dev, NULL, &phy_berlin_sata_ops);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create PHY %d\n", phy_id);
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-berlin-usb.c b/drivers/phy/phy-berlin-usb.c
index f9f1306..c8a8d53 100644
--- a/drivers/phy/phy-berlin-usb.c
+++ b/drivers/phy/phy-berlin-usb.c
@@ -192,8 +192,7 @@ static int phy_berlin_usb_probe(struct platform_device *pdev)
priv->pll_divider = *((u32 *)match->data);
- priv->phy = devm_phy_create(&pdev->dev, NULL, &phy_berlin_usb_ops,
- NULL);
+ priv->phy = devm_phy_create(&pdev->dev, NULL, &phy_berlin_usb_ops);
if (IS_ERR(priv->phy)) {
dev_err(&pdev->dev, "failed to create PHY\n");
return PTR_ERR(priv->phy);
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index bc83077..a12d353 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -55,36 +55,6 @@ static int devm_phy_match(struct device *dev, void *res, void *match_data)
return res == match_data;
}
-static struct phy *phy_lookup(struct device *device, const char *port)
-{
- unsigned int count;
- struct phy *phy;
- struct device *dev;
- struct phy_consumer *consumers;
- struct class_dev_iter iter;
-
- class_dev_iter_init(&iter, phy_class, NULL, NULL);
- while ((dev = class_dev_iter_next(&iter))) {
- phy = to_phy(dev);
-
- if (!phy->init_data)
- continue;
- count = phy->init_data->num_consumers;
- consumers = phy->init_data->consumers;
- while (count--) {
- if (!strcmp(consumers->dev_name, dev_name(device)) &&
- !strcmp(consumers->port, port)) {
- class_dev_iter_exit(&iter);
- return phy;
- }
- consumers++;
- }
- }
-
- class_dev_iter_exit(&iter);
- return ERR_PTR(-ENODEV);
-}
-
/**
* phy_create_lookup() - allocate and register PHY/device association
* @phy: the phy of the association
@@ -148,7 +118,6 @@ static struct phy *phy_find(struct device *dev, const char *con_id)
{
const char *dev_id = dev_name(dev);
struct phy_lookup *p, *pl = NULL;
- struct phy *phy;
mutex_lock(&phy_provider_mutex);
list_for_each_entry(p, &phys, node)
@@ -158,12 +127,7 @@ static struct phy *phy_find(struct device *dev, const char *con_id)
}
mutex_unlock(&phy_provider_mutex);
- phy = pl ? pl->phy : ERR_PTR(-ENODEV);
-
- /* fall-back to the old lookup method for now */
- if (IS_ERR(phy))
- phy = phy_lookup(dev, con_id);
- return phy;
+ return pl ? pl->phy : ERR_PTR(-ENODEV);
}
static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
@@ -662,13 +626,11 @@ EXPORT_SYMBOL_GPL(devm_of_phy_get);
* @dev: device that is creating the new phy
* @node: device node of the phy
* @ops: function pointers for performing phy operations
- * @init_data: contains the list of PHY consumers or NULL
*
* Called to create a phy using phy framework.
*/
struct phy *phy_create(struct device *dev, struct device_node *node,
- const struct phy_ops *ops,
- struct phy_init_data *init_data)
+ const struct phy_ops *ops)
{
int ret;
int id;
@@ -706,7 +668,6 @@ struct phy *phy_create(struct device *dev, struct device_node *node,
phy->dev.of_node = node ?: dev->of_node;
phy->id = id;
phy->ops = ops;
- phy->init_data = init_data;
ret = dev_set_name(&phy->dev, "phy-%s.%d", dev_name(dev), id);
if (ret)
@@ -741,7 +702,6 @@ EXPORT_SYMBOL_GPL(phy_create);
* @dev: device that is creating the new phy
* @node: device node of the phy
* @ops: function pointers for performing phy operations
- * @init_data: contains the list of PHY consumers or NULL
*
* Creates a new PHY device adding it to the PHY class.
* While at that, it also associates the device with the phy using devres.
@@ -749,8 +709,7 @@ EXPORT_SYMBOL_GPL(phy_create);
* then, devres data is freed.
*/
struct phy *devm_phy_create(struct device *dev, struct device_node *node,
- const struct phy_ops *ops,
- struct phy_init_data *init_data)
+ const struct phy_ops *ops)
{
struct phy **ptr, *phy;
@@ -758,7 +717,7 @@ struct phy *devm_phy_create(struct device *dev, struct device_node *node,
if (!ptr)
return ERR_PTR(-ENOMEM);
- phy = phy_create(dev, node, ops, init_data);
+ phy = phy_create(dev, node, ops);
if (!IS_ERR(phy)) {
*ptr = phy;
devres_add(dev, ptr);
diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c
index 84f49e5..f86cbe6 100644
--- a/drivers/phy/phy-exynos-dp-video.c
+++ b/drivers/phy/phy-exynos-dp-video.c
@@ -112,7 +112,7 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
match = of_match_node(exynos_dp_video_phy_of_match, dev->of_node);
state->drvdata = match->data;
- phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops, NULL);
+ phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create Display Port PHY\n");
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c
index 6a9bef1..943e0f8 100644
--- a/drivers/phy/phy-exynos-mipi-video.c
+++ b/drivers/phy/phy-exynos-mipi-video.c
@@ -137,7 +137,7 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)
for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) {
struct phy *phy = devm_phy_create(dev, NULL,
- &exynos_mipi_video_phy_ops, NULL);
+ &exynos_mipi_video_phy_ops);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create PHY %d\n", i);
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5-usbdrd.c
index f756aca..b3ca3bc 100644
--- a/drivers/phy/phy-exynos5-usbdrd.c
+++ b/drivers/phy/phy-exynos5-usbdrd.c
@@ -637,8 +637,7 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
for (i = 0; i < EXYNOS5_DRDPHYS_NUM; i++) {
struct phy *phy = devm_phy_create(dev, NULL,
- &exynos5_usbdrd_phy_ops,
- NULL);
+ &exynos5_usbdrd_phy_ops);
if (IS_ERR(phy)) {
dev_err(dev, "Failed to create usbdrd_phy phy\n");
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-exynos5250-sata.c b/drivers/phy/phy-exynos5250-sata.c
index 54cf4ae..bc858cc 100644
--- a/drivers/phy/phy-exynos5250-sata.c
+++ b/drivers/phy/phy-exynos5250-sata.c
@@ -210,7 +210,7 @@ static int exynos_sata_phy_probe(struct platform_device *pdev)
return ret;
}
- sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops, NULL);
+ sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops);
if (IS_ERR(sata_phy->phy)) {
clk_disable_unprepare(sata_phy->phyclk);
dev_err(dev, "failed to create PHY\n");
diff --git a/drivers/phy/phy-hix5hd2-sata.c b/drivers/phy/phy-hix5hd2-sata.c
index d5d9780..a80ff9d 100644
--- a/drivers/phy/phy-hix5hd2-sata.c
+++ b/drivers/phy/phy-hix5hd2-sata.c
@@ -156,7 +156,7 @@ static int hix5hd2_sata_phy_probe(struct platform_device *pdev)
if (IS_ERR(priv->peri_ctrl))
priv->peri_ctrl = NULL;
- phy = devm_phy_create(dev, NULL, &hix5hd2_sata_phy_ops, NULL);
+ phy = devm_phy_create(dev, NULL, &hix5hd2_sata_phy_ops);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create PHY\n");
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-miphy28lp.c b/drivers/phy/phy-miphy28lp.c
index 87dcc9a..e34da13 100644
--- a/drivers/phy/phy-miphy28lp.c
+++ b/drivers/phy/phy-miphy28lp.c
@@ -1231,7 +1231,7 @@ static int miphy28lp_probe(struct platform_device *pdev)
miphy_dev->phys[port] = miphy_phy;
- phy = devm_phy_create(&pdev->dev, child, &miphy28lp_ops, NULL);
+ phy = devm_phy_create(&pdev->dev, child, &miphy28lp_ops);
if (IS_ERR(phy)) {
dev_err(&pdev->dev, "failed to create PHY\n");
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-miphy365x.c b/drivers/phy/phy-miphy365x.c
index 801afaf..239930e 100644
--- a/drivers/phy/phy-miphy365x.c
+++ b/drivers/phy/phy-miphy365x.c
@@ -593,7 +593,7 @@ static int miphy365x_probe(struct platform_device *pdev)
miphy_dev->phys[port] = miphy_phy;
- phy = devm_phy_create(&pdev->dev, child, &miphy365x_ops, NULL);
+ phy = devm_phy_create(&pdev->dev, child, &miphy365x_ops);
if (IS_ERR(phy)) {
dev_err(&pdev->dev, "failed to create PHY\n");
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-mvebu-sata.c b/drivers/phy/phy-mvebu-sata.c
index d395558..03b94f9 100644
--- a/drivers/phy/phy-mvebu-sata.c
+++ b/drivers/phy/phy-mvebu-sata.c
@@ -101,7 +101,7 @@ static int phy_mvebu_sata_probe(struct platform_device *pdev)
if (IS_ERR(priv->clk))
return PTR_ERR(priv->clk);
- phy = devm_phy_create(&pdev->dev, NULL, &phy_mvebu_sata_ops, NULL);
+ phy = devm_phy_create(&pdev->dev, NULL, &phy_mvebu_sata_ops);
if (IS_ERR(phy))
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index f091576..5dab3ec 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -260,7 +260,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, phy);
pm_runtime_enable(phy->dev);
- generic_phy = devm_phy_create(phy->dev, NULL, &ops, NULL);
+ generic_phy = devm_phy_create(phy->dev, NULL, &ops);
if (IS_ERR(generic_phy)) {
pm_runtime_disable(phy->dev);
return PTR_ERR(generic_phy);
diff --git a/drivers/phy/phy-qcom-apq8064-sata.c b/drivers/phy/phy-qcom-apq8064-sata.c
index 7b3ddfb..4b243f7 100644
--- a/drivers/phy/phy-qcom-apq8064-sata.c
+++ b/drivers/phy/phy-qcom-apq8064-sata.c
@@ -228,8 +228,7 @@ static int qcom_apq8064_sata_phy_probe(struct platform_device *pdev)
if (IS_ERR(phy->mmio))
return PTR_ERR(phy->mmio);
- generic_phy = devm_phy_create(dev, NULL, &qcom_apq8064_sata_phy_ops,
- NULL);
+ generic_phy = devm_phy_create(dev, NULL, &qcom_apq8064_sata_phy_ops);
if (IS_ERR(generic_phy)) {
dev_err(dev, "%s: failed to create phy\n", __func__);
return PTR_ERR(generic_phy);
diff --git a/drivers/phy/phy-qcom-ipq806x-sata.c b/drivers/phy/phy-qcom-ipq806x-sata.c
index 759b0bf..6f2fe26 100644
--- a/drivers/phy/phy-qcom-ipq806x-sata.c
+++ b/drivers/phy/phy-qcom-ipq806x-sata.c
@@ -150,8 +150,7 @@ static int qcom_ipq806x_sata_phy_probe(struct platform_device *pdev)
if (IS_ERR(phy->mmio))
return PTR_ERR(phy->mmio);
- generic_phy = devm_phy_create(dev, NULL, &qcom_ipq806x_sata_phy_ops,
- NULL);
+ generic_phy = devm_phy_create(dev, NULL, &qcom_ipq806x_sata_phy_ops);
if (IS_ERR(generic_phy)) {
dev_err(dev, "%s: failed to create phy\n", __func__);
return PTR_ERR(generic_phy);
diff --git a/drivers/phy/phy-rcar-gen2.c b/drivers/phy/phy-rcar-gen2.c
index 2793af1..778276a 100644
--- a/drivers/phy/phy-rcar-gen2.c
+++ b/drivers/phy/phy-rcar-gen2.c
@@ -304,7 +304,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
phy->select_value = select_value[channel_num][n];
phy->phy = devm_phy_create(dev, NULL,
- &rcar_gen2_phy_ops, NULL);
+ &rcar_gen2_phy_ops);
if (IS_ERR(phy->phy)) {
dev_err(dev, "Failed to create PHY\n");
return PTR_ERR(phy->phy);
diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy-samsung-usb2.c
index 908949d..4a12f66 100644
--- a/drivers/phy/phy-samsung-usb2.c
+++ b/drivers/phy/phy-samsung-usb2.c
@@ -202,8 +202,7 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev)
struct samsung_usb2_phy_instance *p = &drv->instances[i];
dev_dbg(dev, "Creating phy \"%s\"\n", label);
- p->phy = devm_phy_create(dev, NULL, &samsung_usb2_phy_ops,
- NULL);
+ p->phy = devm_phy_create(dev, NULL, &samsung_usb2_phy_ops);
if (IS_ERR(p->phy)) {
dev_err(drv->dev, "Failed to create usb2_phy \"%s\"\n",
label);
diff --git a/drivers/phy/phy-spear1310-miphy.c b/drivers/phy/phy-spear1310-miphy.c
index 5f4c586..9f47fae 100644
--- a/drivers/phy/phy-spear1310-miphy.c
+++ b/drivers/phy/phy-spear1310-miphy.c
@@ -227,7 +227,7 @@ static int spear1310_miphy_probe(struct platform_device *pdev)
return -EINVAL;
}
- priv->phy = devm_phy_create(dev, NULL, &spear1310_miphy_ops, NULL);
+ priv->phy = devm_phy_create(dev, NULL, &spear1310_miphy_ops);
if (IS_ERR(priv->phy)) {
dev_err(dev, "failed to create SATA PCIe PHY\n");
return PTR_ERR(priv->phy);
diff --git a/drivers/phy/phy-spear1340-miphy.c b/drivers/phy/phy-spear1340-miphy.c
index 1ecd094..e42bc20 100644
--- a/drivers/phy/phy-spear1340-miphy.c
+++ b/drivers/phy/phy-spear1340-miphy.c
@@ -259,7 +259,7 @@ static int spear1340_miphy_probe(struct platform_device *pdev)
return PTR_ERR(priv->misc);
}
- priv->phy = devm_phy_create(dev, NULL, &spear1340_miphy_ops, NULL);
+ priv->phy = devm_phy_create(dev, NULL, &spear1340_miphy_ops);
if (IS_ERR(priv->phy)) {
dev_err(dev, "failed to create SATA PCIe PHY\n");
return PTR_ERR(priv->phy);
diff --git a/drivers/phy/phy-stih407-usb.c b/drivers/phy/phy-stih407-usb.c
index 42428d4..74f0fab 100644
--- a/drivers/phy/phy-stih407-usb.c
+++ b/drivers/phy/phy-stih407-usb.c
@@ -137,7 +137,7 @@ static int stih407_usb2_picophy_probe(struct platform_device *pdev)
}
phy_dev->param = res->start;
- phy = devm_phy_create(dev, NULL, &stih407_usb2_picophy_data, NULL);
+ phy = devm_phy_create(dev, NULL, &stih407_usb2_picophy_data);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create Display Port PHY\n");
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-stih41x-usb.c b/drivers/phy/phy-stih41x-usb.c
index 9f16cb8..4ab581e 100644
--- a/drivers/phy/phy-stih41x-usb.c
+++ b/drivers/phy/phy-stih41x-usb.c
@@ -148,7 +148,7 @@ static int stih41x_usb_phy_probe(struct platform_device *pdev)
return PTR_ERR(phy_dev->clk);
}
- phy = devm_phy_create(dev, NULL, &stih41x_usb_phy_ops, NULL);
+ phy = devm_phy_create(dev, NULL, &stih41x_usb_phy_ops);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create phy\n");
diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
index 6bd2b0c..fb02a67 100644
--- a/drivers/phy/phy-sun4i-usb.c
+++ b/drivers/phy/phy-sun4i-usb.c
@@ -298,7 +298,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
return PTR_ERR(phy->pmu);
}
- phy->phy = devm_phy_create(dev, NULL, &sun4i_usb_phy_ops, NULL);
+ phy->phy = devm_phy_create(dev, NULL, &sun4i_usb_phy_ops);
if (IS_ERR(phy->phy)) {
dev_err(dev, "failed to create PHY %d\n", i);
return PTR_ERR(phy->phy);
diff --git a/drivers/phy/phy-ti-pipe3.c b/drivers/phy/phy-ti-pipe3.c
index ab1e22d..c297b7a 100644
--- a/drivers/phy/phy-ti-pipe3.c
+++ b/drivers/phy/phy-ti-pipe3.c
@@ -399,7 +399,7 @@ static int ti_pipe3_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, phy);
pm_runtime_enable(phy->dev);
- generic_phy = devm_phy_create(phy->dev, NULL, &ops, NULL);
+ generic_phy = devm_phy_create(phy->dev, NULL, &ops);
if (IS_ERR(generic_phy))
return PTR_ERR(generic_phy);
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index c45a3aa..d19e4a0 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -678,7 +678,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
otg->set_host = twl4030_set_host;
otg->set_peripheral = twl4030_set_peripheral;
- phy = devm_phy_create(twl->dev, NULL, &ops, NULL);
+ phy = devm_phy_create(twl->dev, NULL, &ops);
if (IS_ERR(phy)) {
dev_dbg(&pdev->dev, "Failed to create PHY\n");
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-xgene.c b/drivers/phy/phy-xgene.c
index f8a51b1..29214a3 100644
--- a/drivers/phy/phy-xgene.c
+++ b/drivers/phy/phy-xgene.c
@@ -1707,7 +1707,7 @@ static int xgene_phy_probe(struct platform_device *pdev)
ctx->dev = &pdev->dev;
platform_set_drvdata(pdev, ctx);
- ctx->phy = devm_phy_create(ctx->dev, NULL, &xgene_phy_ops, NULL);
+ ctx->phy = devm_phy_create(ctx->dev, NULL, &xgene_phy_ops);
if (IS_ERR(ctx->phy)) {
dev_dbg(&pdev->dev, "Failed to create PHY\n");
rc = PTR_ERR(ctx->phy);
diff --git a/drivers/pinctrl/pinctrl-tegra-xusb.c b/drivers/pinctrl/pinctrl-tegra-xusb.c
index 1631ec9..a84299b 100644
--- a/drivers/pinctrl/pinctrl-tegra-xusb.c
+++ b/drivers/pinctrl/pinctrl-tegra-xusb.c
@@ -910,7 +910,7 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
goto reset;
}
- phy = devm_phy_create(&pdev->dev, NULL, &pcie_phy_ops, NULL);
+ phy = devm_phy_create(&pdev->dev, NULL, &pcie_phy_ops);
if (IS_ERR(phy)) {
err = PTR_ERR(phy);
goto unregister;
@@ -919,7 +919,7 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
padctl->phys[TEGRA_XUSB_PADCTL_PCIE] = phy;
phy_set_drvdata(phy, padctl);
- phy = devm_phy_create(&pdev->dev, NULL, &sata_phy_ops, NULL);
+ phy = devm_phy_create(&pdev->dev, NULL, &sata_phy_ops);
if (IS_ERR(phy)) {
err = PTR_ERR(phy);
goto unregister;
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 849284e..a0197fa 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -61,7 +61,6 @@ struct phy {
struct device dev;
int id;
const struct phy_ops *ops;
- struct phy_init_data *init_data;
struct mutex mutex;
int init_count;
int power_count;
@@ -84,32 +83,6 @@ struct phy_provider {
struct of_phandle_args *args);
};
-/**
- * struct phy_consumer - represents the phy consumer
- * @dev_name: the device name of the controller that will use this PHY device
- * @port: name given to the consumer port
- */
-struct phy_consumer {
- const char *dev_name;
- const char *port;
-};
-
-/**
- * struct phy_init_data - contains the list of PHY consumers
- * @num_consumers: number of consumers for this PHY device
- * @consumers: list of PHY consumers
- */
-struct phy_init_data {
- unsigned int num_consumers;
- struct phy_consumer *consumers;
-};
-
-#define PHY_CONSUMER(_dev_name, _port) \
-{ \
- .dev_name = _dev_name, \
- .port = _port, \
-}
-
struct phy_lookup {
struct list_head node;
const char *dev_id;
@@ -166,10 +139,9 @@ struct phy *of_phy_get(struct device_node *np, const char *con_id);
struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
struct phy *phy_create(struct device *dev, struct device_node *node,
- const struct phy_ops *ops,
- struct phy_init_data *init_data);
+ const struct phy_ops *ops);
struct phy *devm_phy_create(struct device *dev, struct device_node *node,
- const struct phy_ops *ops, struct phy_init_data *init_data);
+ const struct phy_ops *ops);
void phy_destroy(struct phy *phy);
void devm_phy_destroy(struct device *dev, struct phy *phy);
struct phy_provider *__of_phy_provider_register(struct device *dev,
@@ -310,16 +282,14 @@ static inline struct phy *of_phy_simple_xlate(struct device *dev,
static inline struct phy *phy_create(struct device *dev,
struct device_node *node,
- const struct phy_ops *ops,
- struct phy_init_data *init_data)
+ const struct phy_ops *ops)
{
return ERR_PTR(-ENOSYS);
}
static inline struct phy *devm_phy_create(struct device *dev,
struct device_node *node,
- const struct phy_ops *ops,
- struct phy_init_data *init_data)
+ const struct phy_ops *ops)
{
return ERR_PTR(-ENOSYS);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] phy: remove the old lookup method
2014-11-22 8:27 [PATCH] phy: remove the old lookup method Kishon Vijay Abraham I
@ 2014-11-22 8:33 ` Kishon Vijay Abraham I
2014-11-28 11:57 ` Linus Walleij
1 sibling, 0 replies; 5+ messages in thread
From: Kishon Vijay Abraham I @ 2014-11-22 8:33 UTC (permalink / raw)
To: heikki.krogerus, gautam.vivek, andrew.kim, linus.walleij,
swarren, thierry.reding, gnurou
Cc: linux-kernel
Hi Linus, Thierry,
On Saturday 22 November 2014 01:57 PM, Kishon Vijay Abraham I wrote:
> From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>
> The users of the old method are now converted to the new one.
One of the files in pinctrl is being modified in this patch to use the new
devm_phy_create signature. I'm merging this in my linux-phy tree. If you see
any problems please let me know.
Thanks
Kishon
>
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> [ kishon@ti.com : made phy-berlin-usb.c and phy-miphy28lp.c to use the updated
> devm_phy_create API.]
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
> Two new PHY drivers phy-berlin-usb.c and phy-miphy28lp.c were added which was using the old
> devm_phy_create signature. Made it to use the new devm_phy_create signatiure.
>
> drivers/phy/phy-bcm-kona-usb2.c | 2 +-
> drivers/phy/phy-berlin-sata.c | 2 +-
> drivers/phy/phy-berlin-usb.c | 3 +--
> drivers/phy/phy-core.c | 49 +++-------------------------------
> drivers/phy/phy-exynos-dp-video.c | 2 +-
> drivers/phy/phy-exynos-mipi-video.c | 2 +-
> drivers/phy/phy-exynos5-usbdrd.c | 3 +--
> drivers/phy/phy-exynos5250-sata.c | 2 +-
> drivers/phy/phy-hix5hd2-sata.c | 2 +-
> drivers/phy/phy-miphy28lp.c | 2 +-
> drivers/phy/phy-miphy365x.c | 2 +-
> drivers/phy/phy-mvebu-sata.c | 2 +-
> drivers/phy/phy-omap-usb2.c | 2 +-
> drivers/phy/phy-qcom-apq8064-sata.c | 3 +--
> drivers/phy/phy-qcom-ipq806x-sata.c | 3 +--
> drivers/phy/phy-rcar-gen2.c | 2 +-
> drivers/phy/phy-samsung-usb2.c | 3 +--
> drivers/phy/phy-spear1310-miphy.c | 2 +-
> drivers/phy/phy-spear1340-miphy.c | 2 +-
> drivers/phy/phy-stih407-usb.c | 2 +-
> drivers/phy/phy-stih41x-usb.c | 2 +-
> drivers/phy/phy-sun4i-usb.c | 2 +-
> drivers/phy/phy-ti-pipe3.c | 2 +-
> drivers/phy/phy-twl4030-usb.c | 2 +-
> drivers/phy/phy-xgene.c | 2 +-
> drivers/pinctrl/pinctrl-tegra-xusb.c | 4 +--
> include/linux/phy/phy.h | 38 +++-----------------------
> 27 files changed, 34 insertions(+), 110 deletions(-)
>
> diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
> index c1e0ca3..ef2dc1a 100644
> --- a/drivers/phy/phy-bcm-kona-usb2.c
> +++ b/drivers/phy/phy-bcm-kona-usb2.c
> @@ -117,7 +117,7 @@ static int bcm_kona_usb2_probe(struct platform_device *pdev)
>
> platform_set_drvdata(pdev, phy);
>
> - gphy = devm_phy_create(dev, NULL, &ops, NULL);
> + gphy = devm_phy_create(dev, NULL, &ops);
> if (IS_ERR(gphy))
> return PTR_ERR(gphy);
>
> diff --git a/drivers/phy/phy-berlin-sata.c b/drivers/phy/phy-berlin-sata.c
> index 873e7a8..3e599dc 100644
> --- a/drivers/phy/phy-berlin-sata.c
> +++ b/drivers/phy/phy-berlin-sata.c
> @@ -249,7 +249,7 @@ static int phy_berlin_sata_probe(struct platform_device *pdev)
> if (!phy_desc)
> return -ENOMEM;
>
> - phy = devm_phy_create(dev, NULL, &phy_berlin_sata_ops, NULL);
> + phy = devm_phy_create(dev, NULL, &phy_berlin_sata_ops);
> if (IS_ERR(phy)) {
> dev_err(dev, "failed to create PHY %d\n", phy_id);
> return PTR_ERR(phy);
> diff --git a/drivers/phy/phy-berlin-usb.c b/drivers/phy/phy-berlin-usb.c
> index f9f1306..c8a8d53 100644
> --- a/drivers/phy/phy-berlin-usb.c
> +++ b/drivers/phy/phy-berlin-usb.c
> @@ -192,8 +192,7 @@ static int phy_berlin_usb_probe(struct platform_device *pdev)
>
> priv->pll_divider = *((u32 *)match->data);
>
> - priv->phy = devm_phy_create(&pdev->dev, NULL, &phy_berlin_usb_ops,
> - NULL);
> + priv->phy = devm_phy_create(&pdev->dev, NULL, &phy_berlin_usb_ops);
> if (IS_ERR(priv->phy)) {
> dev_err(&pdev->dev, "failed to create PHY\n");
> return PTR_ERR(priv->phy);
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index bc83077..a12d353 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -55,36 +55,6 @@ static int devm_phy_match(struct device *dev, void *res, void *match_data)
> return res == match_data;
> }
>
> -static struct phy *phy_lookup(struct device *device, const char *port)
> -{
> - unsigned int count;
> - struct phy *phy;
> - struct device *dev;
> - struct phy_consumer *consumers;
> - struct class_dev_iter iter;
> -
> - class_dev_iter_init(&iter, phy_class, NULL, NULL);
> - while ((dev = class_dev_iter_next(&iter))) {
> - phy = to_phy(dev);
> -
> - if (!phy->init_data)
> - continue;
> - count = phy->init_data->num_consumers;
> - consumers = phy->init_data->consumers;
> - while (count--) {
> - if (!strcmp(consumers->dev_name, dev_name(device)) &&
> - !strcmp(consumers->port, port)) {
> - class_dev_iter_exit(&iter);
> - return phy;
> - }
> - consumers++;
> - }
> - }
> -
> - class_dev_iter_exit(&iter);
> - return ERR_PTR(-ENODEV);
> -}
> -
> /**
> * phy_create_lookup() - allocate and register PHY/device association
> * @phy: the phy of the association
> @@ -148,7 +118,6 @@ static struct phy *phy_find(struct device *dev, const char *con_id)
> {
> const char *dev_id = dev_name(dev);
> struct phy_lookup *p, *pl = NULL;
> - struct phy *phy;
>
> mutex_lock(&phy_provider_mutex);
> list_for_each_entry(p, &phys, node)
> @@ -158,12 +127,7 @@ static struct phy *phy_find(struct device *dev, const char *con_id)
> }
> mutex_unlock(&phy_provider_mutex);
>
> - phy = pl ? pl->phy : ERR_PTR(-ENODEV);
> -
> - /* fall-back to the old lookup method for now */
> - if (IS_ERR(phy))
> - phy = phy_lookup(dev, con_id);
> - return phy;
> + return pl ? pl->phy : ERR_PTR(-ENODEV);
> }
>
> static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
> @@ -662,13 +626,11 @@ EXPORT_SYMBOL_GPL(devm_of_phy_get);
> * @dev: device that is creating the new phy
> * @node: device node of the phy
> * @ops: function pointers for performing phy operations
> - * @init_data: contains the list of PHY consumers or NULL
> *
> * Called to create a phy using phy framework.
> */
> struct phy *phy_create(struct device *dev, struct device_node *node,
> - const struct phy_ops *ops,
> - struct phy_init_data *init_data)
> + const struct phy_ops *ops)
> {
> int ret;
> int id;
> @@ -706,7 +668,6 @@ struct phy *phy_create(struct device *dev, struct device_node *node,
> phy->dev.of_node = node ?: dev->of_node;
> phy->id = id;
> phy->ops = ops;
> - phy->init_data = init_data;
>
> ret = dev_set_name(&phy->dev, "phy-%s.%d", dev_name(dev), id);
> if (ret)
> @@ -741,7 +702,6 @@ EXPORT_SYMBOL_GPL(phy_create);
> * @dev: device that is creating the new phy
> * @node: device node of the phy
> * @ops: function pointers for performing phy operations
> - * @init_data: contains the list of PHY consumers or NULL
> *
> * Creates a new PHY device adding it to the PHY class.
> * While at that, it also associates the device with the phy using devres.
> @@ -749,8 +709,7 @@ EXPORT_SYMBOL_GPL(phy_create);
> * then, devres data is freed.
> */
> struct phy *devm_phy_create(struct device *dev, struct device_node *node,
> - const struct phy_ops *ops,
> - struct phy_init_data *init_data)
> + const struct phy_ops *ops)
> {
> struct phy **ptr, *phy;
>
> @@ -758,7 +717,7 @@ struct phy *devm_phy_create(struct device *dev, struct device_node *node,
> if (!ptr)
> return ERR_PTR(-ENOMEM);
>
> - phy = phy_create(dev, node, ops, init_data);
> + phy = phy_create(dev, node, ops);
> if (!IS_ERR(phy)) {
> *ptr = phy;
> devres_add(dev, ptr);
> diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c
> index 84f49e5..f86cbe6 100644
> --- a/drivers/phy/phy-exynos-dp-video.c
> +++ b/drivers/phy/phy-exynos-dp-video.c
> @@ -112,7 +112,7 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
> match = of_match_node(exynos_dp_video_phy_of_match, dev->of_node);
> state->drvdata = match->data;
>
> - phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops, NULL);
> + phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops);
> if (IS_ERR(phy)) {
> dev_err(dev, "failed to create Display Port PHY\n");
> return PTR_ERR(phy);
> diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c
> index 6a9bef1..943e0f8 100644
> --- a/drivers/phy/phy-exynos-mipi-video.c
> +++ b/drivers/phy/phy-exynos-mipi-video.c
> @@ -137,7 +137,7 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)
>
> for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) {
> struct phy *phy = devm_phy_create(dev, NULL,
> - &exynos_mipi_video_phy_ops, NULL);
> + &exynos_mipi_video_phy_ops);
> if (IS_ERR(phy)) {
> dev_err(dev, "failed to create PHY %d\n", i);
> return PTR_ERR(phy);
> diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5-usbdrd.c
> index f756aca..b3ca3bc 100644
> --- a/drivers/phy/phy-exynos5-usbdrd.c
> +++ b/drivers/phy/phy-exynos5-usbdrd.c
> @@ -637,8 +637,7 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
>
> for (i = 0; i < EXYNOS5_DRDPHYS_NUM; i++) {
> struct phy *phy = devm_phy_create(dev, NULL,
> - &exynos5_usbdrd_phy_ops,
> - NULL);
> + &exynos5_usbdrd_phy_ops);
> if (IS_ERR(phy)) {
> dev_err(dev, "Failed to create usbdrd_phy phy\n");
> return PTR_ERR(phy);
> diff --git a/drivers/phy/phy-exynos5250-sata.c b/drivers/phy/phy-exynos5250-sata.c
> index 54cf4ae..bc858cc 100644
> --- a/drivers/phy/phy-exynos5250-sata.c
> +++ b/drivers/phy/phy-exynos5250-sata.c
> @@ -210,7 +210,7 @@ static int exynos_sata_phy_probe(struct platform_device *pdev)
> return ret;
> }
>
> - sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops, NULL);
> + sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops);
> if (IS_ERR(sata_phy->phy)) {
> clk_disable_unprepare(sata_phy->phyclk);
> dev_err(dev, "failed to create PHY\n");
> diff --git a/drivers/phy/phy-hix5hd2-sata.c b/drivers/phy/phy-hix5hd2-sata.c
> index d5d9780..a80ff9d 100644
> --- a/drivers/phy/phy-hix5hd2-sata.c
> +++ b/drivers/phy/phy-hix5hd2-sata.c
> @@ -156,7 +156,7 @@ static int hix5hd2_sata_phy_probe(struct platform_device *pdev)
> if (IS_ERR(priv->peri_ctrl))
> priv->peri_ctrl = NULL;
>
> - phy = devm_phy_create(dev, NULL, &hix5hd2_sata_phy_ops, NULL);
> + phy = devm_phy_create(dev, NULL, &hix5hd2_sata_phy_ops);
> if (IS_ERR(phy)) {
> dev_err(dev, "failed to create PHY\n");
> return PTR_ERR(phy);
> diff --git a/drivers/phy/phy-miphy28lp.c b/drivers/phy/phy-miphy28lp.c
> index 87dcc9a..e34da13 100644
> --- a/drivers/phy/phy-miphy28lp.c
> +++ b/drivers/phy/phy-miphy28lp.c
> @@ -1231,7 +1231,7 @@ static int miphy28lp_probe(struct platform_device *pdev)
>
> miphy_dev->phys[port] = miphy_phy;
>
> - phy = devm_phy_create(&pdev->dev, child, &miphy28lp_ops, NULL);
> + phy = devm_phy_create(&pdev->dev, child, &miphy28lp_ops);
> if (IS_ERR(phy)) {
> dev_err(&pdev->dev, "failed to create PHY\n");
> return PTR_ERR(phy);
> diff --git a/drivers/phy/phy-miphy365x.c b/drivers/phy/phy-miphy365x.c
> index 801afaf..239930e 100644
> --- a/drivers/phy/phy-miphy365x.c
> +++ b/drivers/phy/phy-miphy365x.c
> @@ -593,7 +593,7 @@ static int miphy365x_probe(struct platform_device *pdev)
>
> miphy_dev->phys[port] = miphy_phy;
>
> - phy = devm_phy_create(&pdev->dev, child, &miphy365x_ops, NULL);
> + phy = devm_phy_create(&pdev->dev, child, &miphy365x_ops);
> if (IS_ERR(phy)) {
> dev_err(&pdev->dev, "failed to create PHY\n");
> return PTR_ERR(phy);
> diff --git a/drivers/phy/phy-mvebu-sata.c b/drivers/phy/phy-mvebu-sata.c
> index d395558..03b94f9 100644
> --- a/drivers/phy/phy-mvebu-sata.c
> +++ b/drivers/phy/phy-mvebu-sata.c
> @@ -101,7 +101,7 @@ static int phy_mvebu_sata_probe(struct platform_device *pdev)
> if (IS_ERR(priv->clk))
> return PTR_ERR(priv->clk);
>
> - phy = devm_phy_create(&pdev->dev, NULL, &phy_mvebu_sata_ops, NULL);
> + phy = devm_phy_create(&pdev->dev, NULL, &phy_mvebu_sata_ops);
> if (IS_ERR(phy))
> return PTR_ERR(phy);
>
> diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
> index f091576..5dab3ec 100644
> --- a/drivers/phy/phy-omap-usb2.c
> +++ b/drivers/phy/phy-omap-usb2.c
> @@ -260,7 +260,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
> platform_set_drvdata(pdev, phy);
> pm_runtime_enable(phy->dev);
>
> - generic_phy = devm_phy_create(phy->dev, NULL, &ops, NULL);
> + generic_phy = devm_phy_create(phy->dev, NULL, &ops);
> if (IS_ERR(generic_phy)) {
> pm_runtime_disable(phy->dev);
> return PTR_ERR(generic_phy);
> diff --git a/drivers/phy/phy-qcom-apq8064-sata.c b/drivers/phy/phy-qcom-apq8064-sata.c
> index 7b3ddfb..4b243f7 100644
> --- a/drivers/phy/phy-qcom-apq8064-sata.c
> +++ b/drivers/phy/phy-qcom-apq8064-sata.c
> @@ -228,8 +228,7 @@ static int qcom_apq8064_sata_phy_probe(struct platform_device *pdev)
> if (IS_ERR(phy->mmio))
> return PTR_ERR(phy->mmio);
>
> - generic_phy = devm_phy_create(dev, NULL, &qcom_apq8064_sata_phy_ops,
> - NULL);
> + generic_phy = devm_phy_create(dev, NULL, &qcom_apq8064_sata_phy_ops);
> if (IS_ERR(generic_phy)) {
> dev_err(dev, "%s: failed to create phy\n", __func__);
> return PTR_ERR(generic_phy);
> diff --git a/drivers/phy/phy-qcom-ipq806x-sata.c b/drivers/phy/phy-qcom-ipq806x-sata.c
> index 759b0bf..6f2fe26 100644
> --- a/drivers/phy/phy-qcom-ipq806x-sata.c
> +++ b/drivers/phy/phy-qcom-ipq806x-sata.c
> @@ -150,8 +150,7 @@ static int qcom_ipq806x_sata_phy_probe(struct platform_device *pdev)
> if (IS_ERR(phy->mmio))
> return PTR_ERR(phy->mmio);
>
> - generic_phy = devm_phy_create(dev, NULL, &qcom_ipq806x_sata_phy_ops,
> - NULL);
> + generic_phy = devm_phy_create(dev, NULL, &qcom_ipq806x_sata_phy_ops);
> if (IS_ERR(generic_phy)) {
> dev_err(dev, "%s: failed to create phy\n", __func__);
> return PTR_ERR(generic_phy);
> diff --git a/drivers/phy/phy-rcar-gen2.c b/drivers/phy/phy-rcar-gen2.c
> index 2793af1..778276a 100644
> --- a/drivers/phy/phy-rcar-gen2.c
> +++ b/drivers/phy/phy-rcar-gen2.c
> @@ -304,7 +304,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
> phy->select_value = select_value[channel_num][n];
>
> phy->phy = devm_phy_create(dev, NULL,
> - &rcar_gen2_phy_ops, NULL);
> + &rcar_gen2_phy_ops);
> if (IS_ERR(phy->phy)) {
> dev_err(dev, "Failed to create PHY\n");
> return PTR_ERR(phy->phy);
> diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy-samsung-usb2.c
> index 908949d..4a12f66 100644
> --- a/drivers/phy/phy-samsung-usb2.c
> +++ b/drivers/phy/phy-samsung-usb2.c
> @@ -202,8 +202,7 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev)
> struct samsung_usb2_phy_instance *p = &drv->instances[i];
>
> dev_dbg(dev, "Creating phy \"%s\"\n", label);
> - p->phy = devm_phy_create(dev, NULL, &samsung_usb2_phy_ops,
> - NULL);
> + p->phy = devm_phy_create(dev, NULL, &samsung_usb2_phy_ops);
> if (IS_ERR(p->phy)) {
> dev_err(drv->dev, "Failed to create usb2_phy \"%s\"\n",
> label);
> diff --git a/drivers/phy/phy-spear1310-miphy.c b/drivers/phy/phy-spear1310-miphy.c
> index 5f4c586..9f47fae 100644
> --- a/drivers/phy/phy-spear1310-miphy.c
> +++ b/drivers/phy/phy-spear1310-miphy.c
> @@ -227,7 +227,7 @@ static int spear1310_miphy_probe(struct platform_device *pdev)
> return -EINVAL;
> }
>
> - priv->phy = devm_phy_create(dev, NULL, &spear1310_miphy_ops, NULL);
> + priv->phy = devm_phy_create(dev, NULL, &spear1310_miphy_ops);
> if (IS_ERR(priv->phy)) {
> dev_err(dev, "failed to create SATA PCIe PHY\n");
> return PTR_ERR(priv->phy);
> diff --git a/drivers/phy/phy-spear1340-miphy.c b/drivers/phy/phy-spear1340-miphy.c
> index 1ecd094..e42bc20 100644
> --- a/drivers/phy/phy-spear1340-miphy.c
> +++ b/drivers/phy/phy-spear1340-miphy.c
> @@ -259,7 +259,7 @@ static int spear1340_miphy_probe(struct platform_device *pdev)
> return PTR_ERR(priv->misc);
> }
>
> - priv->phy = devm_phy_create(dev, NULL, &spear1340_miphy_ops, NULL);
> + priv->phy = devm_phy_create(dev, NULL, &spear1340_miphy_ops);
> if (IS_ERR(priv->phy)) {
> dev_err(dev, "failed to create SATA PCIe PHY\n");
> return PTR_ERR(priv->phy);
> diff --git a/drivers/phy/phy-stih407-usb.c b/drivers/phy/phy-stih407-usb.c
> index 42428d4..74f0fab 100644
> --- a/drivers/phy/phy-stih407-usb.c
> +++ b/drivers/phy/phy-stih407-usb.c
> @@ -137,7 +137,7 @@ static int stih407_usb2_picophy_probe(struct platform_device *pdev)
> }
> phy_dev->param = res->start;
>
> - phy = devm_phy_create(dev, NULL, &stih407_usb2_picophy_data, NULL);
> + phy = devm_phy_create(dev, NULL, &stih407_usb2_picophy_data);
> if (IS_ERR(phy)) {
> dev_err(dev, "failed to create Display Port PHY\n");
> return PTR_ERR(phy);
> diff --git a/drivers/phy/phy-stih41x-usb.c b/drivers/phy/phy-stih41x-usb.c
> index 9f16cb8..4ab581e 100644
> --- a/drivers/phy/phy-stih41x-usb.c
> +++ b/drivers/phy/phy-stih41x-usb.c
> @@ -148,7 +148,7 @@ static int stih41x_usb_phy_probe(struct platform_device *pdev)
> return PTR_ERR(phy_dev->clk);
> }
>
> - phy = devm_phy_create(dev, NULL, &stih41x_usb_phy_ops, NULL);
> + phy = devm_phy_create(dev, NULL, &stih41x_usb_phy_ops);
>
> if (IS_ERR(phy)) {
> dev_err(dev, "failed to create phy\n");
> diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
> index 6bd2b0c..fb02a67 100644
> --- a/drivers/phy/phy-sun4i-usb.c
> +++ b/drivers/phy/phy-sun4i-usb.c
> @@ -298,7 +298,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
> return PTR_ERR(phy->pmu);
> }
>
> - phy->phy = devm_phy_create(dev, NULL, &sun4i_usb_phy_ops, NULL);
> + phy->phy = devm_phy_create(dev, NULL, &sun4i_usb_phy_ops);
> if (IS_ERR(phy->phy)) {
> dev_err(dev, "failed to create PHY %d\n", i);
> return PTR_ERR(phy->phy);
> diff --git a/drivers/phy/phy-ti-pipe3.c b/drivers/phy/phy-ti-pipe3.c
> index ab1e22d..c297b7a 100644
> --- a/drivers/phy/phy-ti-pipe3.c
> +++ b/drivers/phy/phy-ti-pipe3.c
> @@ -399,7 +399,7 @@ static int ti_pipe3_probe(struct platform_device *pdev)
> platform_set_drvdata(pdev, phy);
> pm_runtime_enable(phy->dev);
>
> - generic_phy = devm_phy_create(phy->dev, NULL, &ops, NULL);
> + generic_phy = devm_phy_create(phy->dev, NULL, &ops);
> if (IS_ERR(generic_phy))
> return PTR_ERR(generic_phy);
>
> diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
> index c45a3aa..d19e4a0 100644
> --- a/drivers/phy/phy-twl4030-usb.c
> +++ b/drivers/phy/phy-twl4030-usb.c
> @@ -678,7 +678,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
> otg->set_host = twl4030_set_host;
> otg->set_peripheral = twl4030_set_peripheral;
>
> - phy = devm_phy_create(twl->dev, NULL, &ops, NULL);
> + phy = devm_phy_create(twl->dev, NULL, &ops);
> if (IS_ERR(phy)) {
> dev_dbg(&pdev->dev, "Failed to create PHY\n");
> return PTR_ERR(phy);
> diff --git a/drivers/phy/phy-xgene.c b/drivers/phy/phy-xgene.c
> index f8a51b1..29214a3 100644
> --- a/drivers/phy/phy-xgene.c
> +++ b/drivers/phy/phy-xgene.c
> @@ -1707,7 +1707,7 @@ static int xgene_phy_probe(struct platform_device *pdev)
> ctx->dev = &pdev->dev;
> platform_set_drvdata(pdev, ctx);
>
> - ctx->phy = devm_phy_create(ctx->dev, NULL, &xgene_phy_ops, NULL);
> + ctx->phy = devm_phy_create(ctx->dev, NULL, &xgene_phy_ops);
> if (IS_ERR(ctx->phy)) {
> dev_dbg(&pdev->dev, "Failed to create PHY\n");
> rc = PTR_ERR(ctx->phy);
> diff --git a/drivers/pinctrl/pinctrl-tegra-xusb.c b/drivers/pinctrl/pinctrl-tegra-xusb.c
> index 1631ec9..a84299b 100644
> --- a/drivers/pinctrl/pinctrl-tegra-xusb.c
> +++ b/drivers/pinctrl/pinctrl-tegra-xusb.c
> @@ -910,7 +910,7 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
> goto reset;
> }
>
> - phy = devm_phy_create(&pdev->dev, NULL, &pcie_phy_ops, NULL);
> + phy = devm_phy_create(&pdev->dev, NULL, &pcie_phy_ops);
> if (IS_ERR(phy)) {
> err = PTR_ERR(phy);
> goto unregister;
> @@ -919,7 +919,7 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
> padctl->phys[TEGRA_XUSB_PADCTL_PCIE] = phy;
> phy_set_drvdata(phy, padctl);
>
> - phy = devm_phy_create(&pdev->dev, NULL, &sata_phy_ops, NULL);
> + phy = devm_phy_create(&pdev->dev, NULL, &sata_phy_ops);
> if (IS_ERR(phy)) {
> err = PTR_ERR(phy);
> goto unregister;
> diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> index 849284e..a0197fa 100644
> --- a/include/linux/phy/phy.h
> +++ b/include/linux/phy/phy.h
> @@ -61,7 +61,6 @@ struct phy {
> struct device dev;
> int id;
> const struct phy_ops *ops;
> - struct phy_init_data *init_data;
> struct mutex mutex;
> int init_count;
> int power_count;
> @@ -84,32 +83,6 @@ struct phy_provider {
> struct of_phandle_args *args);
> };
>
> -/**
> - * struct phy_consumer - represents the phy consumer
> - * @dev_name: the device name of the controller that will use this PHY device
> - * @port: name given to the consumer port
> - */
> -struct phy_consumer {
> - const char *dev_name;
> - const char *port;
> -};
> -
> -/**
> - * struct phy_init_data - contains the list of PHY consumers
> - * @num_consumers: number of consumers for this PHY device
> - * @consumers: list of PHY consumers
> - */
> -struct phy_init_data {
> - unsigned int num_consumers;
> - struct phy_consumer *consumers;
> -};
> -
> -#define PHY_CONSUMER(_dev_name, _port) \
> -{ \
> - .dev_name = _dev_name, \
> - .port = _port, \
> -}
> -
> struct phy_lookup {
> struct list_head node;
> const char *dev_id;
> @@ -166,10 +139,9 @@ struct phy *of_phy_get(struct device_node *np, const char *con_id);
> struct phy *of_phy_simple_xlate(struct device *dev,
> struct of_phandle_args *args);
> struct phy *phy_create(struct device *dev, struct device_node *node,
> - const struct phy_ops *ops,
> - struct phy_init_data *init_data);
> + const struct phy_ops *ops);
> struct phy *devm_phy_create(struct device *dev, struct device_node *node,
> - const struct phy_ops *ops, struct phy_init_data *init_data);
> + const struct phy_ops *ops);
> void phy_destroy(struct phy *phy);
> void devm_phy_destroy(struct device *dev, struct phy *phy);
> struct phy_provider *__of_phy_provider_register(struct device *dev,
> @@ -310,16 +282,14 @@ static inline struct phy *of_phy_simple_xlate(struct device *dev,
>
> static inline struct phy *phy_create(struct device *dev,
> struct device_node *node,
> - const struct phy_ops *ops,
> - struct phy_init_data *init_data)
> + const struct phy_ops *ops)
> {
> return ERR_PTR(-ENOSYS);
> }
>
> static inline struct phy *devm_phy_create(struct device *dev,
> struct device_node *node,
> - const struct phy_ops *ops,
> - struct phy_init_data *init_data)
> + const struct phy_ops *ops)
> {
> return ERR_PTR(-ENOSYS);
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] phy: remove the old lookup method
2014-11-22 8:27 [PATCH] phy: remove the old lookup method Kishon Vijay Abraham I
2014-11-22 8:33 ` Kishon Vijay Abraham I
@ 2014-11-28 11:57 ` Linus Walleij
1 sibling, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2014-11-28 11:57 UTC (permalink / raw)
To: Kishon Vijay Abraham I
Cc: Heikki Krogerus, gautam.vivek, andrew.kim, Stephen Warren,
Thierry Reding, Alexandre Courbot, linux-kernel
On Sat, Nov 22, 2014 at 9:27 AM, Kishon Vijay Abraham I <kishon@ti.com> wrote:
> From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>
> The users of the old method are now converted to the new one.
>
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> [ kishon@ti.com : made phy-berlin-usb.c and phy-miphy28lp.c to use the updated
> devm_phy_create API.]
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
> Two new PHY drivers phy-berlin-usb.c and phy-miphy28lp.c were added which was using the old
> devm_phy_create signature. Made it to use the new devm_phy_create signatiure.
Acked-by: Linus Walleij <linus.walleij@linaro.org>
I guess this will be applied to the PHY tree.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 0/5] phy: remove the need for the phys to know about their users
@ 2013-12-09 15:08 Heikki Krogerus
2013-12-09 15:08 ` Heikki Krogerus
0 siblings, 1 reply; 5+ messages in thread
From: Heikki Krogerus @ 2013-12-09 15:08 UTC (permalink / raw)
To: Kishon Vijay Abraham I
Cc: linux-omap, linux-arm-kernel, linux-kernel, linux-samsung-soc
Hi,
This replaces the consumer & init_data structures with a lookup table
that contains complete associations with the phys and their users,
removing the need for the phy drivers themselves to care about their
users even when not using DT.
The lookup method is copied from the way the gpio descriptor lookup is
now handled in gpiolib.c.
Heikki Krogerus (5):
phy: unify the phy name parameters
phy: add support for indexed lookup
phy: improved lookup method
arm: omap3: twl: use the new lookup method with usb phy
phy: remove the old lookup method
arch/arm/mach-omap2/twl-common.c | 15 ++-
drivers/phy/phy-core.c | 209 ++++++++++++++++++++++++++----------
drivers/phy/phy-exynos-dp-video.c | 2 +-
drivers/phy/phy-exynos-mipi-video.c | 2 +-
drivers/phy/phy-omap-usb2.c | 2 +-
drivers/phy/phy-twl4030-usb.c | 4 +-
include/linux/phy/phy.h | 86 ++++++++++-----
7 files changed, 221 insertions(+), 99 deletions(-)
--
1.8.5.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] phy: remove the old lookup method
2013-12-09 15:08 [PATCH 0/5] phy: remove the need for the phys to know about their users Heikki Krogerus
@ 2013-12-09 15:08 ` Heikki Krogerus
0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2013-12-09 15:08 UTC (permalink / raw)
To: Kishon Vijay Abraham I
Cc: linux-omap, linux-arm-kernel, linux-kernel, linux-samsung-soc,
Kukjin Kim, Tony Lindgren
The users of the old method are now converted to the new one.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
Documentation/phy.txt | 100 ++++++++++++++++++++++--------------
drivers/phy/phy-core.c | 46 ++---------------
drivers/phy/phy-exynos-dp-video.c | 2 +-
drivers/phy/phy-exynos-mipi-video.c | 2 +-
drivers/phy/phy-omap-usb2.c | 2 +-
drivers/phy/phy-twl4030-usb.c | 4 +-
include/linux/phy/phy.h | 36 ++-----------
7 files changed, 73 insertions(+), 119 deletions(-)
diff --git a/Documentation/phy.txt b/Documentation/phy.txt
index 0103e4b..cfff1a2 100644
--- a/Documentation/phy.txt
+++ b/Documentation/phy.txt
@@ -53,17 +53,13 @@ unregister the PHY.
The PHY driver should create the PHY in order for other peripheral controllers
to make use of it. The PHY framework provides 2 APIs to create the PHY.
-struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data);
-struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data);
+struct phy *phy_create(struct device *dev, const struct phy_ops *ops);
+struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops);
The PHY drivers can use one of the above 2 APIs to create the PHY by passing
-the device pointer, phy ops and init_data.
+the device pointer, phy ops.
phy_ops is a set of function pointers for performing PHY operations such as
-init, exit, power_on and power_off. *init_data* is mandatory to get a reference
-to the PHY in the case of non-dt boot. See section *Board File Initialization*
-on how init_data should be used.
+init, exit, power_on and power_off.
Inorder to dereference the private data (in phy_ops), the phy provider driver
can use phy_set_drvdata() after creating the PHY and use phy_get_drvdata() in
@@ -74,16 +70,21 @@ phy_ops to get back the private data.
Before the controller can make use of the PHY, it has to get a reference to
it. This framework provides the following APIs to get a reference to the PHY.
-struct phy *phy_get(struct device *dev, const char *string);
-struct phy *devm_phy_get(struct device *dev, const char *string);
+struct phy *phy_get(struct device *dev, const char *con_id);
+struct phy *devm_phy_get(struct device *dev, const char *con_id);
phy_get and devm_phy_get can be used to get the PHY. In the case of dt boot,
-the string arguments should contain the phy name as given in the dt data and
+the con_id arguments should contain the phy name as given in the dt data and
in the case of non-dt boot, it should contain the label of the PHY.
The only difference between the two APIs is that devm_phy_get associates the
device with the PHY using devres on successful PHY get. On driver detach,
release function is invoked on the the devres data and devres data is freed.
+Indexed lookup is also possible when device has multiple PHYs attached to it.
+The framework provides variants for phy_get() functions called phy_get_index()
+and devm_phy_get_index(). They take the same parameters as do the normal
+phy_get() plus the index number of the PHY as the last parameter.
+
5. Releasing a reference to the PHY
When the controller no longer needs the PHY, it has to release the reference
@@ -123,42 +124,63 @@ There are exported APIs like phy_pm_runtime_get, phy_pm_runtime_get_sync,
phy_pm_runtime_put, phy_pm_runtime_put_sync, phy_pm_runtime_allow and
phy_pm_runtime_forbid for performing PM operations.
-8. Board File Initialization
+8. Platform Data binding
-Certain board file initialization is necessary in order to get a reference
-to the PHY in the case of non-dt boot.
-Say we have a single device that implements 3 PHYs that of USB, SATA and PCIe,
-then in the board file the following initialization should be done.
+PHY's are mapped by the means of tables of lookups, containing instances of the
+phy_lookup structure. Two macros are defined to help declaring such mappings:
-struct phy_consumer consumers[] = {
- PHY_CONSUMER("dwc3.0", "usb"),
- PHY_CONSUMER("pcie.0", "pcie"),
- PHY_CONSUMER("sata.0", "sata"),
-};
-PHY_CONSUMER takes 2 parameters, first is the device name of the controller
-(PHY consumer) and second is the port name.
+ PHY_LOOKUP(phy_name, con_id)
+ PHY_LOOKUP_IDX(phy_name, con_id, idx)
+
+where
-struct phy_init_data init_data = {
- .consumers = consumers,
- .num_consumers = ARRAY_SIZE(consumers),
+ - phy_name identifiers of the phy device
+ - con_id is the name of the PHY from the device point of view. It can be NULL.
+ - idx is the index of the PHY within the function.
+
+A lookup table can then be defined as follows, with an empty entry defining its
+end:
+
+struct phy_lookup_table phys_table = {
+ .dev_id = "usb_controller.0",
+ .table = {
+ PHY_LOOKUP_IDX("phy-usb2phy.0", "usb2-phy", 0),
+ PHY_LOOKUP_IDX("phy-usb3phy.0", "usb3-phy", 1),
+ { },
+ },
};
-static const struct platform_device pipe3_phy_dev = {
- .name = "pipe3-phy",
- .id = -1,
- .dev = {
- .platform_data = {
- .init_data = &init_data,
- },
- },
+or when there is only single PHY:
+
+struct phy_lookup_table phy_table = {
+ .dev_id = "foo.0",
+ .table = PHY_LOOKUP("phy.0", NULL),
};
-then, while doing phy_create, the PHY driver should pass this init_data
- phy_create(dev, ops, pdata->init_data);
+And the table can be added by the board code as follows:
+
+ phy_add_table(&phys_table);
+and
+ phy_add_table(&phy_table);
+
+The driver controlling "usb_controller.0" will then be able to obtain its PHYs
+as follows:
+
+ struct phy *usb2_phy, usb3_phy;
+
+ usb2_phy = phy_get(dev, "usb2-phy");
+ usb3_phy = phy_get(dev, "usb3-phy");
+or
+ usb2_phy = phy_get_index(dev, "usb2-phy", 0);
+ usb3_phy = phy_get_index(dev, "usb3-phy", 1);
+
+The driver controlling "foo.0" can obtain its PHY as follows:
+
+ struct phy *phy;
-and the controller driver (phy consumer) should pass the port name along with
-the device to get a reference to the PHY
- phy_get(dev, "pcie");
+ phy = phy_get(dev, NULL);
+or
+ phy = phy_get_index(dev, NULL, 0);
9. DeviceTree Binding
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 05792d0..26f19ee 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -54,38 +54,6 @@ static int devm_phy_match(struct device *dev, void *res, void *match_data)
return res == match_data;
}
-static struct phy *phy_lookup(struct device *device, const char *con_id,
- unsigned int idx)
-{
- unsigned int count;
- struct phy *phy;
- struct device *dev;
- struct phy_consumer *consumers;
- struct class_dev_iter iter;
-
- class_dev_iter_init(&iter, phy_class, NULL, NULL);
- while ((dev = class_dev_iter_next(&iter))) {
- phy = to_phy(dev);
- count = phy->init_data->num_consumers;
- consumers = phy->init_data->consumers;
- while (count--) {
- /* index must always match exactly */
- if (!con_id)
- if (idx != count)
- continue;
- if (!strcmp(consumers->dev_name, dev_name(device)) &&
- !strcmp(consumers->port, con_id)) {
- class_dev_iter_exit(&iter);
- return phy;
- }
- consumers++;
- }
- }
-
- class_dev_iter_exit(&iter);
- return ERR_PTR(-ENODEV);
-}
-
/**
* phy_add_table() - register PHY/device association to the lookup list
* @table: association to register
@@ -150,8 +118,7 @@ static struct phy *phy_find(struct device *dev, const char *con_id,
table = phy_get_lookup_table(dev);
if (!table)
- /* fall-back to the old lookup method for now */
- return phy_lookup(dev, con_id, idx);
+ return ERR_PTR(-ENODEV);
for (p = &table->table[0]; p->phy_name; p++) {
/* index must always match exactly */
@@ -557,12 +524,10 @@ EXPORT_SYMBOL_GPL(devm_phy_get);
* phy_create() - create a new phy
* @dev: device that is creating the new phy
* @ops: function pointers for performing phy operations
- * @init_data: contains the list of PHY consumers or NULL
*
* Called to create a phy using phy framework.
*/
-struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data)
+struct phy *phy_create(struct device *dev, const struct phy_ops *ops)
{
int ret;
int id;
@@ -595,7 +560,6 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
phy->dev.of_node = dev->of_node;
phy->id = id;
phy->ops = ops;
- phy->init_data = init_data;
ret = dev_set_name(&phy->dev, "phy-%s.%d", dev_name(dev), id);
if (ret)
@@ -626,15 +590,13 @@ EXPORT_SYMBOL_GPL(phy_create);
* devm_phy_create() - create a new phy
* @dev: device that is creating the new phy
* @ops: function pointers for performing phy operations
- * @init_data: contains the list of PHY consumers or NULL
*
* Creates a new PHY device adding it to the PHY class.
* While at that, it also associates the device with the phy using devres.
* On driver detach, release function is invoked on the devres data,
* then, devres data is freed.
*/
-struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data)
+struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops)
{
struct phy **ptr, *phy;
@@ -642,7 +604,7 @@ struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
if (!ptr)
return ERR_PTR(-ENOMEM);
- phy = phy_create(dev, ops, init_data);
+ phy = phy_create(dev, ops);
if (!IS_ERR(phy)) {
*ptr = phy;
devres_add(dev, ptr);
diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c
index 1dbe6ce..e6c5065 100644
--- a/drivers/phy/phy-exynos-dp-video.c
+++ b/drivers/phy/phy-exynos-dp-video.c
@@ -80,7 +80,7 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
if (IS_ERR(phy_provider))
return PTR_ERR(phy_provider);
- phy = devm_phy_create(dev, &exynos_dp_video_phy_ops, NULL);
+ phy = devm_phy_create(dev, &exynos_dp_video_phy_ops);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create Display Port PHY\n");
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c
index 0c5efab..900a14d 100644
--- a/drivers/phy/phy-exynos-mipi-video.c
+++ b/drivers/phy/phy-exynos-mipi-video.c
@@ -141,7 +141,7 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)
for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) {
struct phy *phy = devm_phy_create(dev,
- &exynos_mipi_video_phy_ops, NULL);
+ &exynos_mipi_video_phy_ops);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create PHY %d\n", i);
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index bfc5c33..87c9d8b 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -208,7 +208,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, phy);
pm_runtime_enable(phy->dev);
- generic_phy = devm_phy_create(phy->dev, &ops, NULL);
+ generic_phy = devm_phy_create(phy->dev, &ops);
if (IS_ERR(generic_phy))
return PTR_ERR(generic_phy);
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index daf65e6..bcc2f7d 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -659,7 +659,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
struct usb_otg *otg;
struct device_node *np = pdev->dev.of_node;
struct phy_provider *phy_provider;
- struct phy_init_data *init_data = NULL;
twl = devm_kzalloc(&pdev->dev, sizeof *twl, GFP_KERNEL);
if (!twl)
@@ -670,7 +669,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
(enum twl4030_usb_mode *)&twl->usb_mode);
else if (pdata) {
twl->usb_mode = pdata->usb_mode;
- init_data = pdata->init_data;
} else {
dev_err(&pdev->dev, "twl4030 initialized without pdata\n");
return -EINVAL;
@@ -700,7 +698,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
if (IS_ERR(phy_provider))
return PTR_ERR(phy_provider);
- phy = devm_phy_create(twl->dev, &ops, init_data);
+ phy = devm_phy_create(twl->dev, &ops);
if (IS_ERR(phy)) {
dev_dbg(&pdev->dev, "Failed to create PHY\n");
return PTR_ERR(phy);
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index cca363a..a0fd30f 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -73,32 +73,6 @@ struct phy_provider {
};
/**
- * struct phy_consumer - represents the phy consumer
- * @dev_name: the device name of the controller that will use this PHY device
- * @port: name given to the consumer port
- */
-struct phy_consumer {
- const char *dev_name;
- const char *port;
-};
-
-/**
- * struct phy_init_data - contains the list of PHY consumers
- * @num_consumers: number of consumers for this PHY device
- * @consumers: list of PHY consumers
- */
-struct phy_init_data {
- unsigned int num_consumers;
- struct phy_consumer *consumers;
-};
-
-#define PHY_CONSUMER(_dev_name, _port) \
-{ \
- .dev_name = _dev_name, \
- .port = _port, \
-}
-
-/**
* struct phy_lookup - Lookup entry for associating PHYs
* @phy_name: device name of the PHY
* @con_id: name of the PHY from device's point of view
@@ -183,10 +157,8 @@ void phy_put(struct phy *phy);
void devm_phy_put(struct device *dev, struct phy *phy);
struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
-struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data);
-struct phy *devm_phy_create(struct device *dev,
- const struct phy_ops *ops, struct phy_init_data *init_data);
+struct phy *phy_create(struct device *dev, const struct phy_ops *ops);
+struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops);
void phy_destroy(struct phy *phy);
void devm_phy_destroy(struct device *dev, struct phy *phy);
struct phy_provider *__of_phy_provider_register(struct device *dev,
@@ -286,13 +258,13 @@ static inline struct phy *of_phy_simple_xlate(struct device *dev,
}
static inline struct phy *phy_create(struct device *dev,
- const struct phy_ops *ops, struct phy_init_data *init_data)
+ const struct phy_ops *ops)
{
return ERR_PTR(-ENOSYS);
}
static inline struct phy *devm_phy_create(struct device *dev,
- const struct phy_ops *ops, struct phy_init_data *init_data)
+ const struct phy_ops *ops)
{
return ERR_PTR(-ENOSYS);
}
--
1.8.5.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] phy: remove the old lookup method
@ 2013-12-09 15:08 ` Heikki Krogerus
0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2013-12-09 15:08 UTC (permalink / raw)
To: linux-arm-kernel
The users of the old method are now converted to the new one.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
Documentation/phy.txt | 100 ++++++++++++++++++++++--------------
drivers/phy/phy-core.c | 46 ++---------------
drivers/phy/phy-exynos-dp-video.c | 2 +-
drivers/phy/phy-exynos-mipi-video.c | 2 +-
drivers/phy/phy-omap-usb2.c | 2 +-
drivers/phy/phy-twl4030-usb.c | 4 +-
include/linux/phy/phy.h | 36 ++-----------
7 files changed, 73 insertions(+), 119 deletions(-)
diff --git a/Documentation/phy.txt b/Documentation/phy.txt
index 0103e4b..cfff1a2 100644
--- a/Documentation/phy.txt
+++ b/Documentation/phy.txt
@@ -53,17 +53,13 @@ unregister the PHY.
The PHY driver should create the PHY in order for other peripheral controllers
to make use of it. The PHY framework provides 2 APIs to create the PHY.
-struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data);
-struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data);
+struct phy *phy_create(struct device *dev, const struct phy_ops *ops);
+struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops);
The PHY drivers can use one of the above 2 APIs to create the PHY by passing
-the device pointer, phy ops and init_data.
+the device pointer, phy ops.
phy_ops is a set of function pointers for performing PHY operations such as
-init, exit, power_on and power_off. *init_data* is mandatory to get a reference
-to the PHY in the case of non-dt boot. See section *Board File Initialization*
-on how init_data should be used.
+init, exit, power_on and power_off.
Inorder to dereference the private data (in phy_ops), the phy provider driver
can use phy_set_drvdata() after creating the PHY and use phy_get_drvdata() in
@@ -74,16 +70,21 @@ phy_ops to get back the private data.
Before the controller can make use of the PHY, it has to get a reference to
it. This framework provides the following APIs to get a reference to the PHY.
-struct phy *phy_get(struct device *dev, const char *string);
-struct phy *devm_phy_get(struct device *dev, const char *string);
+struct phy *phy_get(struct device *dev, const char *con_id);
+struct phy *devm_phy_get(struct device *dev, const char *con_id);
phy_get and devm_phy_get can be used to get the PHY. In the case of dt boot,
-the string arguments should contain the phy name as given in the dt data and
+the con_id arguments should contain the phy name as given in the dt data and
in the case of non-dt boot, it should contain the label of the PHY.
The only difference between the two APIs is that devm_phy_get associates the
device with the PHY using devres on successful PHY get. On driver detach,
release function is invoked on the the devres data and devres data is freed.
+Indexed lookup is also possible when device has multiple PHYs attached to it.
+The framework provides variants for phy_get() functions called phy_get_index()
+and devm_phy_get_index(). They take the same parameters as do the normal
+phy_get() plus the index number of the PHY as the last parameter.
+
5. Releasing a reference to the PHY
When the controller no longer needs the PHY, it has to release the reference
@@ -123,42 +124,63 @@ There are exported APIs like phy_pm_runtime_get, phy_pm_runtime_get_sync,
phy_pm_runtime_put, phy_pm_runtime_put_sync, phy_pm_runtime_allow and
phy_pm_runtime_forbid for performing PM operations.
-8. Board File Initialization
+8. Platform Data binding
-Certain board file initialization is necessary in order to get a reference
-to the PHY in the case of non-dt boot.
-Say we have a single device that implements 3 PHYs that of USB, SATA and PCIe,
-then in the board file the following initialization should be done.
+PHY's are mapped by the means of tables of lookups, containing instances of the
+phy_lookup structure. Two macros are defined to help declaring such mappings:
-struct phy_consumer consumers[] = {
- PHY_CONSUMER("dwc3.0", "usb"),
- PHY_CONSUMER("pcie.0", "pcie"),
- PHY_CONSUMER("sata.0", "sata"),
-};
-PHY_CONSUMER takes 2 parameters, first is the device name of the controller
-(PHY consumer) and second is the port name.
+ PHY_LOOKUP(phy_name, con_id)
+ PHY_LOOKUP_IDX(phy_name, con_id, idx)
+
+where
-struct phy_init_data init_data = {
- .consumers = consumers,
- .num_consumers = ARRAY_SIZE(consumers),
+ - phy_name identifiers of the phy device
+ - con_id is the name of the PHY from the device point of view. It can be NULL.
+ - idx is the index of the PHY within the function.
+
+A lookup table can then be defined as follows, with an empty entry defining its
+end:
+
+struct phy_lookup_table phys_table = {
+ .dev_id = "usb_controller.0",
+ .table = {
+ PHY_LOOKUP_IDX("phy-usb2phy.0", "usb2-phy", 0),
+ PHY_LOOKUP_IDX("phy-usb3phy.0", "usb3-phy", 1),
+ { },
+ },
};
-static const struct platform_device pipe3_phy_dev = {
- .name = "pipe3-phy",
- .id = -1,
- .dev = {
- .platform_data = {
- .init_data = &init_data,
- },
- },
+or when there is only single PHY:
+
+struct phy_lookup_table phy_table = {
+ .dev_id = "foo.0",
+ .table = PHY_LOOKUP("phy.0", NULL),
};
-then, while doing phy_create, the PHY driver should pass this init_data
- phy_create(dev, ops, pdata->init_data);
+And the table can be added by the board code as follows:
+
+ phy_add_table(&phys_table);
+and
+ phy_add_table(&phy_table);
+
+The driver controlling "usb_controller.0" will then be able to obtain its PHYs
+as follows:
+
+ struct phy *usb2_phy, usb3_phy;
+
+ usb2_phy = phy_get(dev, "usb2-phy");
+ usb3_phy = phy_get(dev, "usb3-phy");
+or
+ usb2_phy = phy_get_index(dev, "usb2-phy", 0);
+ usb3_phy = phy_get_index(dev, "usb3-phy", 1);
+
+The driver controlling "foo.0" can obtain its PHY as follows:
+
+ struct phy *phy;
-and the controller driver (phy consumer) should pass the port name along with
-the device to get a reference to the PHY
- phy_get(dev, "pcie");
+ phy = phy_get(dev, NULL);
+or
+ phy = phy_get_index(dev, NULL, 0);
9. DeviceTree Binding
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 05792d0..26f19ee 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -54,38 +54,6 @@ static int devm_phy_match(struct device *dev, void *res, void *match_data)
return res == match_data;
}
-static struct phy *phy_lookup(struct device *device, const char *con_id,
- unsigned int idx)
-{
- unsigned int count;
- struct phy *phy;
- struct device *dev;
- struct phy_consumer *consumers;
- struct class_dev_iter iter;
-
- class_dev_iter_init(&iter, phy_class, NULL, NULL);
- while ((dev = class_dev_iter_next(&iter))) {
- phy = to_phy(dev);
- count = phy->init_data->num_consumers;
- consumers = phy->init_data->consumers;
- while (count--) {
- /* index must always match exactly */
- if (!con_id)
- if (idx != count)
- continue;
- if (!strcmp(consumers->dev_name, dev_name(device)) &&
- !strcmp(consumers->port, con_id)) {
- class_dev_iter_exit(&iter);
- return phy;
- }
- consumers++;
- }
- }
-
- class_dev_iter_exit(&iter);
- return ERR_PTR(-ENODEV);
-}
-
/**
* phy_add_table() - register PHY/device association to the lookup list
* @table: association to register
@@ -150,8 +118,7 @@ static struct phy *phy_find(struct device *dev, const char *con_id,
table = phy_get_lookup_table(dev);
if (!table)
- /* fall-back to the old lookup method for now */
- return phy_lookup(dev, con_id, idx);
+ return ERR_PTR(-ENODEV);
for (p = &table->table[0]; p->phy_name; p++) {
/* index must always match exactly */
@@ -557,12 +524,10 @@ EXPORT_SYMBOL_GPL(devm_phy_get);
* phy_create() - create a new phy
* @dev: device that is creating the new phy
* @ops: function pointers for performing phy operations
- * @init_data: contains the list of PHY consumers or NULL
*
* Called to create a phy using phy framework.
*/
-struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data)
+struct phy *phy_create(struct device *dev, const struct phy_ops *ops)
{
int ret;
int id;
@@ -595,7 +560,6 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
phy->dev.of_node = dev->of_node;
phy->id = id;
phy->ops = ops;
- phy->init_data = init_data;
ret = dev_set_name(&phy->dev, "phy-%s.%d", dev_name(dev), id);
if (ret)
@@ -626,15 +590,13 @@ EXPORT_SYMBOL_GPL(phy_create);
* devm_phy_create() - create a new phy
* @dev: device that is creating the new phy
* @ops: function pointers for performing phy operations
- * @init_data: contains the list of PHY consumers or NULL
*
* Creates a new PHY device adding it to the PHY class.
* While at that, it also associates the device with the phy using devres.
* On driver detach, release function is invoked on the devres data,
* then, devres data is freed.
*/
-struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data)
+struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops)
{
struct phy **ptr, *phy;
@@ -642,7 +604,7 @@ struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
if (!ptr)
return ERR_PTR(-ENOMEM);
- phy = phy_create(dev, ops, init_data);
+ phy = phy_create(dev, ops);
if (!IS_ERR(phy)) {
*ptr = phy;
devres_add(dev, ptr);
diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c
index 1dbe6ce..e6c5065 100644
--- a/drivers/phy/phy-exynos-dp-video.c
+++ b/drivers/phy/phy-exynos-dp-video.c
@@ -80,7 +80,7 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
if (IS_ERR(phy_provider))
return PTR_ERR(phy_provider);
- phy = devm_phy_create(dev, &exynos_dp_video_phy_ops, NULL);
+ phy = devm_phy_create(dev, &exynos_dp_video_phy_ops);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create Display Port PHY\n");
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c
index 0c5efab..900a14d 100644
--- a/drivers/phy/phy-exynos-mipi-video.c
+++ b/drivers/phy/phy-exynos-mipi-video.c
@@ -141,7 +141,7 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)
for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) {
struct phy *phy = devm_phy_create(dev,
- &exynos_mipi_video_phy_ops, NULL);
+ &exynos_mipi_video_phy_ops);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create PHY %d\n", i);
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index bfc5c33..87c9d8b 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -208,7 +208,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, phy);
pm_runtime_enable(phy->dev);
- generic_phy = devm_phy_create(phy->dev, &ops, NULL);
+ generic_phy = devm_phy_create(phy->dev, &ops);
if (IS_ERR(generic_phy))
return PTR_ERR(generic_phy);
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index daf65e6..bcc2f7d 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -659,7 +659,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
struct usb_otg *otg;
struct device_node *np = pdev->dev.of_node;
struct phy_provider *phy_provider;
- struct phy_init_data *init_data = NULL;
twl = devm_kzalloc(&pdev->dev, sizeof *twl, GFP_KERNEL);
if (!twl)
@@ -670,7 +669,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
(enum twl4030_usb_mode *)&twl->usb_mode);
else if (pdata) {
twl->usb_mode = pdata->usb_mode;
- init_data = pdata->init_data;
} else {
dev_err(&pdev->dev, "twl4030 initialized without pdata\n");
return -EINVAL;
@@ -700,7 +698,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
if (IS_ERR(phy_provider))
return PTR_ERR(phy_provider);
- phy = devm_phy_create(twl->dev, &ops, init_data);
+ phy = devm_phy_create(twl->dev, &ops);
if (IS_ERR(phy)) {
dev_dbg(&pdev->dev, "Failed to create PHY\n");
return PTR_ERR(phy);
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index cca363a..a0fd30f 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -73,32 +73,6 @@ struct phy_provider {
};
/**
- * struct phy_consumer - represents the phy consumer
- * @dev_name: the device name of the controller that will use this PHY device
- * @port: name given to the consumer port
- */
-struct phy_consumer {
- const char *dev_name;
- const char *port;
-};
-
-/**
- * struct phy_init_data - contains the list of PHY consumers
- * @num_consumers: number of consumers for this PHY device
- * @consumers: list of PHY consumers
- */
-struct phy_init_data {
- unsigned int num_consumers;
- struct phy_consumer *consumers;
-};
-
-#define PHY_CONSUMER(_dev_name, _port) \
-{ \
- .dev_name = _dev_name, \
- .port = _port, \
-}
-
-/**
* struct phy_lookup - Lookup entry for associating PHYs
* @phy_name: device name of the PHY
* @con_id: name of the PHY from device's point of view
@@ -183,10 +157,8 @@ void phy_put(struct phy *phy);
void devm_phy_put(struct device *dev, struct phy *phy);
struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
-struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data);
-struct phy *devm_phy_create(struct device *dev,
- const struct phy_ops *ops, struct phy_init_data *init_data);
+struct phy *phy_create(struct device *dev, const struct phy_ops *ops);
+struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops);
void phy_destroy(struct phy *phy);
void devm_phy_destroy(struct device *dev, struct phy *phy);
struct phy_provider *__of_phy_provider_register(struct device *dev,
@@ -286,13 +258,13 @@ static inline struct phy *of_phy_simple_xlate(struct device *dev,
}
static inline struct phy *phy_create(struct device *dev,
- const struct phy_ops *ops, struct phy_init_data *init_data)
+ const struct phy_ops *ops)
{
return ERR_PTR(-ENOSYS);
}
static inline struct phy *devm_phy_create(struct device *dev,
- const struct phy_ops *ops, struct phy_init_data *init_data)
+ const struct phy_ops *ops)
{
return ERR_PTR(-ENOSYS);
}
--
1.8.5.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-11-28 11:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-22 8:27 [PATCH] phy: remove the old lookup method Kishon Vijay Abraham I
2014-11-22 8:33 ` Kishon Vijay Abraham I
2014-11-28 11:57 ` Linus Walleij
-- strict thread matches above, loose matches on Subject: below --
2013-12-09 15:08 [PATCH 0/5] phy: remove the need for the phys to know about their users Heikki Krogerus
2013-12-09 15:08 ` [PATCH] phy: remove the old lookup method Heikki Krogerus
2013-12-09 15:08 ` Heikki Krogerus
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.