zoukankan      html  css  js  c++  java
  • 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 ");
    dev->bus->shutdown(dev);
    } else if (dev->driver && dev->driver->shutdown) {
    if (initcall_debug)
    dev_info(dev, "shutdown ");
    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

  • 相关阅读:
    Codeforces #364 DIV2
    uva10635 LIS
    hdu3714 三分找最值
    【转】三分查找
    NBUT 1457 莫队算法 离散化
    HYSBZ 2038 莫队算法
    莫队算法
    poj3417 LCA + 树形dp
    hdu3087 LCA + 暴力
    hdu2874 LCA在线算法
  • 原文地址:https://www.cnblogs.com/aspirs/p/13686554.html
Copyright © 2011-2022 走看看