Skip to content

Commit c8eaed4

Browse files
Sachin KamatLee Jones
authored andcommitted
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>
1 parent e578438 commit c8eaed4

2 files changed

Lines changed: 10 additions & 40 deletions

File tree

‎drivers/mfd/davinci_voicecodec.c‎

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void davinci_vc_write(struct davinci_vc *davinci_vc,
4646
static int __init davinci_vc_probe(struct platform_device *pdev)
4747
{
4848
struct davinci_vc *davinci_vc;
49-
struct resource *res, *mem;
49+
struct resource *res;
5050
struct mfd_cell *cell = NULL;
5151
int ret;
5252

@@ -58,7 +58,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
5858
return -ENOMEM;
5959
}
6060

61-
davinci_vc->clk = clk_get(&pdev->dev, NULL);
61+
davinci_vc->clk = devm_clk_get(&pdev->dev, NULL);
6262
if (IS_ERR(davinci_vc->clk)) {
6363
dev_dbg(&pdev->dev,
6464
"could not get the clock for voice codec\n");
@@ -67,35 +67,18 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
6767
clk_enable(davinci_vc->clk);
6868

6969
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);
7870

79-
mem = request_mem_region(davinci_vc->pbase, davinci_vc->base_size,
80-
pdev->name);
81-
if (!mem) {
82-
dev_err(&pdev->dev, "VCIF region already claimed\n");
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;
71+
davinci_vc->base = devm_ioremap_resource(&pdev->dev, res);
72+
if (IS_ERR(davinci_vc->base)) {
73+
ret = PTR_ERR(davinci_vc->base);
74+
goto fail;
9275
}
9376

9477
res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
9578
if (!res) {
9679
dev_err(&pdev->dev, "no DMA resource\n");
9780
ret = -ENXIO;
98-
goto fail4;
81+
goto fail;
9982
}
10083

10184
davinci_vc->davinci_vcif.dma_tx_channel = res->start;
@@ -106,7 +89,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
10689
if (!res) {
10790
dev_err(&pdev->dev, "no DMA resource\n");
10891
ret = -ENXIO;
109-
goto fail4;
92+
goto fail;
11093
}
11194

11295
davinci_vc->davinci_vcif.dma_rx_channel = res->start;
@@ -132,19 +115,13 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
132115
DAVINCI_VC_CELLS, NULL, 0, NULL);
133116
if (ret != 0) {
134117
dev_err(&pdev->dev, "fail to register client devices\n");
135-
goto fail4;
118+
goto fail;
136119
}
137120

138121
return 0;
139122

140-
fail4:
141-
iounmap(davinci_vc->base);
142-
fail3:
143-
release_mem_region(davinci_vc->pbase, davinci_vc->base_size);
144-
fail2:
123+
fail:
145124
clk_disable(davinci_vc->clk);
146-
clk_put(davinci_vc->clk);
147-
davinci_vc->clk = NULL;
148125

149126
return ret;
150127
}
@@ -155,12 +132,7 @@ static int davinci_vc_remove(struct platform_device *pdev)
155132

156133
mfd_remove_devices(&pdev->dev);
157134

158-
iounmap(davinci_vc->base);
159-
release_mem_region(davinci_vc->pbase, davinci_vc->base_size);
160-
161135
clk_disable(davinci_vc->clk);
162-
clk_put(davinci_vc->clk);
163-
davinci_vc->clk = NULL;
164136

165137
return 0;
166138
}

‎include/linux/mfd/davinci_voicecodec.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ struct davinci_vc {
112112

113113
/* Memory resources */
114114
void __iomem *base;
115-
resource_size_t pbase;
116-
size_t base_size;
117115

118116
/* MFD cells */
119117
struct mfd_cell cells[DAVINCI_VC_CELLS];

0 commit comments

Comments
 (0)