aboutsummaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorMarcos Paulo de Souza2012-11-06 21:11:12 -0200
committerAnton Vorontsov2012-11-18 16:10:45 -0800
commit9790f98fdcfb1c60b953973ae256d00857b5ebb7 (patch)
treed07c4b7b0e3d6748a7276c83103dcc580fb21546 /drivers/power
parentec073c9b319fee6564dcb9f1fb7a70eb6a8a06b5 (diff)
jz4740-battery: Use devm_request_and_ioremap
No functional changes. Just a cleanup. Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/jz4740-battery.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/drivers/power/jz4740-battery.c b/drivers/power/jz4740-battery.c
index 529d22abe0e2..fc7550d4d568 100644
--- a/drivers/power/jz4740-battery.c
+++ b/drivers/power/jz4740-battery.c
@@ -33,7 +33,6 @@ struct jz_battery {
struct jz_battery_platform_data *pdata;
struct platform_device *pdev;
- struct resource *mem;
void __iomem *base;
int irq;
@@ -244,6 +243,7 @@ static int __devinit jz_battery_probe(struct platform_device *pdev)
struct jz_battery_platform_data *pdata = pdev->dev.parent->platform_data;
struct jz_battery *jz_battery;
struct power_supply *battery;
+ struct resource *mem;
if (!pdata) {
dev_err(&pdev->dev, "No platform_data supplied\n");
@@ -264,26 +264,11 @@ static int __devinit jz_battery_probe(struct platform_device *pdev)
return jz_battery->irq;
}
- jz_battery->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!jz_battery->mem) {
- dev_err(&pdev->dev, "Failed to get platform mmio resource\n");
- return -ENOENT;
- }
+ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- jz_battery->mem = request_mem_region(jz_battery->mem->start,
- resource_size(jz_battery->mem), pdev->name);
- if (!jz_battery->mem) {
- dev_err(&pdev->dev, "Failed to request mmio memory region\n");
+ jz_battery->base = devm_request_and_ioremap(&pdev->dev, mem);
+ if (!jz_battery->base)
return -EBUSY;
- }
-
- jz_battery->base = ioremap_nocache(jz_battery->mem->start,
- resource_size(jz_battery->mem));
- if (!jz_battery->base) {
- ret = -EBUSY;
- dev_err(&pdev->dev, "Failed to ioremap mmio memory\n");
- goto err_release_mem_region;
- }
battery = &jz_battery->battery;
battery->name = pdata->info.name;
@@ -306,7 +291,7 @@ static int __devinit jz_battery_probe(struct platform_device *pdev)
jz_battery);
if (ret) {
dev_err(&pdev->dev, "Failed to request irq %d\n", ret);
- goto err_iounmap;
+ goto err;
}
disable_irq(jz_battery->irq);
@@ -363,11 +348,8 @@ err_free_gpio:
gpio_free(jz_battery->pdata->gpio_charge);
err_free_irq:
free_irq(jz_battery->irq, jz_battery);
-err_iounmap:
+err:
platform_set_drvdata(pdev, NULL);
- iounmap(jz_battery->base);
-err_release_mem_region:
- release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem));
return ret;
}
@@ -387,9 +369,6 @@ static int __devexit jz_battery_remove(struct platform_device *pdev)
free_irq(jz_battery->irq, jz_battery);
- iounmap(jz_battery->base);
- release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem));
-
return 0;
}