Linux的WDT(watchdog)驱动(6)


/*
 *platform_driver s3c2410wdt_driver 与 platform_device s3c_device_wdt 对应
 *s3c_device_wdt 在arch/arm/plat-s3c24xx/devs.c中定义
 *两者的工作顺序是先定义platform_device -> 注册 platform_device->
 *在mini2440_machine_init()中完成
 *再定义 platform_driver-> 注册 platform_driver
 */
static struct platform_driver s3c2410wdt_driver = {
    .probe = s3c2410wdt_probe, //设备的检测,所以需要先注册设备
    .remove = __devexit_p(s3c2410wdt_remove), //删除该设备
    .shutdown = s3c2410wdt_shutdown, //关闭该设备
    .suspend = s3c2410wdt_suspend,
    .resume = s3c2410wdt_resume,
    .driver = { //设备驱动
        .owner = THIS_MODULE,
        /*
        *对应 struct platform_device s3c_device_wdt = {
        *    .name        = "s3c2410-wdt",
        *      ...
        *    };
        */
        .name = "s3c2410-wdt",
    },
};


static char banner[] __initdata =
    KERN_INFO "S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics\n";

static int __init watchdog_init(void) //模块初始化
{
    printk(banner); //打印信息
    return platform_driver_register(&s3c2410wdt_driver); //注册设备的驱动程序
}

static void __exit watchdog_exit(void) //移除模块
{
    platform_driver_unregister(&s3c2410wdt_driver); //unregister a driver for platform-level devices
}

module_init(watchdog_init);
module_exit(watchdog_exit);

MODULE_AUTHOR("Ben Dooks , "
          "Dimitry Andric ");
MODULE_DESCRIPTION("S3C2410 Watchdog Device Driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
MODULE_ALIAS("platform:s3c2410-wdt");

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/16180.html