mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
watchdog: advantechwdt: 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: Jean Delvare <jdelvare@suse.de> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
This commit is contained in:
parent
b0e0b4b598
commit
acaaaf62c9
1 changed files with 9 additions and 12 deletions
|
@ -238,7 +238,7 @@ static struct miscdevice advwdt_miscdev = {
|
||||||
* Init & exit routines
|
* Init & exit routines
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int advwdt_probe(struct platform_device *dev)
|
static int __init advwdt_probe(struct platform_device *dev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -299,7 +299,6 @@ static void advwdt_shutdown(struct platform_device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct platform_driver advwdt_driver = {
|
static struct platform_driver advwdt_driver = {
|
||||||
.probe = advwdt_probe,
|
|
||||||
.remove = advwdt_remove,
|
.remove = advwdt_remove,
|
||||||
.shutdown = advwdt_shutdown,
|
.shutdown = advwdt_shutdown,
|
||||||
.driver = {
|
.driver = {
|
||||||
|
@ -314,21 +313,19 @@ static int __init advwdt_init(void)
|
||||||
|
|
||||||
pr_info("WDT driver for Advantech single board computer initialising\n");
|
pr_info("WDT driver for Advantech single board computer initialising\n");
|
||||||
|
|
||||||
err = platform_driver_register(&advwdt_driver);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
advwdt_platform_device = platform_device_register_simple(DRV_NAME,
|
advwdt_platform_device = platform_device_register_simple(DRV_NAME,
|
||||||
-1, NULL, 0);
|
-1, NULL, 0);
|
||||||
if (IS_ERR(advwdt_platform_device)) {
|
if (IS_ERR(advwdt_platform_device))
|
||||||
err = PTR_ERR(advwdt_platform_device);
|
return PTR_ERR(advwdt_platform_device);
|
||||||
goto unreg_platform_driver;
|
|
||||||
}
|
err = platform_driver_probe(&advwdt_driver, advwdt_probe);
|
||||||
|
if (err)
|
||||||
|
goto unreg_platform_device;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
unreg_platform_driver:
|
unreg_platform_device:
|
||||||
platform_driver_unregister(&advwdt_driver);
|
platform_device_unregister(advwdt_platform_device);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue