From: Felipe Balbi Date: Thu, 2 Dec 2010 07:27:29 +0000 (+0200) Subject: usb: musb: omap2430: give it a context structure X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=a3cee12aa9129b576c5403a31e37d0e0113235b3;p=openwrt%2Fstaging%2Fblogic.git usb: musb: omap2430: 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 --- diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 78bb1e5cb9f8..bca9df7557a4 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -37,6 +37,11 @@ #include "musb_core.h" #include "omap2430.h" +struct omap2430_glue { + struct device *dev; + struct platform_device *musb; +}; + static struct timer_list musb_idle_timer; static void musb_do_idle(unsigned long _musb) @@ -350,55 +355,69 @@ static int __init omap2430_probe(struct platform_device *pdev) { struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct platform_device *musb; + struct omap2430_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 = &omap2430_dmamask; musb->dev.coherent_dma_mask = omap2430_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 omap2430_remove(struct platform_device *pdev) { - struct platform_device *musb = platform_get_drvdata(pdev); + struct omap2430_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; }