Date:2012-11-07 00:11:12 (7 years 1 month ago)
Author:Marcos Paulo de Souza
Commit:969f08bd1e239a9bd78f87259234d5da9c169b3e
Message:drivers/power/jz4740-battery.c: Use devm_request_and_ioremap

No functional changes. Just a cleanup.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Files: drivers/power/jz4740-battery.c (6 diffs)

Change Details

drivers/power/jz4740-battery.c
3333    struct jz_battery_platform_data *pdata;
3434    struct platform_device *pdev;
3535
36    struct resource *mem;
3736    void __iomem *base;
3837
3938    int irq;
...... 
246245    struct jz_battery_platform_data *pdata = pdev->dev.parent->platform_data;
247246    struct jz_battery *jz_battery;
248247    struct power_supply *battery;
248    struct resource *mem;
249249
250250    if (!pdata) {
251251        dev_err(&pdev->dev, "No platform_data supplied\n");
...... 
266266        return jz_battery->irq;
267267    }
268268
269    jz_battery->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
270    if (!jz_battery->mem) {
271        dev_err(&pdev->dev, "Failed to get platform mmio resource\n");
272        return -ENOENT;
273    }
269    mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
274270
275    jz_battery->mem = request_mem_region(jz_battery->mem->start,
276                resource_size(jz_battery->mem), pdev->name);
277    if (!jz_battery->mem) {
278        dev_err(&pdev->dev, "Failed to request mmio memory region\n");
271    jz_battery->base = devm_request_and_ioremap(&pdev->dev, mem);
272    if (!jz_battery->base)
279273        return -EBUSY;
280    }
281
282    jz_battery->base = ioremap_nocache(jz_battery->mem->start,
283                resource_size(jz_battery->mem));
284    if (!jz_battery->base) {
285        ret = -EBUSY;
286        dev_err(&pdev->dev, "Failed to ioremap mmio memory\n");
287        goto err_release_mem_region;
288    }
289274
290275    battery = &jz_battery->battery;
291276    battery->name = pdata->info.name;
...... 
308293            jz_battery);
309294    if (ret) {
310295        dev_err(&pdev->dev, "Failed to request irq %d\n", ret);
311        goto err_iounmap;
296        goto err;
312297    }
313298    disable_irq(jz_battery->irq);
314299
...... 
365350        gpio_free(jz_battery->pdata->gpio_charge);
366351err_free_irq:
367352    free_irq(jz_battery->irq, jz_battery);
368err_iounmap:
353err:
369354    platform_set_drvdata(pdev, NULL);
370    iounmap(jz_battery->base);
371err_release_mem_region:
372    release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem));
373355    return ret;
374356}
375357
...... 
389371
390372    free_irq(jz_battery->irq, jz_battery);
391373
392    iounmap(jz_battery->base);
393    release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem));
394
395374    return 0;
396375}
397376

Archive Download the corresponding diff file



interactive