Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 226996
b: refs/heads/master
c: 0919dfc
h: refs/heads/master
v: v3
  • Loading branch information
Felipe Balbi committed Dec 10, 2010
1 parent 9078167 commit 8d7d03a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a3cee12aa9129b576c5403a31e37d0e0113235b3
refs/heads/master: 0919dfc12a43d5ea21411e67984c268e84d05204
37 changes: 28 additions & 9 deletions trunk/drivers/usb/musb/am35x.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@

#define USB_MENTOR_CORE_OFFSET 0x400

struct am35x_glue {
struct device *dev;
struct platform_device *musb;
};

static inline void phy_on(void)
{
unsigned long timeout = jiffies + msecs_to_jiffies(100);
Expand Down Expand Up @@ -544,55 +549,69 @@ static int __init am35x_probe(struct platform_device *pdev)
{
struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
struct platform_device *musb;
struct am35x_glue *glue;

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);
if (!musb) {
dev_err(&pdev->dev, "failed to allocate musb device\n");
goto err0;
goto err1;
}

musb->dev.parent = &pdev->dev;
musb->dev.dma_mask = &am35x_dmamask;
musb->dev.coherent_dma_mask = am35x_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,
pdev->num_resources);
if (ret) {
dev_err(&pdev->dev, "failed to add resources\n");
goto err1;
goto err2;
}

ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n");
goto err1;
goto err2;
}

ret = platform_device_add(musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n");
goto err1;
goto err2;
}

return 0;

err1:
err2:
platform_device_put(musb);

err1:
kfree(glue);

err0:
return ret;
}

static int __exit am35x_remove(struct platform_device *pdev)
{
struct platform_device *musb = platform_get_drvdata(pdev);
struct am35x_glue *glue = platform_get_drvdata(pdev);

platform_device_del(musb);
platform_device_put(musb);
platform_device_del(glue->musb);
platform_device_put(glue->musb);
kfree(glue);

return 0;
}
Expand Down

0 comments on commit 8d7d03a

Please sign in to comment.