aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/omap2430.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 02:27:29 -0500
committerFelipe Balbi <balbi@ti.com>2010-12-10 03:21:17 -0500
commita3cee12aa9129b576c5403a31e37d0e0113235b3 (patch)
tree17975e46cfeb146d08d6d86834be94f96a01054b /drivers/usb/musb/omap2430.c
parent9cb0308eec7a965136fe9fc6d1be3548c01a4a1e (diff)
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 <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/omap2430.c')
-rw-r--r--drivers/usb/musb/omap2430.c37
1 files changed, 28 insertions, 9 deletions
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 @@
37#include "musb_core.h" 37#include "musb_core.h"
38#include "omap2430.h" 38#include "omap2430.h"
39 39
40struct omap2430_glue {
41 struct device *dev;
42 struct platform_device *musb;
43};
44
40static struct timer_list musb_idle_timer; 45static struct timer_list musb_idle_timer;
41 46
42static void musb_do_idle(unsigned long _musb) 47static void musb_do_idle(unsigned long _musb)
@@ -350,55 +355,69 @@ static int __init omap2430_probe(struct platform_device *pdev)
350{ 355{
351 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 356 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
352 struct platform_device *musb; 357 struct platform_device *musb;
358 struct omap2430_glue *glue;
353 359
354 int ret = -ENOMEM; 360 int ret = -ENOMEM;
355 361
362 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
363 if (!glue) {
364 dev_err(&pdev->dev, "failed to allocate glue context\n");
365 goto err0;
366 }
367
356 musb = platform_device_alloc("musb-hdrc", -1); 368 musb = platform_device_alloc("musb-hdrc", -1);
357 if (!musb) { 369 if (!musb) {
358 dev_err(&pdev->dev, "failed to allocate musb device\n"); 370 dev_err(&pdev->dev, "failed to allocate musb device\n");
359 goto err0; 371 goto err1;
360 } 372 }
361 373
362 musb->dev.parent = &pdev->dev; 374 musb->dev.parent = &pdev->dev;
363 musb->dev.dma_mask = &omap2430_dmamask; 375 musb->dev.dma_mask = &omap2430_dmamask;
364 musb->dev.coherent_dma_mask = omap2430_dmamask; 376 musb->dev.coherent_dma_mask = omap2430_dmamask;
365 377
366 platform_set_drvdata(pdev, musb); 378 glue->dev = &pdev->dev;
379 glue->musb = musb;
380
381 platform_set_drvdata(pdev, glue);
367 382
368 ret = platform_device_add_resources(musb, pdev->resource, 383 ret = platform_device_add_resources(musb, pdev->resource,
369 pdev->num_resources); 384 pdev->num_resources);
370 if (ret) { 385 if (ret) {
371 dev_err(&pdev->dev, "failed to add resources\n"); 386 dev_err(&pdev->dev, "failed to add resources\n");
372 goto err1; 387 goto err2;
373 } 388 }
374 389
375 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 390 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
376 if (ret) { 391 if (ret) {
377 dev_err(&pdev->dev, "failed to add platform_data\n"); 392 dev_err(&pdev->dev, "failed to add platform_data\n");
378 goto err1; 393 goto err2;
379 } 394 }
380 395
381 ret = platform_device_add(musb); 396 ret = platform_device_add(musb);
382 if (ret) { 397 if (ret) {
383 dev_err(&pdev->dev, "failed to register musb device\n"); 398 dev_err(&pdev->dev, "failed to register musb device\n");
384 goto err1; 399 goto err2;
385 } 400 }
386 401
387 return 0; 402 return 0;
388 403
389err1: 404err2:
390 platform_device_put(musb); 405 platform_device_put(musb);
391 406
407err1:
408 kfree(glue);
409
392err0: 410err0:
393 return ret; 411 return ret;
394} 412}
395 413
396static int __exit omap2430_remove(struct platform_device *pdev) 414static int __exit omap2430_remove(struct platform_device *pdev)
397{ 415{
398 struct platform_device *musb = platform_get_drvdata(pdev); 416 struct omap2430_glue *glue = platform_get_drvdata(pdev);
399 417
400 platform_device_del(musb); 418 platform_device_del(glue->musb);
401 platform_device_put(musb); 419 platform_device_put(glue->musb);
420 kfree(glue);
402 421
403 return 0; 422 return 0;
404} 423}