Commit 338edabc authored by Sachin Kamat's avatar Sachin Kamat Committed by Felipe Balbi

usb: s3c-hsotg: Use devm_* functions in s3c-hsotg.c file

devm_* functions are used to replace kzalloc, request_mem_region, ioremap
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 dd8e9381
...@@ -136,7 +136,6 @@ struct s3c_hsotg_ep { ...@@ -136,7 +136,6 @@ struct s3c_hsotg_ep {
* @driver: USB gadget driver * @driver: USB gadget driver
* @plat: The platform specific configuration data. * @plat: The platform specific configuration data.
* @regs: The memory area mapped for accessing registers. * @regs: The memory area mapped for accessing registers.
* @regs_res: The resource that was allocated when claiming register space.
* @irq: The IRQ number we are using * @irq: The IRQ number we are using
* @supplies: Definition of USB power supplies * @supplies: Definition of USB power supplies
* @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos. * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
...@@ -158,7 +157,6 @@ struct s3c_hsotg { ...@@ -158,7 +157,6 @@ struct s3c_hsotg {
struct s3c_hsotg_plat *plat; struct s3c_hsotg_plat *plat;
void __iomem *regs; void __iomem *regs;
struct resource *regs_res;
int irq; int irq;
struct clk *clk; struct clk *clk;
...@@ -3477,7 +3475,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) ...@@ -3477,7 +3475,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
hsotg = kzalloc(sizeof(struct s3c_hsotg), GFP_KERNEL); hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
if (!hsotg) { if (!hsotg) {
dev_err(dev, "cannot get memory\n"); dev_err(dev, "cannot get memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -3489,46 +3487,33 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) ...@@ -3489,46 +3487,33 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
hsotg->clk = clk_get(&pdev->dev, "otg"); hsotg->clk = clk_get(&pdev->dev, "otg");
if (IS_ERR(hsotg->clk)) { if (IS_ERR(hsotg->clk)) {
dev_err(dev, "cannot get otg clock\n"); dev_err(dev, "cannot get otg clock\n");
ret = PTR_ERR(hsotg->clk); return PTR_ERR(hsotg->clk);
goto err_mem;
} }
platform_set_drvdata(pdev, hsotg); platform_set_drvdata(pdev, hsotg);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(dev, "cannot find register resource 0\n");
ret = -EINVAL;
goto err_clk;
}
hsotg->regs_res = request_mem_region(res->start, resource_size(res),
dev_name(dev));
if (!hsotg->regs_res) {
dev_err(dev, "cannot reserve registers\n");
ret = -ENOENT;
goto err_clk;
}
hsotg->regs = ioremap(res->start, resource_size(res)); hsotg->regs = devm_request_and_ioremap(&pdev->dev, res);
if (!hsotg->regs) { if (!hsotg->regs) {
dev_err(dev, "cannot map registers\n"); dev_err(dev, "cannot map registers\n");
ret = -ENXIO; ret = -ENXIO;
goto err_regs_res; goto err_clk;
} }
ret = platform_get_irq(pdev, 0); ret = platform_get_irq(pdev, 0);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "cannot find IRQ\n"); dev_err(dev, "cannot find IRQ\n");
goto err_regs; goto err_clk;
} }
hsotg->irq = ret; hsotg->irq = ret;
ret = request_irq(ret, s3c_hsotg_irq, 0, dev_name(dev), hsotg); ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0,
dev_name(dev), hsotg);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "cannot claim IRQ\n"); dev_err(dev, "cannot claim IRQ\n");
goto err_regs; goto err_clk;
} }
dev_info(dev, "regs %p, irq %d\n", hsotg->regs, hsotg->irq); dev_info(dev, "regs %p, irq %d\n", hsotg->regs, hsotg->irq);
...@@ -3558,7 +3543,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) ...@@ -3558,7 +3543,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
hsotg->supplies); hsotg->supplies);
if (ret) { if (ret) {
dev_err(dev, "failed to request supplies: %d\n", ret); dev_err(dev, "failed to request supplies: %d\n", ret);
goto err_irq; goto err_clk;
} }
ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies), ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
...@@ -3642,19 +3627,11 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) ...@@ -3642,19 +3627,11 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
err_supplies: err_supplies:
s3c_hsotg_phy_disable(hsotg); s3c_hsotg_phy_disable(hsotg);
regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
err_irq:
free_irq(hsotg->irq, hsotg);
err_regs:
iounmap(hsotg->regs);
err_regs_res:
release_resource(hsotg->regs_res);
kfree(hsotg->regs_res);
err_clk: err_clk:
clk_disable_unprepare(hsotg->clk); clk_disable_unprepare(hsotg->clk);
clk_put(hsotg->clk); clk_put(hsotg->clk);
err_mem:
kfree(hsotg);
return ret; return ret;
} }
...@@ -3675,12 +3652,6 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev) ...@@ -3675,12 +3652,6 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev)
usb_gadget_unregister_driver(hsotg->driver); usb_gadget_unregister_driver(hsotg->driver);
} }
free_irq(hsotg->irq, hsotg);
iounmap(hsotg->regs);
release_resource(hsotg->regs_res);
kfree(hsotg->regs_res);
s3c_hsotg_phy_disable(hsotg); s3c_hsotg_phy_disable(hsotg);
regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
......
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