Commit 8bd3902d authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

usb: ohci-ep93xx: use devm_ioremap_resource()

Use devm_ioremap_resource() to make the code a bit cleaner and
simpler.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Cc: Lennert Buytenhek <kernel@wantstofly.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 140983c2
...@@ -43,38 +43,37 @@ static void ep93xx_stop_hc(struct device *dev) ...@@ -43,38 +43,37 @@ static void ep93xx_stop_hc(struct device *dev)
static int usb_hcd_ep93xx_probe(const struct hc_driver *driver, static int usb_hcd_ep93xx_probe(const struct hc_driver *driver,
struct platform_device *pdev) struct platform_device *pdev)
{ {
int retval;
struct usb_hcd *hcd; struct usb_hcd *hcd;
struct resource *res;
int retval;
if (pdev->resource[1].flags != IORESOURCE_IRQ) { if (pdev->resource[1].flags != IORESOURCE_IRQ) {
dev_dbg(&pdev->dev, "resource[1] is not IORESOURCE_IRQ\n"); dev_dbg(&pdev->dev, "resource[1] is not IORESOURCE_IRQ\n");
return -ENOMEM; return -ENOMEM;
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -ENXIO;
hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx"); hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx");
if (hcd == NULL) if (hcd == NULL)
return -ENOMEM; return -ENOMEM;
hcd->rsrc_start = pdev->resource[0].start; hcd->rsrc_start = res->start;
hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; hcd->rsrc_len = resource_size(res);
if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
usb_put_hcd(hcd);
retval = -EBUSY;
goto err1;
}
hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); hcd->regs = devm_ioremap_resource(&pdev->dev, res);
if (hcd->regs == NULL) { if (IS_ERR(hcd->regs)) {
dev_dbg(&pdev->dev, "ioremap failed\n"); retval = PTR_ERR(hcd->regs);
retval = -ENOMEM; goto err_put_hcd;
goto err2;
} }
usb_host_clock = clk_get(&pdev->dev, NULL); usb_host_clock = clk_get(&pdev->dev, NULL);
if (IS_ERR(usb_host_clock)) { if (IS_ERR(usb_host_clock)) {
dev_dbg(&pdev->dev, "clk_get failed\n"); dev_dbg(&pdev->dev, "clk_get failed\n");
retval = PTR_ERR(usb_host_clock); retval = PTR_ERR(usb_host_clock);
goto err3; goto err_put_hcd;
} }
ep93xx_start_hc(&pdev->dev); ep93xx_start_hc(&pdev->dev);
...@@ -86,11 +85,7 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver *driver, ...@@ -86,11 +85,7 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver *driver,
return retval; return retval;
ep93xx_stop_hc(&pdev->dev); ep93xx_stop_hc(&pdev->dev);
err3: err_put_hcd:
iounmap(hcd->regs);
err2:
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
err1:
usb_put_hcd(hcd); usb_put_hcd(hcd);
return retval; return retval;
...@@ -102,8 +97,6 @@ static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd, ...@@ -102,8 +97,6 @@ static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd,
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
ep93xx_stop_hc(&pdev->dev); ep93xx_stop_hc(&pdev->dev);
clk_put(usb_host_clock); clk_put(usb_host_clock);
iounmap(hcd->regs);
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd); usb_put_hcd(hcd);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment