• Lukas Wunner's avatar
    PCI: Autosense device removal in pci_bridge_d3_update() · 1ed276a7
    Lukas Wunner authored
    The algorithm to update the flag indicating whether a bridge may go to D3
    makes a few optimizations based on whether the update was caused by the
    removal of a device on the one hand, versus the addition of a device or the
    change of its D3cold flags on the other hand.
    
    The information whether the update pertains to a removal is currently
    passed in by the caller, but the function may as well determine that itself
    by examining the device in question, thereby allowing for a considerable
    simplification and reduction of the code.
    
    Out of several options to determine removal, I've chosen the function
    device_is_registered() because it's cheap:  It merely returns the
    dev->kobj.state_in_sysfs flag.  That flag is set through device_add() when
    the root bus is scanned and cleared through device_remove().  The call to
    pci_bridge_d3_update() happens after each of these calls, respectively, so
    the ordering is correct.
    
    No functional change intended.
    Tested-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
    Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
    Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    1ed276a7
pci.c 137 KB