Skip to content

Commit

Permalink
phy: remove the old lookup method
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Heikki Krogerus authored and Kishon Vijay Abraham I committed Nov 22, 2014
1 parent 61211b1 commit dbc9863
Show file tree
Hide file tree
Showing 27 changed files with 34 additions and 110 deletions.
2 changes: 1 addition & 1 deletion drivers/phy/phy-bcm-kona-usb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-berlin-sata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions drivers/phy/phy-berlin-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
49 changes: 4 additions & 45 deletions drivers/phy/phy-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -741,24 +702,22 @@ 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.
* On driver detach, release function is invoked on the devres data,
* 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;

ptr = devres_alloc(devm_phy_consume, sizeof(*ptr), GFP_KERNEL);
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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-exynos-dp-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-exynos-mipi-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions drivers/phy/phy-exynos5-usbdrd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-exynos5250-sata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-hix5hd2-sata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-miphy28lp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-miphy365x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-mvebu-sata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-omap-usb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions drivers/phy/phy-qcom-apq8064-sata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions drivers/phy/phy-qcom-ipq806x-sata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-rcar-gen2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions drivers/phy/phy-samsung-usb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-spear1310-miphy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-spear1340-miphy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-stih407-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-stih41x-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-sun4i-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-ti-pipe3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-twl4030-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/phy-xgene.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions drivers/pinctrl/pinctrl-tegra-xusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading

0 comments on commit dbc9863

Please sign in to comment.