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

This is just a cleanup.

Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Files: drivers/power/jz4740-battery.c (4 diffs)

Change Details

drivers/power/jz4740-battery.c
252252        return -ENXIO;
253253    }
254254
255    jz_battery = kzalloc(sizeof(*jz_battery), GFP_KERNEL);
255    jz_battery = devm_kzalloc(&pdev->dev, sizeof(*jz_battery), GFP_KERNEL);
256256    if (!jz_battery) {
257257        dev_err(&pdev->dev, "Failed to allocate driver structure\n");
258258        return -ENOMEM;
...... 
262262
263263    jz_battery->irq = platform_get_irq(pdev, 0);
264264    if (jz_battery->irq < 0) {
265        ret = jz_battery->irq;
266265        dev_err(&pdev->dev, "Failed to get platform irq: %d\n", ret);
267        goto err_free;
266        return jz_battery->irq;
268267    }
269268
270269    jz_battery->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
271270    if (!jz_battery->mem) {
272        ret = -ENOENT;
273271        dev_err(&pdev->dev, "Failed to get platform mmio resource\n");
274        goto err_free;
272        return -ENOENT;
275273    }
276274
277275    jz_battery->mem = request_mem_region(jz_battery->mem->start,
278276                resource_size(jz_battery->mem), pdev->name);
279277    if (!jz_battery->mem) {
280        ret = -EBUSY;
281278        dev_err(&pdev->dev, "Failed to request mmio memory region\n");
282        goto err_free;
279        return -EBUSY;
283280    }
284281
285282    jz_battery->base = ioremap_nocache(jz_battery->mem->start,
...... 
373370    iounmap(jz_battery->base);
374371err_release_mem_region:
375372    release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem));
376err_free:
377    kfree(jz_battery);
378373    return ret;
379374}
380375
...... 
396391
397392    iounmap(jz_battery->base);
398393    release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem));
399    kfree(jz_battery);
400394
401395    return 0;
402396}

Archive Download the corresponding diff file



interactive