Зачем включать и отключать слот PCIe при вызове has_power_file ()? - PullRequest
0 голосов
/ 27 сентября 2018

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;
}

мы видим, что слот будет включен и отключен, я думаю, что он изменил исходный статус слота, не так ли?

...