leds: Use devm_kzalloc in leds-pwm.c file
authorSachin Kamat <sachin.kamat@linaro.org>
Tue, 3 Jul 2012 11:47:53 +0000 (19:47 +0800)
committerBryan Wu <bryan.wu@canonical.com>
Mon, 23 Jul 2012 23:52:36 +0000 (07:52 +0800)
devm_kzalloc() makes cleanup simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
drivers/leds/leds-pwm.c

index 3ed92f34bd4477108549499e7bbf4959af1a56cd..f2e44c7194374f135906fc3e9aa4ac87ca33a6bb 100644 (file)
@@ -57,7 +57,8 @@ static int led_pwm_probe(struct platform_device *pdev)
        if (!pdata)
                return -EBUSY;
 
-       leds_data = kzalloc(sizeof(struct led_pwm_data) * pdata->num_leds,
+       leds_data = devm_kzalloc(&pdev->dev,
+                       sizeof(struct led_pwm_data) * pdata->num_leds,
                                GFP_KERNEL);
        if (!leds_data)
                return -ENOMEM;
@@ -103,8 +104,6 @@ err:
                }
        }
 
-       kfree(leds_data);
-
        return ret;
 }
 
@@ -121,8 +120,6 @@ static int __devexit led_pwm_remove(struct platform_device *pdev)
                pwm_free(leds_data[i].pwm);
        }
 
-       kfree(leds_data);
-
        return 0;
 }