Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78411be4 authored by Jean Delvare's avatar Jean Delvare Committed by Wim Van Sebroeck
Browse files

watchdog: geodewdt: Use platform_driver_probe



Using platform_driver_probe instead of platform_driver_register has
two benefits:
* The driver will fail to load if device probing fails.
* The probe function can be marked __init.

Signed-off-by: default avatarJean Delvare <jdelvare@suse.de>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent acaaaf62
Loading
Loading
Loading
Loading
+7 −10
Original line number Original line Diff line number Diff line
@@ -215,7 +215,7 @@ static struct miscdevice geodewdt_miscdev = {
	.fops = &geodewdt_fops,
	.fops = &geodewdt_fops,
};
};


static int geodewdt_probe(struct platform_device *dev)
static int __init geodewdt_probe(struct platform_device *dev)
{
{
	int ret;
	int ret;


@@ -255,7 +255,6 @@ static void geodewdt_shutdown(struct platform_device *dev)
}
}


static struct platform_driver geodewdt_driver = {
static struct platform_driver geodewdt_driver = {
	.probe		= geodewdt_probe,
	.remove		= geodewdt_remove,
	.remove		= geodewdt_remove,
	.shutdown	= geodewdt_shutdown,
	.shutdown	= geodewdt_shutdown,
	.driver		= {
	.driver		= {
@@ -268,20 +267,18 @@ static int __init geodewdt_init(void)
{
{
	int ret;
	int ret;


	ret = platform_driver_register(&geodewdt_driver);
	if (ret)
		return ret;

	geodewdt_platform_device = platform_device_register_simple(DRV_NAME,
	geodewdt_platform_device = platform_device_register_simple(DRV_NAME,
								-1, NULL, 0);
								-1, NULL, 0);
	if (IS_ERR(geodewdt_platform_device)) {
	if (IS_ERR(geodewdt_platform_device))
		ret = PTR_ERR(geodewdt_platform_device);
		return PTR_ERR(geodewdt_platform_device);

	ret = platform_driver_probe(&geodewdt_driver, geodewdt_probe);
	if (ret)
		goto err;
		goto err;
	}


	return 0;
	return 0;
err:
err:
	platform_driver_unregister(&geodewdt_driver);
	platform_device_unregister(geodewdt_platform_device);
	return ret;
	return ret;
}
}