Skip to content

Commit

Permalink
USB: EHCI: make ehci-platform use devm_request_and_ioremap helper
Browse files Browse the repository at this point in the history
This patch changes the ehci-platform driver to use the device managed helper
function for requesting memory region and ioremapping memory resources.
As a result the error path in the probe function is simplified, and the
platform driver remove callback does no longer need to release and iounmap
memory resources. devm_request_and_ioremap() will use either the ioremap()
or ioremap_nocache() handler depending on the resource's CACHEABLE flag, so
we are good with this change.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Florian Fainelli authored and Greg Kroah-Hartman committed Oct 22, 2012
1 parent ac0e3c0 commit 61ff274
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions drivers/usb/host/ehci-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,29 +123,19 @@ static int __devinit ehci_platform_probe(struct platform_device *dev)
hcd->rsrc_start = res_mem->start;
hcd->rsrc_len = resource_size(res_mem);

if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
dev_err(&dev->dev, "controller already in use");
err = -EBUSY;
goto err_put_hcd;
}

hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem);
if (!hcd->regs) {
err = -ENOMEM;
goto err_release_region;
goto err_put_hcd;
}
err = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (err)
goto err_iounmap;
goto err_put_hcd;

platform_set_drvdata(dev, hcd);

return err;

err_iounmap:
iounmap(hcd->regs);
err_release_region:
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
err_put_hcd:
usb_put_hcd(hcd);
err_power:
Expand All @@ -161,8 +151,6 @@ static int __devexit ehci_platform_remove(struct platform_device *dev)
struct usb_ehci_pdata *pdata = dev->dev.platform_data;

usb_remove_hcd(hcd);
iounmap(hcd->regs);
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd);
platform_set_drvdata(dev, NULL);

Expand Down

0 comments on commit 61ff274

Please sign in to comment.