mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 15:18:19 +00:00
leds: convert Network Space v2 LED driver to devm_kzalloc() and cleanup error exit path
Cc: Simon Guinot <sguinot@lacie.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
This commit is contained in:
parent
e58603122e
commit
a209f76698
1 changed files with 6 additions and 13 deletions
|
@ -273,29 +273,23 @@ static int __devinit ns2_led_probe(struct platform_device *pdev)
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
leds_data = kzalloc(sizeof(struct ns2_led_data) *
|
leds_data = devm_kzalloc(&pdev->dev, sizeof(struct ns2_led_data) *
|
||||||
pdata->num_leds, GFP_KERNEL);
|
pdata->num_leds, GFP_KERNEL);
|
||||||
if (!leds_data)
|
if (!leds_data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
for (i = 0; i < pdata->num_leds; i++) {
|
for (i = 0; i < pdata->num_leds; i++) {
|
||||||
ret = create_ns2_led(pdev, &leds_data[i], &pdata->leds[i]);
|
ret = create_ns2_led(pdev, &leds_data[i], &pdata->leds[i]);
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
goto err;
|
for (i = i - 1; i >= 0; i--)
|
||||||
|
delete_ns2_led(&leds_data[i]);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, leds_data);
|
platform_set_drvdata(pdev, leds_data);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
|
||||||
for (i = i - 1; i >= 0; i--)
|
|
||||||
delete_ns2_led(&leds_data[i]);
|
|
||||||
|
|
||||||
kfree(leds_data);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __devexit ns2_led_remove(struct platform_device *pdev)
|
static int __devexit ns2_led_remove(struct platform_device *pdev)
|
||||||
|
@ -309,7 +303,6 @@ static int __devexit ns2_led_remove(struct platform_device *pdev)
|
||||||
for (i = 0; i < pdata->num_leds; i++)
|
for (i = 0; i < pdata->num_leds; i++)
|
||||||
delete_ns2_led(&leds_data[i]);
|
delete_ns2_led(&leds_data[i]);
|
||||||
|
|
||||||
kfree(leds_data);
|
|
||||||
platform_set_drvdata(pdev, NULL);
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue