Commit 78f0c53e authored by Sachin Kamat's avatar Sachin Kamat Committed by Felipe Balbi

usb: gadget: s3c-hsudc: Use devm_* functions

devm_* functions are used to replace kzalloc, request_mem_region, ioremap
clk_get and request_irq functions in probe call. With the usage of devm_*
functions explicit freeing and unmapping is not required.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 9d2333d0
...@@ -135,7 +135,6 @@ struct s3c_hsudc_req { ...@@ -135,7 +135,6 @@ struct s3c_hsudc_req {
* @dev: The device reference used by probe function. * @dev: The device reference used by probe function.
* @lock: Lock to synchronize the usage of Endpoints (EP's are indexed). * @lock: Lock to synchronize the usage of Endpoints (EP's are indexed).
* @regs: Remapped base address of controller's register space. * @regs: Remapped base address of controller's register space.
* @mem_rsrc: Device memory resource used for remapping device register space.
* irq: IRQ number used by the controller. * irq: IRQ number used by the controller.
* uclk: Reference to the controller clock. * uclk: Reference to the controller clock.
* ep0state: Current state of EP0. * ep0state: Current state of EP0.
...@@ -150,7 +149,6 @@ struct s3c_hsudc { ...@@ -150,7 +149,6 @@ struct s3c_hsudc {
struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)]; struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)];
spinlock_t lock; spinlock_t lock;
void __iomem *regs; void __iomem *regs;
struct resource *mem_rsrc;
int irq; int irq;
struct clk *uclk; struct clk *uclk;
int ep0state; int ep0state;
...@@ -1271,7 +1269,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) ...@@ -1271,7 +1269,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev)
struct s3c24xx_hsudc_platdata *pd = pdev->dev.platform_data; struct s3c24xx_hsudc_platdata *pd = pdev->dev.platform_data;
int ret, i; int ret, i;
hsudc = kzalloc(sizeof(struct s3c_hsudc) + hsudc = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsudc) +
sizeof(struct s3c_hsudc_ep) * pd->epnum, sizeof(struct s3c_hsudc_ep) * pd->epnum,
GFP_KERNEL); GFP_KERNEL);
if (!hsudc) { if (!hsudc) {
...@@ -1296,25 +1294,12 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) ...@@ -1296,25 +1294,12 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev)
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(dev, "unable to obtain driver resource data\n");
ret = -ENODEV;
goto err_res;
}
hsudc->mem_rsrc = request_mem_region(res->start, resource_size(res),
dev_name(&pdev->dev));
if (!hsudc->mem_rsrc) {
dev_err(dev, "failed to reserve register area\n");
ret = -ENODEV;
goto err_res;
}
hsudc->regs = ioremap(res->start, resource_size(res)); hsudc->regs = devm_request_and_ioremap(&pdev->dev, res);
if (!hsudc->regs) { if (!hsudc->regs) {
dev_err(dev, "error mapping device register area\n"); dev_err(dev, "error mapping device register area\n");
ret = -EBUSY; ret = -EBUSY;
goto err_remap; goto err_res;
} }
spin_lock_init(&hsudc->lock); spin_lock_init(&hsudc->lock);
...@@ -1337,21 +1322,22 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) ...@@ -1337,21 +1322,22 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev)
ret = platform_get_irq(pdev, 0); ret = platform_get_irq(pdev, 0);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "unable to obtain IRQ number\n"); dev_err(dev, "unable to obtain IRQ number\n");
goto err_irq; goto err_res;
} }
hsudc->irq = ret; hsudc->irq = ret;
ret = request_irq(hsudc->irq, s3c_hsudc_irq, 0, driver_name, hsudc); ret = devm_request_irq(&pdev->dev, hsudc->irq, s3c_hsudc_irq, 0,
driver_name, hsudc);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "irq request failed\n"); dev_err(dev, "irq request failed\n");
goto err_irq; goto err_res;
} }
hsudc->uclk = clk_get(&pdev->dev, "usb-device"); hsudc->uclk = devm_clk_get(&pdev->dev, "usb-device");
if (IS_ERR(hsudc->uclk)) { if (IS_ERR(hsudc->uclk)) {
dev_err(dev, "failed to find usb-device clock source\n"); dev_err(dev, "failed to find usb-device clock source\n");
ret = PTR_ERR(hsudc->uclk); ret = PTR_ERR(hsudc->uclk);
goto err_clk; goto err_res;
} }
clk_enable(hsudc->uclk); clk_enable(hsudc->uclk);
...@@ -1377,21 +1363,12 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) ...@@ -1377,21 +1363,12 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev)
device_unregister(&hsudc->gadget.dev); device_unregister(&hsudc->gadget.dev);
err_add_device: err_add_device:
clk_disable(hsudc->uclk); clk_disable(hsudc->uclk);
clk_put(hsudc->uclk);
err_clk:
free_irq(hsudc->irq, hsudc);
err_irq:
iounmap(hsudc->regs);
err_remap:
release_mem_region(res->start, resource_size(res));
err_res: err_res:
if (!IS_ERR_OR_NULL(hsudc->transceiver)) if (!IS_ERR_OR_NULL(hsudc->transceiver))
usb_put_phy(hsudc->transceiver); usb_put_phy(hsudc->transceiver);
regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies);
err_supplies: err_supplies:
kfree(hsudc);
return ret; return ret;
} }
......
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