aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/davinci_voicecodec.c
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-06-18 06:05:40 -0400
committerLee Jones <lee.jones@linaro.org>2013-06-19 04:53:26 -0400
commitc8eaed458e2cfbd906dbbe1af49aa028f59cc132 (patch)
treeb69c1934800bacecd4f4a7ca0cbfca719c1ccb42 /drivers/mfd/davinci_voicecodec.c
parente578438820cdca91cb5eab477ec062236433ce5f (diff)
mfd: davinci_voicecodec: Convert to use devm_* APIs
devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd/davinci_voicecodec.c')
-rw-r--r--drivers/mfd/davinci_voicecodec.c48
1 files changed, 10 insertions, 38 deletions
diff --git a/drivers/mfd/davinci_voicecodec.c b/drivers/mfd/davinci_voicecodec.c
index b6e297363946..fb64398506e9 100644
--- a/drivers/mfd/davinci_voicecodec.c
+++ b/drivers/mfd/davinci_voicecodec.c
@@ -46,7 +46,7 @@ void davinci_vc_write(struct davinci_vc *davinci_vc,
46static int __init davinci_vc_probe(struct platform_device *pdev) 46static int __init davinci_vc_probe(struct platform_device *pdev)
47{ 47{
48 struct davinci_vc *davinci_vc; 48 struct davinci_vc *davinci_vc;
49 struct resource *res, *mem; 49 struct resource *res;
50 struct mfd_cell *cell = NULL; 50 struct mfd_cell *cell = NULL;
51 int ret; 51 int ret;
52 52
@@ -58,7 +58,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
58 return -ENOMEM; 58 return -ENOMEM;
59 } 59 }
60 60
61 davinci_vc->clk = clk_get(&pdev->dev, NULL); 61 davinci_vc->clk = devm_clk_get(&pdev->dev, NULL);
62 if (IS_ERR(davinci_vc->clk)) { 62 if (IS_ERR(davinci_vc->clk)) {
63 dev_dbg(&pdev->dev, 63 dev_dbg(&pdev->dev,
64 "could not get the clock for voice codec\n"); 64 "could not get the clock for voice codec\n");
@@ -67,35 +67,18 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
67 clk_enable(davinci_vc->clk); 67 clk_enable(davinci_vc->clk);
68 68
69 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 69 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
70 if (!res) {
71 dev_err(&pdev->dev, "no mem resource\n");
72 ret = -ENODEV;
73 goto fail2;
74 }
75
76 davinci_vc->pbase = res->start;
77 davinci_vc->base_size = resource_size(res);
78 70
79 mem = request_mem_region(davinci_vc->pbase, davinci_vc->base_size, 71 davinci_vc->base = devm_ioremap_resource(&pdev->dev, res);
80 pdev->name); 72 if (IS_ERR(davinci_vc->base)) {
81 if (!mem) { 73 ret = PTR_ERR(davinci_vc->base);
82 dev_err(&pdev->dev, "VCIF region already claimed\n"); 74 goto fail;
83 ret = -EBUSY;
84 goto fail2;
85 }
86
87 davinci_vc->base = ioremap(davinci_vc->pbase, davinci_vc->base_size);
88 if (!davinci_vc->base) {
89 dev_err(&pdev->dev, "can't ioremap mem resource.\n");
90 ret = -ENOMEM;
91 goto fail3;
92 } 75 }
93 76
94 res = platform_get_resource(pdev, IORESOURCE_DMA, 0); 77 res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
95 if (!res) { 78 if (!res) {
96 dev_err(&pdev->dev, "no DMA resource\n"); 79 dev_err(&pdev->dev, "no DMA resource\n");
97 ret = -ENXIO; 80 ret = -ENXIO;
98 goto fail4; 81 goto fail;
99 } 82 }
100 83
101 davinci_vc->davinci_vcif.dma_tx_channel = res->start; 84 davinci_vc->davinci_vcif.dma_tx_channel = res->start;
@@ -106,7 +89,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
106 if (!res) { 89 if (!res) {
107 dev_err(&pdev->dev, "no DMA resource\n"); 90 dev_err(&pdev->dev, "no DMA resource\n");
108 ret = -ENXIO; 91 ret = -ENXIO;
109 goto fail4; 92 goto fail;
110 } 93 }
111 94
112 davinci_vc->davinci_vcif.dma_rx_channel = res->start; 95 davinci_vc->davinci_vcif.dma_rx_channel = res->start;
@@ -132,19 +115,13 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
132 DAVINCI_VC_CELLS, NULL, 0, NULL); 115 DAVINCI_VC_CELLS, NULL, 0, NULL);
133 if (ret != 0) { 116 if (ret != 0) {
134 dev_err(&pdev->dev, "fail to register client devices\n"); 117 dev_err(&pdev->dev, "fail to register client devices\n");
135 goto fail4; 118 goto fail;
136 } 119 }
137 120
138 return 0; 121 return 0;
139 122
140fail4: 123fail:
141 iounmap(davinci_vc->base);
142fail3:
143 release_mem_region(davinci_vc->pbase, davinci_vc->base_size);
144fail2:
145 clk_disable(davinci_vc->clk); 124 clk_disable(davinci_vc->clk);
146 clk_put(davinci_vc->clk);
147 davinci_vc->clk = NULL;
148 125
149 return ret; 126 return ret;
150} 127}
@@ -155,12 +132,7 @@ static int davinci_vc_remove(struct platform_device *pdev)
155 132
156 mfd_remove_devices(&pdev->dev); 133 mfd_remove_devices(&pdev->dev);
157 134
158 iounmap(davinci_vc->base);
159 release_mem_region(davinci_vc->pbase, davinci_vc->base_size);
160
161 clk_disable(davinci_vc->clk); 135 clk_disable(davinci_vc->clk);
162 clk_put(davinci_vc->clk);
163 davinci_vc->clk = NULL;
164 136
165 return 0; 137 return 0;
166} 138}