summaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/da8xx.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 09:40:34 +0200
committerFelipe Balbi <balbi@ti.com>2010-12-10 10:21:21 +0200
commite6480faa1067af91ab403fd3aaf6db2fe1134b13 (patch)
treea9f1d5ffe63228016baa0f752e1c5a9fa804132b /drivers/usb/musb/da8xx.c
parente110de4d5358f2e67c333d23d608cbabe26b6220 (diff)
usb: musb: da8xx: 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: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/da8xx.c')
-rw-r--r--drivers/usb/musb/da8xx.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index b80b7da4472..94ddfe01d67 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -80,6 +80,11 @@
#define CFGCHIP2 IO_ADDRESS(DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP2_REG)
+struct da8xx_glue {
+ struct device *dev;
+ struct platform_device *musb;
+};
+
/*
* REVISIT (PM): we should be able to keep the PHY in low power mode most
* of the time (24 MHz oscillator and PLL off, etc.) by setting POWER.D0
@@ -489,55 +494,69 @@ static int __init da8xx_probe(struct platform_device *pdev)
{
struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
struct platform_device *musb;
+ struct da8xx_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 = &da8xx_dmamask;
musb->dev.coherent_dma_mask = da8xx_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 da8xx_remove(struct platform_device *pdev)
{
- struct platform_device *musb = platform_get_drvdata(pdev);
+ struct da8xx_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;
}