aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ohci-ep93xx.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hartleys@visionengravers.com>2013-07-01 18:52:42 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-26 16:54:29 -0400
commit8bd3902d8be2b4ba484d5dbbe0f30b73b2f8c017 (patch)
tree7ea8e87ddd9054e09ed61b478ae8876f5dadec51 /drivers/usb/host/ohci-ep93xx.c
parent140983c283b302167b387646218a97f112cc0c03 (diff)
usb: ohci-ep93xx: use devm_ioremap_resource()
Use devm_ioremap_resource() to make the code a bit cleaner and simpler. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Cc: Lennert Buytenhek <kernel@wantstofly.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/ohci-ep93xx.c')
-rw-r--r--drivers/usb/host/ohci-ep93xx.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 8704e9fa5a80..4e12f67a32dd 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -43,38 +43,37 @@ static void ep93xx_stop_hc(struct device *dev)
43static int usb_hcd_ep93xx_probe(const struct hc_driver *driver, 43static int usb_hcd_ep93xx_probe(const struct hc_driver *driver,
44 struct platform_device *pdev) 44 struct platform_device *pdev)
45{ 45{
46 int retval;
47 struct usb_hcd *hcd; 46 struct usb_hcd *hcd;
47 struct resource *res;
48 int retval;
48 49
49 if (pdev->resource[1].flags != IORESOURCE_IRQ) { 50 if (pdev->resource[1].flags != IORESOURCE_IRQ) {
50 dev_dbg(&pdev->dev, "resource[1] is not IORESOURCE_IRQ\n"); 51 dev_dbg(&pdev->dev, "resource[1] is not IORESOURCE_IRQ\n");
51 return -ENOMEM; 52 return -ENOMEM;
52 } 53 }
53 54
55 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
56 if (!res)
57 return -ENXIO;
58
54 hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx"); 59 hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx");
55 if (hcd == NULL) 60 if (hcd == NULL)
56 return -ENOMEM; 61 return -ENOMEM;
57 62
58 hcd->rsrc_start = pdev->resource[0].start; 63 hcd->rsrc_start = res->start;
59 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; 64 hcd->rsrc_len = resource_size(res);
60 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
61 usb_put_hcd(hcd);
62 retval = -EBUSY;
63 goto err1;
64 }
65 65
66 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 66 hcd->regs = devm_ioremap_resource(&pdev->dev, res);
67 if (hcd->regs == NULL) { 67 if (IS_ERR(hcd->regs)) {
68 dev_dbg(&pdev->dev, "ioremap failed\n"); 68 retval = PTR_ERR(hcd->regs);
69 retval = -ENOMEM; 69 goto err_put_hcd;
70 goto err2;
71 } 70 }
72 71
73 usb_host_clock = clk_get(&pdev->dev, NULL); 72 usb_host_clock = clk_get(&pdev->dev, NULL);
74 if (IS_ERR(usb_host_clock)) { 73 if (IS_ERR(usb_host_clock)) {
75 dev_dbg(&pdev->dev, "clk_get failed\n"); 74 dev_dbg(&pdev->dev, "clk_get failed\n");
76 retval = PTR_ERR(usb_host_clock); 75 retval = PTR_ERR(usb_host_clock);
77 goto err3; 76 goto err_put_hcd;
78 } 77 }
79 78
80 ep93xx_start_hc(&pdev->dev); 79 ep93xx_start_hc(&pdev->dev);
@@ -86,11 +85,7 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver *driver,
86 return retval; 85 return retval;
87 86
88 ep93xx_stop_hc(&pdev->dev); 87 ep93xx_stop_hc(&pdev->dev);
89err3: 88err_put_hcd:
90 iounmap(hcd->regs);
91err2:
92 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
93err1:
94 usb_put_hcd(hcd); 89 usb_put_hcd(hcd);
95 90
96 return retval; 91 return retval;
@@ -102,8 +97,6 @@ static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd,
102 usb_remove_hcd(hcd); 97 usb_remove_hcd(hcd);
103 ep93xx_stop_hc(&pdev->dev); 98 ep93xx_stop_hc(&pdev->dev);
104 clk_put(usb_host_clock); 99 clk_put(usb_host_clock);
105 iounmap(hcd->regs);
106 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
107 usb_put_hcd(hcd); 100 usb_put_hcd(hcd);
108} 101}
109 102