leds-88pm860x: use devm_kzalloc function
Using devm_kzalloc will remove all the error checks and the frees are automatically done at the driver unload side. Signed-off-by: Devendra Naga <devendra.aaru@gmail.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
This commit is contained in:
parent
5391dd0a9d
commit
b523cfe61b
|
@ -209,7 +209,7 @@ static int pm860x_led_probe(struct platform_device *pdev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = kzalloc(sizeof(struct pm860x_led), GFP_KERNEL);
|
data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_led), GFP_KERNEL);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
strncpy(data->name, res->name, MFD_NAME_SIZE - 1);
|
strncpy(data->name, res->name, MFD_NAME_SIZE - 1);
|
||||||
|
@ -220,7 +220,6 @@ static int pm860x_led_probe(struct platform_device *pdev)
|
||||||
data->port = pdata->flags;
|
data->port = pdata->flags;
|
||||||
if (data->port < 0) {
|
if (data->port < 0) {
|
||||||
dev_err(&pdev->dev, "check device failed\n");
|
dev_err(&pdev->dev, "check device failed\n");
|
||||||
kfree(data);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,13 +232,10 @@ static int pm860x_led_probe(struct platform_device *pdev)
|
||||||
ret = led_classdev_register(chip->dev, &data->cdev);
|
ret = led_classdev_register(chip->dev, &data->cdev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&pdev->dev, "Failed to register LED: %d\n", ret);
|
dev_err(&pdev->dev, "Failed to register LED: %d\n", ret);
|
||||||
goto out;
|
return ret;
|
||||||
}
|
}
|
||||||
pm860x_led_set(&data->cdev, 0);
|
pm860x_led_set(&data->cdev, 0);
|
||||||
return 0;
|
return 0;
|
||||||
out:
|
|
||||||
kfree(data);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pm860x_led_remove(struct platform_device *pdev)
|
static int pm860x_led_remove(struct platform_device *pdev)
|
||||||
|
@ -247,7 +243,6 @@ static int pm860x_led_remove(struct platform_device *pdev)
|
||||||
struct pm860x_led *data = platform_get_drvdata(pdev);
|
struct pm860x_led *data = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
led_classdev_unregister(&data->cdev);
|
led_classdev_unregister(&data->cdev);
|
||||||
kfree(data);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue