Commit 801f0063 authored by Jingoo Han's avatar Jingoo Han Committed by Greg Kroah-Hartman

USB: ohci-s3c2410: use devm_ functions

The devm_ functions allocate memory that is released when a driver
detaches. This makes the code smaller and a bit simpler.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 30b1e495
...@@ -323,8 +323,6 @@ usb_hcd_s3c2410_remove(struct usb_hcd *hcd, struct platform_device *dev) ...@@ -323,8 +323,6 @@ usb_hcd_s3c2410_remove(struct usb_hcd *hcd, struct platform_device *dev)
{ {
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
s3c2410_stop_hc(dev); s3c2410_stop_hc(dev);
iounmap(hcd->regs);
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd); usb_put_hcd(hcd);
} }
...@@ -353,35 +351,29 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver, ...@@ -353,35 +351,29 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
hcd->rsrc_start = dev->resource[0].start; hcd->rsrc_start = dev->resource[0].start;
hcd->rsrc_len = resource_size(&dev->resource[0]); hcd->rsrc_len = resource_size(&dev->resource[0]);
if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { hcd->regs = devm_request_and_ioremap(&dev->dev, &dev->resource[0]);
dev_err(&dev->dev, "request_mem_region failed\n"); if (!hcd->regs) {
retval = -EBUSY; dev_err(&dev->dev, "devm_request_and_ioremap failed\n");
retval = -ENOMEM;
goto err_put; goto err_put;
} }
clk = clk_get(&dev->dev, "usb-host"); clk = devm_clk_get(&dev->dev, "usb-host");
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
dev_err(&dev->dev, "cannot get usb-host clock\n"); dev_err(&dev->dev, "cannot get usb-host clock\n");
retval = PTR_ERR(clk); retval = PTR_ERR(clk);
goto err_mem; goto err_put;
} }
usb_clk = clk_get(&dev->dev, "usb-bus-host"); usb_clk = devm_clk_get(&dev->dev, "usb-bus-host");
if (IS_ERR(usb_clk)) { if (IS_ERR(usb_clk)) {
dev_err(&dev->dev, "cannot get usb-bus-host clock\n"); dev_err(&dev->dev, "cannot get usb-bus-host clock\n");
retval = PTR_ERR(usb_clk); retval = PTR_ERR(usb_clk);
goto err_clk; goto err_put;
} }
s3c2410_start_hc(dev, hcd); s3c2410_start_hc(dev, hcd);
hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
if (!hcd->regs) {
dev_err(&dev->dev, "ioremap failed\n");
retval = -ENOMEM;
goto err_ioremap;
}
ohci_hcd_init(hcd_to_ohci(hcd)); ohci_hcd_init(hcd_to_ohci(hcd));
retval = usb_add_hcd(hcd, dev->resource[1].start, 0); retval = usb_add_hcd(hcd, dev->resource[1].start, 0);
...@@ -392,14 +384,6 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver, ...@@ -392,14 +384,6 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
err_ioremap: err_ioremap:
s3c2410_stop_hc(dev); s3c2410_stop_hc(dev);
iounmap(hcd->regs);
clk_put(usb_clk);
err_clk:
clk_put(clk);
err_mem:
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
err_put: err_put:
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