Skip to content

Commit

Permalink
leds: Use devm_kzalloc in leds-pwm.c file
Browse files Browse the repository at this point in the history
devm_kzalloc() makes cleanup simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
  • Loading branch information
Sachin Kamat authored and Bryan Wu committed Jul 23, 2012
1 parent 7fafefb commit 0b7da74
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/leds/leds-pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -103,8 +104,6 @@ static int led_pwm_probe(struct platform_device *pdev)
}
}

kfree(leds_data);

return ret;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 0b7da74

Please sign in to comment.