]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mfd: ab8500-debug: Convert to managed resources for allocating memory
authorLee Jones <lee.jones@linaro.org>
Thu, 23 May 2013 15:25:05 +0000 (16:25 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 13 Jun 2013 10:11:40 +0000 (12:11 +0200)
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/ab8500-debugfs.c

index 11656c2c63cb41b640ebfb8a3e5e7af3efe8eea1..7d1f1b08fc4be76c20310879b34b0a2394c3034f 100644 (file)
@@ -2937,7 +2937,6 @@ static struct dentry *ab8500_gpadc_dir;
 static int ab8500_debug_probe(struct platform_device *plf)
 {
        struct dentry *file;
-       int ret = -ENOMEM;
        struct ab8500 *ab8500;
        struct resource *res;
        debug_bank = AB8500_MISC;
@@ -2946,24 +2945,26 @@ static int ab8500_debug_probe(struct platform_device *plf)
        ab8500 = dev_get_drvdata(plf->dev.parent);
        num_irqs = ab8500->mask_size;
 
-       irq_count = kzalloc(sizeof(*irq_count)*num_irqs, GFP_KERNEL);
+       irq_count = devm_kzalloc(&plf->dev,
+                                sizeof(*irq_count)*num_irqs, GFP_KERNEL);
        if (!irq_count)
                return -ENOMEM;
 
-       dev_attr = kzalloc(sizeof(*dev_attr)*num_irqs,GFP_KERNEL);
+       dev_attr = devm_kzalloc(&plf->dev,
+                               sizeof(*dev_attr)*num_irqs,GFP_KERNEL);
        if (!dev_attr)
-               goto out_freeirq_count;
+               return -ENOMEM;
 
-       event_name = kzalloc(sizeof(*event_name)*num_irqs, GFP_KERNEL);
+       event_name = devm_kzalloc(&plf->dev,
+                                 sizeof(*event_name)*num_irqs, GFP_KERNEL);
        if (!event_name)
-               goto out_freedev_attr;
+               return -ENOMEM;
 
        res = platform_get_resource_byname(plf, 0, "IRQ_AB8500");
        if (!res) {
                dev_err(&plf->dev, "AB8500 irq not found, err %d\n",
                        irq_first);
-               ret = -ENXIO;
-               goto out_freeevent_name;
+               return ENXIO;
        }
        irq_ab8500 = res->start;
 
@@ -2971,16 +2972,14 @@ static int ab8500_debug_probe(struct platform_device *plf)
        if (irq_first < 0) {
                dev_err(&plf->dev, "First irq not found, err %d\n",
                        irq_first);
-               ret = irq_first;
-               goto out_freeevent_name;
+               return irq_first;
        }
 
        irq_last = platform_get_irq_byname(plf, "IRQ_LAST");
        if (irq_last < 0) {
                dev_err(&plf->dev, "Last irq not found, err %d\n",
                        irq_last);
-               ret = irq_last;
-               goto out_freeevent_name;
+               return irq_last;
        }
 
        ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
@@ -3189,22 +3188,13 @@ err:
        if (ab8500_dir)
                debugfs_remove_recursive(ab8500_dir);
        dev_err(&plf->dev, "failed to create debugfs entries.\n");
-out_freeevent_name:
-       kfree(event_name);
-out_freedev_attr:
-       kfree(dev_attr);
-out_freeirq_count:
-       kfree(irq_count);
 
-       return ret;
+       return -ENOMEM;
 }
 
 static int ab8500_debug_remove(struct platform_device *plf)
 {
        debugfs_remove_recursive(ab8500_dir);
-       kfree(event_name);
-       kfree(dev_attr);
-       kfree(irq_count);
 
        return 0;
 }