aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ohci-jz4740.c
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-12-11 02:24:17 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-18 19:35:11 -0500
commitc81c3b0115d7d1bd83137eb800ed6c16c86182e2 (patch)
treec0768f267240c8d88c633d71afcd740c2508cd11 /drivers/usb/host/ohci-jz4740.c
parentf1080e4d90b2c0ec3ce850a9fad8ac8a79df3b23 (diff)
USB: ohci-jz4740: Use devm_*() functions
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/ohci-jz4740.c')
-rw-r--r--drivers/usb/host/ohci-jz4740.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/drivers/usb/host/ohci-jz4740.c b/drivers/usb/host/ohci-jz4740.c
index efe31f3ab4ea..af8dc1b92d75 100644
--- a/drivers/usb/host/ohci-jz4740.c
+++ b/drivers/usb/host/ohci-jz4740.c
@@ -174,31 +174,23 @@ static int jz4740_ohci_probe(struct platform_device *pdev)
174 174
175 jz4740_ohci = hcd_to_jz4740_hcd(hcd); 175 jz4740_ohci = hcd_to_jz4740_hcd(hcd);
176 176
177 res = request_mem_region(res->start, resource_size(res), hcd_name);
178 if (!res) {
179 dev_err(&pdev->dev, "Failed to request mem region.\n");
180 ret = -EBUSY;
181 goto err_free;
182 }
183
184 hcd->rsrc_start = res->start; 177 hcd->rsrc_start = res->start;
185 hcd->rsrc_len = resource_size(res); 178 hcd->rsrc_len = resource_size(res);
186 hcd->regs = ioremap(res->start, resource_size(res));
187 179
188 if (!hcd->regs) { 180 hcd->regs = devm_ioremap_resource(&pdev->dev, res);
189 dev_err(&pdev->dev, "Failed to ioremap registers.\n"); 181 if (IS_ERR(hcd->regs)) {
190 ret = -EBUSY; 182 ret = PTR_ERR(hcd->regs);
191 goto err_release_mem; 183 goto err_free;
192 } 184 }
193 185
194 jz4740_ohci->clk = clk_get(&pdev->dev, "uhc"); 186 jz4740_ohci->clk = devm_clk_get(&pdev->dev, "uhc");
195 if (IS_ERR(jz4740_ohci->clk)) { 187 if (IS_ERR(jz4740_ohci->clk)) {
196 ret = PTR_ERR(jz4740_ohci->clk); 188 ret = PTR_ERR(jz4740_ohci->clk);
197 dev_err(&pdev->dev, "Failed to get clock: %d\n", ret); 189 dev_err(&pdev->dev, "Failed to get clock: %d\n", ret);
198 goto err_iounmap; 190 goto err_free;
199 } 191 }
200 192
201 jz4740_ohci->vbus = regulator_get(&pdev->dev, "vbus"); 193 jz4740_ohci->vbus = devm_regulator_get(&pdev->dev, "vbus");
202 if (IS_ERR(jz4740_ohci->vbus)) 194 if (IS_ERR(jz4740_ohci->vbus))
203 jz4740_ohci->vbus = NULL; 195 jz4740_ohci->vbus = NULL;
204 196
@@ -222,17 +214,10 @@ static int jz4740_ohci_probe(struct platform_device *pdev)
222 return 0; 214 return 0;
223 215
224err_disable: 216err_disable:
225 if (jz4740_ohci->vbus) { 217 if (jz4740_ohci->vbus)
226 regulator_disable(jz4740_ohci->vbus); 218 regulator_disable(jz4740_ohci->vbus);
227 regulator_put(jz4740_ohci->vbus);
228 }
229 clk_disable(jz4740_ohci->clk); 219 clk_disable(jz4740_ohci->clk);
230 220
231 clk_put(jz4740_ohci->clk);
232err_iounmap:
233 iounmap(hcd->regs);
234err_release_mem:
235 release_mem_region(res->start, resource_size(res));
236err_free: 221err_free:
237 usb_put_hcd(hcd); 222 usb_put_hcd(hcd);
238 223
@@ -246,16 +231,10 @@ static int jz4740_ohci_remove(struct platform_device *pdev)
246 231
247 usb_remove_hcd(hcd); 232 usb_remove_hcd(hcd);
248 233
249 if (jz4740_ohci->vbus) { 234 if (jz4740_ohci->vbus)
250 regulator_disable(jz4740_ohci->vbus); 235 regulator_disable(jz4740_ohci->vbus);
251 regulator_put(jz4740_ohci->vbus);
252 }
253 236
254 clk_disable(jz4740_ohci->clk); 237 clk_disable(jz4740_ohci->clk);
255 clk_put(jz4740_ohci->clk);
256
257 iounmap(hcd->regs);
258 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
259 238
260 usb_put_hcd(hcd); 239 usb_put_hcd(hcd);
261 240