diff options
author | Kishon Vijay Abraham I <kishon@ti.com> | 2012-06-22 08:10:55 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-06-25 07:08:53 -0400 |
commit | b8a3efa3a363720687d21228d6b23b988a223bbb (patch) | |
tree | 1b1554813c7d91d05c3c13b42fb4e3ee604cf27a | |
parent | b1183c242a60764afbdfaf39396405b7afa1106c (diff) |
usb: otg: twl: use devres API to allocate resources
used devres API while allocating memory resource in twl4030 and twl6030
so that these resources are released automatically on driver detach.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/otg/twl4030-usb.c | 15 | ||||
-rw-r--r-- | drivers/usb/otg/twl6030-usb.c | 16 |
2 files changed, 6 insertions, 25 deletions
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c index 4d0d98bc40cd..523cad5bfea9 100644 --- a/drivers/usb/otg/twl4030-usb.c +++ b/drivers/usb/otg/twl4030-usb.c | |||
@@ -591,15 +591,13 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev) | |||
591 | return -EINVAL; | 591 | return -EINVAL; |
592 | } | 592 | } |
593 | 593 | ||
594 | twl = kzalloc(sizeof *twl, GFP_KERNEL); | 594 | twl = devm_kzalloc(&pdev->dev, sizeof *twl, GFP_KERNEL); |
595 | if (!twl) | 595 | if (!twl) |
596 | return -ENOMEM; | 596 | return -ENOMEM; |
597 | 597 | ||
598 | otg = kzalloc(sizeof *otg, GFP_KERNEL); | 598 | otg = devm_kzalloc(&pdev->dev, sizeof *otg, GFP_KERNEL); |
599 | if (!otg) { | 599 | if (!otg) |
600 | kfree(twl); | ||
601 | return -ENOMEM; | 600 | return -ENOMEM; |
602 | } | ||
603 | 601 | ||
604 | twl->dev = &pdev->dev; | 602 | twl->dev = &pdev->dev; |
605 | twl->irq = platform_get_irq(pdev, 0); | 603 | twl->irq = platform_get_irq(pdev, 0); |
@@ -623,8 +621,6 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev) | |||
623 | err = twl4030_usb_ldo_init(twl); | 621 | err = twl4030_usb_ldo_init(twl); |
624 | if (err) { | 622 | if (err) { |
625 | dev_err(&pdev->dev, "ldo init failed\n"); | 623 | dev_err(&pdev->dev, "ldo init failed\n"); |
626 | kfree(otg); | ||
627 | kfree(twl); | ||
628 | return err; | 624 | return err; |
629 | } | 625 | } |
630 | usb_add_phy(&twl->phy, USB_PHY_TYPE_USB2); | 626 | usb_add_phy(&twl->phy, USB_PHY_TYPE_USB2); |
@@ -648,8 +644,6 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev) | |||
648 | if (status < 0) { | 644 | if (status < 0) { |
649 | dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n", | 645 | dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n", |
650 | twl->irq, status); | 646 | twl->irq, status); |
651 | kfree(otg); | ||
652 | kfree(twl); | ||
653 | return status; | 647 | return status; |
654 | } | 648 | } |
655 | 649 | ||
@@ -693,9 +687,6 @@ static int __exit twl4030_usb_remove(struct platform_device *pdev) | |||
693 | regulator_put(twl->usb1v8); | 687 | regulator_put(twl->usb1v8); |
694 | regulator_put(twl->usb3v1); | 688 | regulator_put(twl->usb3v1); |
695 | 689 | ||
696 | kfree(twl->phy.otg); | ||
697 | kfree(twl); | ||
698 | |||
699 | return 0; | 690 | return 0; |
700 | } | 691 | } |
701 | 692 | ||
diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c index 66cfea735557..600c27a42ff1 100644 --- a/drivers/usb/otg/twl6030-usb.c +++ b/drivers/usb/otg/twl6030-usb.c | |||
@@ -395,15 +395,13 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) | |||
395 | struct device *dev = &pdev->dev; | 395 | struct device *dev = &pdev->dev; |
396 | pdata = dev->platform_data; | 396 | pdata = dev->platform_data; |
397 | 397 | ||
398 | twl = kzalloc(sizeof *twl, GFP_KERNEL); | 398 | twl = devm_kzalloc(dev, sizeof *twl, GFP_KERNEL); |
399 | if (!twl) | 399 | if (!twl) |
400 | return -ENOMEM; | 400 | return -ENOMEM; |
401 | 401 | ||
402 | otg = kzalloc(sizeof *otg, GFP_KERNEL); | 402 | otg = devm_kzalloc(dev, sizeof *otg, GFP_KERNEL); |
403 | if (!otg) { | 403 | if (!otg) |
404 | kfree(twl); | ||
405 | return -ENOMEM; | 404 | return -ENOMEM; |
406 | } | ||
407 | 405 | ||
408 | twl->dev = &pdev->dev; | 406 | twl->dev = &pdev->dev; |
409 | twl->irq1 = platform_get_irq(pdev, 0); | 407 | twl->irq1 = platform_get_irq(pdev, 0); |
@@ -430,8 +428,6 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) | |||
430 | err = twl6030_usb_ldo_init(twl); | 428 | err = twl6030_usb_ldo_init(twl); |
431 | if (err) { | 429 | if (err) { |
432 | dev_err(&pdev->dev, "ldo init failed\n"); | 430 | dev_err(&pdev->dev, "ldo init failed\n"); |
433 | kfree(otg); | ||
434 | kfree(twl); | ||
435 | return err; | 431 | return err; |
436 | } | 432 | } |
437 | usb_add_phy(&twl->phy, USB_PHY_TYPE_USB2); | 433 | usb_add_phy(&twl->phy, USB_PHY_TYPE_USB2); |
@@ -450,8 +446,6 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) | |||
450 | dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", | 446 | dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", |
451 | twl->irq1, status); | 447 | twl->irq1, status); |
452 | device_remove_file(twl->dev, &dev_attr_vbus); | 448 | device_remove_file(twl->dev, &dev_attr_vbus); |
453 | kfree(otg); | ||
454 | kfree(twl); | ||
455 | return status; | 449 | return status; |
456 | } | 450 | } |
457 | 451 | ||
@@ -463,8 +457,6 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) | |||
463 | twl->irq2, status); | 457 | twl->irq2, status); |
464 | free_irq(twl->irq1, twl); | 458 | free_irq(twl->irq1, twl); |
465 | device_remove_file(twl->dev, &dev_attr_vbus); | 459 | device_remove_file(twl->dev, &dev_attr_vbus); |
466 | kfree(otg); | ||
467 | kfree(twl); | ||
468 | return status; | 460 | return status; |
469 | } | 461 | } |
470 | 462 | ||
@@ -495,8 +487,6 @@ static int __exit twl6030_usb_remove(struct platform_device *pdev) | |||
495 | pdata->phy_exit(twl->dev); | 487 | pdata->phy_exit(twl->dev); |
496 | device_remove_file(twl->dev, &dev_attr_vbus); | 488 | device_remove_file(twl->dev, &dev_attr_vbus); |
497 | cancel_work_sync(&twl->set_vbus_work); | 489 | cancel_work_sync(&twl->set_vbus_work); |
498 | kfree(twl->phy.otg); | ||
499 | kfree(twl); | ||
500 | 490 | ||
501 | return 0; | 491 | return 0; |
502 | } | 492 | } |