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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值