Commit 644db166 authored by Jingoo Han's avatar Jingoo Han Committed by Greg Kroah-Hartman

USB: ohci-da8xx: Use devm_*() functions

Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c81c3b01
...@@ -300,41 +300,28 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver, ...@@ -300,41 +300,28 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver,
if (hub == NULL) if (hub == NULL)
return -ENODEV; return -ENODEV;
usb11_clk = clk_get(&pdev->dev, "usb11"); usb11_clk = devm_clk_get(&pdev->dev, "usb11");
if (IS_ERR(usb11_clk)) if (IS_ERR(usb11_clk))
return PTR_ERR(usb11_clk); return PTR_ERR(usb11_clk);
usb20_clk = clk_get(&pdev->dev, "usb20"); usb20_clk = devm_clk_get(&pdev->dev, "usb20");
if (IS_ERR(usb20_clk)) { if (IS_ERR(usb20_clk))
error = PTR_ERR(usb20_clk); return PTR_ERR(usb20_clk);
goto err0;
}
hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
if (!hcd) { if (!hcd)
error = -ENOMEM; return -ENOMEM;
goto err1;
}
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) { if (!mem)
error = -ENODEV; return -ENODEV;
goto err2;
}
hcd->rsrc_start = mem->start; hcd->rsrc_start = mem->start;
hcd->rsrc_len = resource_size(mem); hcd->rsrc_len = resource_size(mem);
if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { hcd->regs = devm_ioremap_resource(&pdev->dev, mem);
dev_dbg(&pdev->dev, "request_mem_region failed\n"); if (IS_ERR(hcd->regs)) {
error = -EBUSY; error = PTR_ERR(hcd->regs);
goto err2; goto err;
}
hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
if (!hcd->regs) {
dev_err(&pdev->dev, "ioremap failed\n");
error = -ENOMEM;
goto err3;
} }
ohci_hcd_init(hcd_to_ohci(hcd)); ohci_hcd_init(hcd_to_ohci(hcd));
...@@ -342,11 +329,11 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver, ...@@ -342,11 +329,11 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver,
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
error = -ENODEV; error = -ENODEV;
goto err4; goto err;
} }
error = usb_add_hcd(hcd, irq, 0); error = usb_add_hcd(hcd, irq, 0);
if (error) if (error)
goto err4; goto err;
device_wakeup_enable(hcd->self.controller); device_wakeup_enable(hcd->self.controller);
...@@ -357,16 +344,8 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver, ...@@ -357,16 +344,8 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver,
} }
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
err4: err:
iounmap(hcd->regs);
err3:
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
err2:
usb_put_hcd(hcd); usb_put_hcd(hcd);
err1:
clk_put(usb20_clk);
err0:
clk_put(usb11_clk);
return error; return error;
} }
...@@ -386,11 +365,7 @@ usb_hcd_da8xx_remove(struct usb_hcd *hcd, struct platform_device *pdev) ...@@ -386,11 +365,7 @@ usb_hcd_da8xx_remove(struct usb_hcd *hcd, struct platform_device *pdev)
hub->ocic_notify(NULL); hub->ocic_notify(NULL);
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
iounmap(hcd->regs);
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd); usb_put_hcd(hcd);
clk_put(usb20_clk);
clk_put(usb11_clk);
} }
static int ohci_hcd_da8xx_drv_probe(struct platform_device *dev) static int ohci_hcd_da8xx_drv_probe(struct platform_device *dev)
......
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