为什么在调用has_power_file()时启用和禁用PCIe插槽?

时间:2018-09-27 03:38:04

标签: linux driver pci

https://github.com/torvalds/linux/blob/d01e12dd3f4227f1be5d7c5bffa7b8240787bec1/drivers/pci/hotplug/pci_hotplug_core.c#L293

static int fs_add_slot(struct pci_slot *pci_slot)
{
    int retval = 0;

    /* Create symbolic link to the hotplug driver module */
    pci_hp_create_module_link(pci_slot);

    if (has_power_file(pci_slot)) {
        retval = sysfs_create_file(&pci_slot->kobj,
                       &hotplug_slot_attr_power.attr);
        if (retval)
            goto exit_power;
}

在检查pci代码的这一部分时,我们可以看到

has_power_file(pci_slot)

将被执行。但是,在

has_power_file():

https://github.com/torvalds/linux/blob/d01e12dd3f4227f1be5d7c5bffa7b8240787bec1/drivers/pci/hotplug/pci_hotplug_core.c#L235

static bool has_power_file(struct pci_slot *pci_slot)
{
    struct hotplug_slot *slot = pci_slot->hotplug;

    if ((!slot) || (!slot->ops))
        return false;
    if ((slot->ops->enable_slot) ||   /////////// why force enable here ?
        (slot->ops->disable_slot) ||  ////////// why force disalbe here ?
        (slot->ops->get_power_status))
        return true;
    return false;
}

我们可以看到插槽将被启用和禁用,我认为它改变了原来的插槽状态,不是吗?

0 个答案:

没有答案