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

在注册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_shutdown
void device_shutdown(void)
{
//从device_shutdown的实现看首先调用bus->shutdown,如果bus没有shutdown,则调用dev->driver->shutdown

if (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

 

from: https://blog.csdn.net/tiantao2012/article/details/78095181?utm_source=blogxgwz1

 

posted @   aspirs  阅读(665)  评论(0编辑  收藏  举报
编辑推荐:
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
阅读排行:
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
历史上的今天:
2017-09-17 linux硬链接和软链接的区别
2017-09-17 du -sh
点击右上角即可分享
微信分享提示