提交 a023c631 编写于 作者: F Felipe Balbi

usb: musb: blackfin: give it a context structure

that structure currently only holds a device
pointer to our own platform_device and musb's
platform_device, but soon it will hold pointers
to our clock structures and glue-specific bits
and pieces.
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 e6480faa
...@@ -23,6 +23,11 @@ ...@@ -23,6 +23,11 @@
#include "musb_core.h" #include "musb_core.h"
#include "blackfin.h" #include "blackfin.h"
struct bfin_glue {
struct device *dev;
struct platform_device *musb;
};
/* /*
* Load an endpoint's FIFO * Load an endpoint's FIFO
*/ */
...@@ -451,55 +456,69 @@ static int __init bfin_probe(struct platform_device *pdev) ...@@ -451,55 +456,69 @@ static int __init bfin_probe(struct platform_device *pdev)
{ {
struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
struct platform_device *musb; struct platform_device *musb;
struct bfin_glue *glue;
int ret = -ENOMEM; int ret = -ENOMEM;
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
if (!glue) {
dev_err(&pdev->dev, "failed to allocate glue context\n");
goto err0;
}
musb = platform_device_alloc("musb-hdrc", -1); musb = platform_device_alloc("musb-hdrc", -1);
if (!musb) { if (!musb) {
dev_err(&pdev->dev, "failed to allocate musb device\n"); dev_err(&pdev->dev, "failed to allocate musb device\n");
goto err0; goto err1;
} }
musb->dev.parent = &pdev->dev; musb->dev.parent = &pdev->dev;
musb->dev.dma_mask = &bfin_dmamask; musb->dev.dma_mask = &bfin_dmamask;
musb->dev.coherent_dma_mask = bfin_dmamask; musb->dev.coherent_dma_mask = bfin_dmamask;
platform_set_drvdata(pdev, musb); glue->dev = &pdev->dev;
glue->musb = musb;
platform_set_drvdata(pdev, glue);
ret = platform_device_add_resources(musb, pdev->resource, ret = platform_device_add_resources(musb, pdev->resource,
pdev->num_resources); pdev->num_resources);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to add resources\n"); dev_err(&pdev->dev, "failed to add resources\n");
goto err1; goto err2;
} }
ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n"); dev_err(&pdev->dev, "failed to add platform_data\n");
goto err1; goto err2;
} }
ret = platform_device_add(musb); ret = platform_device_add(musb);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n"); dev_err(&pdev->dev, "failed to register musb device\n");
goto err1; goto err2;
} }
return 0; return 0;
err1: err2:
platform_device_put(musb); platform_device_put(musb);
err1:
kfree(glue);
err0: err0:
return ret; return ret;
} }
static int __exit bfin_remove(struct platform_device *pdev) static int __exit bfin_remove(struct platform_device *pdev)
{ {
struct platform_device *musb = platform_get_drvdata(pdev); struct bfin_glue *glue = platform_get_drvdata(pdev);
platform_device_del(musb); platform_device_del(glue->musb);
platform_device_put(musb); platform_device_put(glue->musb);
kfree(glue);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册