reboot系统调用的时候会调用shutdown函数

来源:互联网 发布:手机不能连接数据网络 编辑:程序博客网 时间:2024/06/05 03:32
在注册platform_driver的时候,其中的shutdown函数是什么时候调用的呢?static struct platform_driver advwdt_driver = {.remove= advwdt_remove,.shutdown= advwdt_shutdown,.driver= {.name= DRV_NAME,},};其调用flow如下:reboot->kernel_restart->kernel_restart_prepare->device_shutdownvoid device_shutdown(void){//从device_shutdown的实现看首先调用bus->shutdown,如果bus没有shutdown,则调用dev->driver->shutdownif (dev->bus && dev->bus->shutdown) {if (initcall_debug)dev_info(dev, "shutdown\n");dev->bus->shutdown(dev);} else if (dev->driver && dev->driver->shutdown) {if (initcall_debug)dev_info(dev, "shutdown\n");dev->driver->shutdown(dev);}}而platform_bus_type 定义如下:struct bus_type platform_bus_type = {.name= "platform",.dev_groups= platform_dev_groups,.match= platform_match,.uevent= platform_uevent,.pm= &platform_dev_pm_ops,};可以看到platform_bus_type 并没有定义shutdown函数,因此在device_shutdown 中最终会调用driver->shutdown本例子中就是调用advwdt_shutdown

原创粉丝点击