aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/chipidea
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-06-13 11:00:00 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-17 16:47:24 -0400
commitea1418b5f1a394d11c8cdb91ef19d24dcd9c0045 (patch)
treeae58876290b1f9e16d762f5145bbf68e45c26fb4 /drivers/usb/chipidea
parent0404ae035149c83fc9a04818aa7da35e482686ea (diff)
usb: chipidea: i.MX: use devm_usb_get_phy_by_phandle to get phy
This patch converts the driver to use devm_usb_get_phy_by_phandle which makes the code smaller and a bit simpler. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/chipidea')
-rw-r--r--drivers/usb/chipidea/ci13xxx_imx.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index 18d83abac7cd..7e6f0674bee3 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -28,7 +28,6 @@
28 ((struct usb_phy *)platform_get_drvdata(pdev)) 28 ((struct usb_phy *)platform_get_drvdata(pdev))
29 29
30struct ci13xxx_imx_data { 30struct ci13xxx_imx_data {
31 struct device_node *phy_np;
32 struct usb_phy *phy; 31 struct usb_phy *phy;
33 struct platform_device *ci_pdev; 32 struct platform_device *ci_pdev;
34 struct clk *clk; 33 struct clk *clk;
@@ -97,9 +96,9 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
97 CI13XXX_PULLUP_ON_VBUS | 96 CI13XXX_PULLUP_ON_VBUS |
98 CI13XXX_DISABLE_STREAMING, 97 CI13XXX_DISABLE_STREAMING,
99 }; 98 };
100 struct platform_device *phy_pdev;
101 struct resource *res; 99 struct resource *res;
102 int ret; 100 int ret;
101 struct usb_phy *phy;
103 102
104 if (of_find_property(pdev->dev.of_node, "fsl,usbmisc", NULL) 103 if (of_find_property(pdev->dev.of_node, "fsl,usbmisc", NULL)
105 && !usbmisc_ops) 104 && !usbmisc_ops)
@@ -131,18 +130,16 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
131 return ret; 130 return ret;
132 } 131 }
133 132
134 data->phy_np = of_parse_phandle(pdev->dev.of_node, "fsl,usbphy", 0); 133 phy = devm_usb_get_phy_by_phandle(&pdev->dev, "fsl,usbphy", 0);
135 if (data->phy_np) { 134 if (!IS_ERR(phy)) {
136 phy_pdev = of_find_device_by_node(data->phy_np); 135 ret = usb_phy_init(phy);
137 if (phy_pdev) { 136 if (ret) {
138 struct usb_phy *phy; 137 dev_err(&pdev->dev, "unable to init phy: %d\n", ret);
139 phy = pdev_to_phy(phy_pdev); 138 goto err_clk;
140 if (phy &&
141 try_module_get(phy_pdev->dev.driver->owner)) {
142 usb_phy_init(phy);
143 data->phy = phy;
144 }
145 } 139 }
140 } else if (PTR_ERR(phy) == -EPROBE_DEFER) {
141 ret = -EPROBE_DEFER;
142 goto err_clk;
146 } 143 }
147 144
148 /* we only support host now, so enable vbus here */ 145 /* we only support host now, so enable vbus here */
@@ -153,7 +150,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
153 dev_err(&pdev->dev, 150 dev_err(&pdev->dev,
154 "Failed to enable vbus regulator, err=%d\n", 151 "Failed to enable vbus regulator, err=%d\n",
155 ret); 152 ret);
156 goto put_np; 153 goto err_clk;
157 } 154 }
158 } else { 155 } else {
159 data->reg_vbus = NULL; 156 data->reg_vbus = NULL;
@@ -207,9 +204,7 @@ disable_device:
207err: 204err:
208 if (data->reg_vbus) 205 if (data->reg_vbus)
209 regulator_disable(data->reg_vbus); 206 regulator_disable(data->reg_vbus);
210put_np: 207err_clk:
211 if (data->phy_np)
212 of_node_put(data->phy_np);
213 clk_disable_unprepare(data->clk); 208 clk_disable_unprepare(data->clk);
214 return ret; 209 return ret;
215} 210}
@@ -229,9 +224,6 @@ static int ci13xxx_imx_remove(struct platform_device *pdev)
229 module_put(data->phy->dev->driver->owner); 224 module_put(data->phy->dev->driver->owner);
230 } 225 }
231 226
232 if (data->phy_np)
233 of_node_put(data->phy_np);
234
235 clk_disable_unprepare(data->clk); 227 clk_disable_unprepare(data->clk);
236 228
237 return 0; 229 return 0;