Commit 9cb07563 authored by Jingoo Han's avatar Jingoo Han Committed by Greg Kroah-Hartman

USB: ehci-s5p: 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>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 390a0a78
...@@ -79,7 +79,8 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) ...@@ -79,7 +79,8 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
s5p_ehci = kzalloc(sizeof(struct s5p_ehci_hcd), GFP_KERNEL); s5p_ehci = devm_kzalloc(&pdev->dev, sizeof(struct s5p_ehci_hcd),
GFP_KERNEL);
if (!s5p_ehci) if (!s5p_ehci)
return -ENOMEM; return -ENOMEM;
...@@ -89,8 +90,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) ...@@ -89,8 +90,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
dev_name(&pdev->dev)); dev_name(&pdev->dev));
if (!hcd) { if (!hcd) {
dev_err(&pdev->dev, "Unable to create HCD\n"); dev_err(&pdev->dev, "Unable to create HCD\n");
err = -ENOMEM; return -ENOMEM;
goto fail_hcd;
} }
s5p_ehci->hcd = hcd; s5p_ehci->hcd = hcd;
...@@ -115,7 +115,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) ...@@ -115,7 +115,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
hcd->rsrc_start = res->start; hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res); hcd->rsrc_len = resource_size(res);
hcd->regs = ioremap(res->start, resource_size(res)); hcd->regs = devm_ioremap(&pdev->dev, res->start, hcd->rsrc_len);
if (!hcd->regs) { if (!hcd->regs) {
dev_err(&pdev->dev, "Failed to remap I/O memory\n"); dev_err(&pdev->dev, "Failed to remap I/O memory\n");
err = -ENOMEM; err = -ENOMEM;
...@@ -126,7 +126,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) ...@@ -126,7 +126,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
if (!irq) { if (!irq) {
dev_err(&pdev->dev, "Failed to get IRQ\n"); dev_err(&pdev->dev, "Failed to get IRQ\n");
err = -ENODEV; err = -ENODEV;
goto fail; goto fail_io;
} }
if (pdata->phy_init) if (pdata->phy_init)
...@@ -151,23 +151,19 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) ...@@ -151,23 +151,19 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
err = usb_add_hcd(hcd, irq, IRQF_SHARED); err = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (err) { if (err) {
dev_err(&pdev->dev, "Failed to add USB HCD\n"); dev_err(&pdev->dev, "Failed to add USB HCD\n");
goto fail; goto fail_io;
} }
platform_set_drvdata(pdev, s5p_ehci); platform_set_drvdata(pdev, s5p_ehci);
return 0; return 0;
fail:
iounmap(hcd->regs);
fail_io: fail_io:
clk_disable(s5p_ehci->clk); clk_disable(s5p_ehci->clk);
fail_clken: fail_clken:
clk_put(s5p_ehci->clk); clk_put(s5p_ehci->clk);
fail_clk: fail_clk:
usb_put_hcd(hcd); usb_put_hcd(hcd);
fail_hcd:
kfree(s5p_ehci);
return err; return err;
} }
...@@ -182,13 +178,10 @@ static int __devexit s5p_ehci_remove(struct platform_device *pdev) ...@@ -182,13 +178,10 @@ static int __devexit s5p_ehci_remove(struct platform_device *pdev)
if (pdata && pdata->phy_exit) if (pdata && pdata->phy_exit)
pdata->phy_exit(pdev, S5P_USB_PHY_HOST); pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
iounmap(hcd->regs);
clk_disable(s5p_ehci->clk); clk_disable(s5p_ehci->clk);
clk_put(s5p_ehci->clk); clk_put(s5p_ehci->clk);
usb_put_hcd(hcd); usb_put_hcd(hcd);
kfree(s5p_ehci);
return 0; return 0;
} }
......
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