Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: ab8500-debug: Convert to managed resources for allocating memory

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Lee Jones and committed by
Samuel Ortiz
c18cf6d1 5feac05d

+12 -22
+12 -22
drivers/mfd/ab8500-debugfs.c
··· 2937 2937 static int ab8500_debug_probe(struct platform_device *plf) 2938 2938 { 2939 2939 struct dentry *file; 2940 - int ret = -ENOMEM; 2941 2940 struct ab8500 *ab8500; 2942 2941 struct resource *res; 2943 2942 debug_bank = AB8500_MISC; ··· 2945 2946 ab8500 = dev_get_drvdata(plf->dev.parent); 2946 2947 num_irqs = ab8500->mask_size; 2947 2948 2948 - irq_count = kzalloc(sizeof(*irq_count)*num_irqs, GFP_KERNEL); 2949 + irq_count = devm_kzalloc(&plf->dev, 2950 + sizeof(*irq_count)*num_irqs, GFP_KERNEL); 2949 2951 if (!irq_count) 2950 2952 return -ENOMEM; 2951 2953 2952 - dev_attr = kzalloc(sizeof(*dev_attr)*num_irqs,GFP_KERNEL); 2954 + dev_attr = devm_kzalloc(&plf->dev, 2955 + sizeof(*dev_attr)*num_irqs,GFP_KERNEL); 2953 2956 if (!dev_attr) 2954 - goto out_freeirq_count; 2957 + return -ENOMEM; 2955 2958 2956 - event_name = kzalloc(sizeof(*event_name)*num_irqs, GFP_KERNEL); 2959 + event_name = devm_kzalloc(&plf->dev, 2960 + sizeof(*event_name)*num_irqs, GFP_KERNEL); 2957 2961 if (!event_name) 2958 - goto out_freedev_attr; 2962 + return -ENOMEM; 2959 2963 2960 2964 res = platform_get_resource_byname(plf, 0, "IRQ_AB8500"); 2961 2965 if (!res) { 2962 2966 dev_err(&plf->dev, "AB8500 irq not found, err %d\n", 2963 2967 irq_first); 2964 - ret = -ENXIO; 2965 - goto out_freeevent_name; 2968 + return ENXIO; 2966 2969 } 2967 2970 irq_ab8500 = res->start; 2968 2971 ··· 2972 2971 if (irq_first < 0) { 2973 2972 dev_err(&plf->dev, "First irq not found, err %d\n", 2974 2973 irq_first); 2975 - ret = irq_first; 2976 - goto out_freeevent_name; 2974 + return irq_first; 2977 2975 } 2978 2976 2979 2977 irq_last = platform_get_irq_byname(plf, "IRQ_LAST"); 2980 2978 if (irq_last < 0) { 2981 2979 dev_err(&plf->dev, "Last irq not found, err %d\n", 2982 2980 irq_last); 2983 - ret = irq_last; 2984 - goto out_freeevent_name; 2981 + return irq_last; 2985 2982 } 2986 2983 2987 2984 ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL); ··· 3188 3189 if (ab8500_dir) 3189 3190 debugfs_remove_recursive(ab8500_dir); 3190 3191 dev_err(&plf->dev, "failed to create debugfs entries.\n"); 3191 - out_freeevent_name: 3192 - kfree(event_name); 3193 - out_freedev_attr: 3194 - kfree(dev_attr); 3195 - out_freeirq_count: 3196 - kfree(irq_count); 3197 3192 3198 - return ret; 3193 + return -ENOMEM; 3199 3194 } 3200 3195 3201 3196 static int ab8500_debug_remove(struct platform_device *plf) 3202 3197 { 3203 3198 debugfs_remove_recursive(ab8500_dir); 3204 - kfree(event_name); 3205 - kfree(dev_attr); 3206 - kfree(irq_count); 3207 3199 3208 3200 return 0; 3209 3201 }