diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-08-19 03:02:53 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-20 15:44:28 -0400 |
commit | b18e93a493626c1446f9788ebd5844d008bbf71c (patch) | |
tree | b65825976f6e63b8a4a47c38dc875f1e7d623143 /sound/soc/ux500 | |
parent | db8b624d55e65ad5d8211a9fef66fa7f16bd13a0 (diff) |
ASoC: ux500_msp_i2s: better use devm functions and fix error return code
Remove unnecessary calls to devm_kfree and replace iounmap by devm_iounmap
(and use resource_size for the third argument). These changes make it
possible to remove the error-handling code at the end of
ux500_msp_i2s_init_msp, and all of the gotos become direct returns.
In the case of the second call to devm_kzalloc, the return variable ret was
not initialized. Here it is changed to a direct return of -ENOMEM.
A simplified version of the semantic match that finds the second problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/ux500')
-rw-r--r-- | sound/soc/ux500/ux500_msp_i2s.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/sound/soc/ux500/ux500_msp_i2s.c b/sound/soc/ux500/ux500_msp_i2s.c index 5c472f335a64..eb85113d472a 100644 --- a/sound/soc/ux500/ux500_msp_i2s.c +++ b/sound/soc/ux500/ux500_msp_i2s.c | |||
@@ -663,7 +663,6 @@ int ux500_msp_i2s_init_msp(struct platform_device *pdev, | |||
663 | struct ux500_msp **msp_p, | 663 | struct ux500_msp **msp_p, |
664 | struct msp_i2s_platform_data *platform_data) | 664 | struct msp_i2s_platform_data *platform_data) |
665 | { | 665 | { |
666 | int ret = 0; | ||
667 | struct resource *res = NULL; | 666 | struct resource *res = NULL; |
668 | struct i2s_controller *i2s_cont; | 667 | struct i2s_controller *i2s_cont; |
669 | struct ux500_msp *msp; | 668 | struct ux500_msp *msp; |
@@ -685,15 +684,14 @@ int ux500_msp_i2s_init_msp(struct platform_device *pdev, | |||
685 | if (res == NULL) { | 684 | if (res == NULL) { |
686 | dev_err(&pdev->dev, "%s: ERROR: Unable to get resource!\n", | 685 | dev_err(&pdev->dev, "%s: ERROR: Unable to get resource!\n", |
687 | __func__); | 686 | __func__); |
688 | ret = -ENOMEM; | 687 | return -ENOMEM; |
689 | goto err_res; | ||
690 | } | 688 | } |
691 | 689 | ||
692 | msp->registers = ioremap(res->start, (res->end - res->start + 1)); | 690 | msp->registers = devm_ioremap(&pdev->dev, res->start, |
691 | resource_size(res)); | ||
693 | if (msp->registers == NULL) { | 692 | if (msp->registers == NULL) { |
694 | dev_err(&pdev->dev, "%s: ERROR: ioremap failed!\n", __func__); | 693 | dev_err(&pdev->dev, "%s: ERROR: ioremap failed!\n", __func__); |
695 | ret = -ENOMEM; | 694 | return -ENOMEM; |
696 | goto err_res; | ||
697 | } | 695 | } |
698 | 696 | ||
699 | msp->msp_state = MSP_STATE_IDLE; | 697 | msp->msp_state = MSP_STATE_IDLE; |
@@ -705,7 +703,7 @@ int ux500_msp_i2s_init_msp(struct platform_device *pdev, | |||
705 | dev_err(&pdev->dev, | 703 | dev_err(&pdev->dev, |
706 | "%s: ERROR: Failed to allocate I2S-controller!\n", | 704 | "%s: ERROR: Failed to allocate I2S-controller!\n", |
707 | __func__); | 705 | __func__); |
708 | goto err_i2s_cont; | 706 | return -ENOMEM; |
709 | } | 707 | } |
710 | i2s_cont->dev.parent = &pdev->dev; | 708 | i2s_cont->dev.parent = &pdev->dev; |
711 | i2s_cont->data = (void *)msp; | 709 | i2s_cont->data = (void *)msp; |
@@ -716,14 +714,6 @@ int ux500_msp_i2s_init_msp(struct platform_device *pdev, | |||
716 | msp->i2s_cont = i2s_cont; | 714 | msp->i2s_cont = i2s_cont; |
717 | 715 | ||
718 | return 0; | 716 | return 0; |
719 | |||
720 | err_i2s_cont: | ||
721 | iounmap(msp->registers); | ||
722 | |||
723 | err_res: | ||
724 | devm_kfree(&pdev->dev, msp); | ||
725 | |||
726 | return ret; | ||
727 | } | 717 | } |
728 | 718 | ||
729 | void ux500_msp_i2s_cleanup_msp(struct platform_device *pdev, | 719 | void ux500_msp_i2s_cleanup_msp(struct platform_device *pdev, |
@@ -732,11 +722,6 @@ void ux500_msp_i2s_cleanup_msp(struct platform_device *pdev, | |||
732 | dev_dbg(msp->dev, "%s: Enter (id = %d).\n", __func__, msp->id); | 722 | dev_dbg(msp->dev, "%s: Enter (id = %d).\n", __func__, msp->id); |
733 | 723 | ||
734 | device_unregister(&msp->i2s_cont->dev); | 724 | device_unregister(&msp->i2s_cont->dev); |
735 | devm_kfree(&pdev->dev, msp->i2s_cont); | ||
736 | |||
737 | iounmap(msp->registers); | ||
738 | |||
739 | devm_kfree(&pdev->dev, msp); | ||
740 | } | 725 | } |
741 | 726 | ||
742 | MODULE_LICENSE("GPL v2"); | 727 | MODULE_LICENSE("GPL v2"); |