diff options
author | Felipe Balbi <balbi@ti.com> | 2010-12-02 09:35:58 +0200 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2010-12-10 10:21:19 +0200 |
commit | 1add75d2bd1a44553e2c40e30db5f90a500dc1ab (patch) | |
tree | fa2a8d7a3ee80536e4e876909e2980004418b22e /drivers/usb/musb | |
parent | 0919dfc12a43d5ea21411e67984c268e84d05204 (diff) | |
download | talos-obmc-linux-1add75d2bd1a44553e2c40e30db5f90a500dc1ab.tar.gz talos-obmc-linux-1add75d2bd1a44553e2c40e30db5f90a500dc1ab.zip |
usb: musb: tusb6010: 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')
-rw-r--r-- | drivers/usb/musb/tusb6010.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index a8e26a0f2ad4..2ff78d6b2eff 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -25,6 +25,11 @@ #include "musb_core.h" +struct tusb6010_glue { + struct device *dev; + struct platform_device *musb; +}; + static void tusb_musb_set_vbus(struct musb *musb, int is_on); #define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf) @@ -1193,32 +1198,42 @@ static int __init tusb_probe(struct platform_device *pdev) { struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct platform_device *musb; + struct tusb6010_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 = &tusb_dmamask; musb->dev.coherent_dma_mask = tusb_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); @@ -1229,19 +1244,23 @@ static int __init tusb_probe(struct platform_device *pdev) return 0; -err1: +err2: platform_device_put(musb); +err1: + kfree(glue); + err0: return ret; } static int __exit tusb_remove(struct platform_device *pdev) { - struct platform_device *musb = platform_get_drvdata(pdev); + struct tusb6010_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; } |