diff options
author | Kefeng Wang <wangkefeng.wang@huawei.com> | 2014-05-27 06:18:42 -0400 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2014-05-30 14:20:12 -0400 |
commit | afba256b14644e4ca5f9e84672e61b14cb71c40e (patch) | |
tree | 260bbdda7b55d426e9b94eda8fa707d2d82d03e6 /drivers/iommu | |
parent | c7208164e66f63e3ec1759b98087849286410741 (diff) |
iommu/msm: Use devm_ioremap_resource to simplify code
Use devm_ioremap_resource() to make the code simpler, drop unused variable,
redundant return value check, and error-handing code.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/msm_iommu_dev.c | 38 |
1 files changed, 7 insertions, 31 deletions
diff --git a/drivers/iommu/msm_iommu_dev.c b/drivers/iommu/msm_iommu_dev.c index 08ba4972da9d..61def7cb5263 100644 --- a/drivers/iommu/msm_iommu_dev.c +++ b/drivers/iommu/msm_iommu_dev.c | |||
@@ -127,13 +127,12 @@ static void msm_iommu_reset(void __iomem *base, int ncb) | |||
127 | 127 | ||
128 | static int msm_iommu_probe(struct platform_device *pdev) | 128 | static int msm_iommu_probe(struct platform_device *pdev) |
129 | { | 129 | { |
130 | struct resource *r, *r2; | 130 | struct resource *r; |
131 | struct clk *iommu_clk; | 131 | struct clk *iommu_clk; |
132 | struct clk *iommu_pclk; | 132 | struct clk *iommu_pclk; |
133 | struct msm_iommu_drvdata *drvdata; | 133 | struct msm_iommu_drvdata *drvdata; |
134 | struct msm_iommu_dev *iommu_dev = pdev->dev.platform_data; | 134 | struct msm_iommu_dev *iommu_dev = pdev->dev.platform_data; |
135 | void __iomem *regs_base; | 135 | void __iomem *regs_base; |
136 | resource_size_t len; | ||
137 | int ret, irq, par; | 136 | int ret, irq, par; |
138 | 137 | ||
139 | if (pdev->id == -1) { | 138 | if (pdev->id == -1) { |
@@ -178,35 +177,16 @@ static int msm_iommu_probe(struct platform_device *pdev) | |||
178 | iommu_clk = NULL; | 177 | iommu_clk = NULL; |
179 | 178 | ||
180 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "physbase"); | 179 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "physbase"); |
181 | 180 | regs_base = devm_ioremap_resource(&pdev->dev, r); | |
182 | if (!r) { | 181 | if (IS_ERR(regs_base)) { |
183 | ret = -ENODEV; | 182 | ret = PTR_ERR(regs_base); |
184 | goto fail_clk; | ||
185 | } | ||
186 | |||
187 | len = resource_size(r); | ||
188 | |||
189 | r2 = request_mem_region(r->start, len, r->name); | ||
190 | if (!r2) { | ||
191 | pr_err("Could not request memory region: start=%p, len=%d\n", | ||
192 | (void *) r->start, len); | ||
193 | ret = -EBUSY; | ||
194 | goto fail_clk; | 183 | goto fail_clk; |
195 | } | 184 | } |
196 | 185 | ||
197 | regs_base = ioremap(r2->start, len); | ||
198 | |||
199 | if (!regs_base) { | ||
200 | pr_err("Could not ioremap: start=%p, len=%d\n", | ||
201 | (void *) r2->start, len); | ||
202 | ret = -EBUSY; | ||
203 | goto fail_mem; | ||
204 | } | ||
205 | |||
206 | irq = platform_get_irq_byname(pdev, "secure_irq"); | 186 | irq = platform_get_irq_byname(pdev, "secure_irq"); |
207 | if (irq < 0) { | 187 | if (irq < 0) { |
208 | ret = -ENODEV; | 188 | ret = -ENODEV; |
209 | goto fail_io; | 189 | goto fail_clk; |
210 | } | 190 | } |
211 | 191 | ||
212 | msm_iommu_reset(regs_base, iommu_dev->ncb); | 192 | msm_iommu_reset(regs_base, iommu_dev->ncb); |
@@ -222,14 +202,14 @@ static int msm_iommu_probe(struct platform_device *pdev) | |||
222 | if (!par) { | 202 | if (!par) { |
223 | pr_err("%s: Invalid PAR value detected\n", iommu_dev->name); | 203 | pr_err("%s: Invalid PAR value detected\n", iommu_dev->name); |
224 | ret = -ENODEV; | 204 | ret = -ENODEV; |
225 | goto fail_io; | 205 | goto fail_clk; |
226 | } | 206 | } |
227 | 207 | ||
228 | ret = request_irq(irq, msm_iommu_fault_handler, 0, | 208 | ret = request_irq(irq, msm_iommu_fault_handler, 0, |
229 | "msm_iommu_secure_irpt_handler", drvdata); | 209 | "msm_iommu_secure_irpt_handler", drvdata); |
230 | if (ret) { | 210 | if (ret) { |
231 | pr_err("Request IRQ %d failed with ret=%d\n", irq, ret); | 211 | pr_err("Request IRQ %d failed with ret=%d\n", irq, ret); |
232 | goto fail_io; | 212 | goto fail_clk; |
233 | } | 213 | } |
234 | 214 | ||
235 | 215 | ||
@@ -250,10 +230,6 @@ static int msm_iommu_probe(struct platform_device *pdev) | |||
250 | clk_disable(iommu_pclk); | 230 | clk_disable(iommu_pclk); |
251 | 231 | ||
252 | return 0; | 232 | return 0; |
253 | fail_io: | ||
254 | iounmap(regs_base); | ||
255 | fail_mem: | ||
256 | release_mem_region(r->start, len); | ||
257 | fail_clk: | 233 | fail_clk: |
258 | if (iommu_clk) { | 234 | if (iommu_clk) { |
259 | clk_disable(iommu_clk); | 235 | clk_disable(iommu_clk); |