提交 5ddcee27 编写于 作者: F Felipe Balbi

usb: dwc3: omap: add multiple instances support to OMAP

if we ever have an omap with multiple instances of
the DWC3 IP, we need unique names for them. In order
to achieve that, let's use the dwc3_get/put_device_id()
calls to give us an unique device identifier.
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 8300dd23
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
#include "core.h"
#include "io.h" #include "io.h"
/* /*
...@@ -200,6 +201,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) ...@@ -200,6 +201,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
struct dwc3_omap *omap; struct dwc3_omap *omap;
struct resource *res; struct resource *res;
int devid;
int ret = -ENOMEM; int ret = -ENOMEM;
int irq; int irq;
...@@ -236,16 +238,20 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) ...@@ -236,16 +238,20 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
goto err1; goto err1;
} }
dwc3 = platform_device_alloc("dwc3", -1); devid = dwc3_get_device_id();
if (devid < 0)
goto err2;
dwc3 = platform_device_alloc("dwc3", devid);
if (!dwc3) { if (!dwc3) {
dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); dev_err(&pdev->dev, "couldn't allocate dwc3 device\n");
goto err2; goto err3;
} }
context = kzalloc(resource_size(res), GFP_KERNEL); context = kzalloc(resource_size(res), GFP_KERNEL);
if (!context) { if (!context) {
dev_err(&pdev->dev, "couldn't allocate dwc3 context memory\n"); dev_err(&pdev->dev, "couldn't allocate dwc3 context memory\n");
goto err3; goto err4;
} }
spin_lock_init(&omap->lock); spin_lock_init(&omap->lock);
...@@ -299,7 +305,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) ...@@ -299,7 +305,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to request IRQ #%d --> %d\n", dev_err(&pdev->dev, "failed to request IRQ #%d --> %d\n",
omap->irq, ret); omap->irq, ret);
goto err4; goto err5;
} }
/* enable all IRQs */ /* enable all IRQs */
...@@ -322,26 +328,29 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) ...@@ -322,26 +328,29 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
pdev->num_resources); pdev->num_resources);
if (ret) { if (ret) {
dev_err(&pdev->dev, "couldn't add resources to dwc3 device\n"); dev_err(&pdev->dev, "couldn't add resources to dwc3 device\n");
goto err5; goto err6;
} }
ret = platform_device_add(dwc3); ret = platform_device_add(dwc3);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to register dwc3 device\n"); dev_err(&pdev->dev, "failed to register dwc3 device\n");
goto err5; goto err6;
} }
return 0; return 0;
err5: err6:
free_irq(omap->irq, omap); free_irq(omap->irq, omap);
err4: err5:
kfree(omap->context); kfree(omap->context);
err3: err4:
platform_device_put(dwc3); platform_device_put(dwc3);
err3:
dwc3_put_device_id(devid);
err2: err2:
iounmap(base); iounmap(base);
...@@ -358,6 +367,7 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev) ...@@ -358,6 +367,7 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev)
platform_device_unregister(omap->dwc3); platform_device_unregister(omap->dwc3);
dwc3_put_device_id(omap->dwc3->id);
free_irq(omap->irq, omap); free_irq(omap->irq, omap);
iounmap(omap->base); iounmap(omap->base);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册