void pciehp_handle_disable_request(struct slot *slot);
 void pciehp_handle_presence_or_link_change(struct slot *slot, u32 events);
 int pciehp_configure_device(struct slot *p_slot);
-void pciehp_unconfigure_device(struct slot *p_slot);
+void pciehp_unconfigure_device(struct slot *p_slot, bool presence);
 void pciehp_queue_pushbutton_work(struct work_struct *work);
 struct controller *pcie_init(struct pcie_device *dev);
 int pcie_init_notification(struct controller *ctrl);
 
    hotplug controller logic
  */
 
+#define SAFE_REMOVAL    true
+#define SURPRISE_REMOVAL false
+
 static void set_slot_off(struct controller *ctrl, struct slot *pslot)
 {
        /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
 /**
  * remove_board - Turns off slot and LEDs
  * @p_slot: slot where board is being removed
+ * @safe_removal: whether the board is safely removed (versus surprise removed)
  */
-static void remove_board(struct slot *p_slot)
+static void remove_board(struct slot *p_slot, bool safe_removal)
 {
        struct controller *ctrl = p_slot->ctrl;
 
-       pciehp_unconfigure_device(p_slot);
+       pciehp_unconfigure_device(p_slot, safe_removal);
 
        if (POWER_CTRL(ctrl)) {
                pciehp_power_off_slot(p_slot);
 }
 
 static int pciehp_enable_slot(struct slot *slot);
-static int pciehp_disable_slot(struct slot *slot);
+static int pciehp_disable_slot(struct slot *slot, bool safe_removal);
 
 void pciehp_request(struct controller *ctrl, int action)
 {
        slot->state = POWEROFF_STATE;
        mutex_unlock(&slot->lock);
 
-       ctrl->request_result = pciehp_disable_slot(slot);
+       ctrl->request_result = pciehp_disable_slot(slot, SAFE_REMOVAL);
 }
 
 void pciehp_handle_presence_or_link_change(struct slot *slot, u32 events)
                if (events & PCI_EXP_SLTSTA_PDC)
                        ctrl_info(ctrl, "Slot(%s): Card not present\n",
                                  slot_name(slot));
-               pciehp_disable_slot(slot);
+               pciehp_disable_slot(slot, SURPRISE_REMOVAL);
                break;
        default:
                mutex_unlock(&slot->lock);
        return ret;
 }
 
-static int __pciehp_disable_slot(struct slot *p_slot)
+static int __pciehp_disable_slot(struct slot *p_slot, bool safe_removal)
 {
        u8 getstatus = 0;
        struct controller *ctrl = p_slot->ctrl;
                }
        }
 
-       remove_board(p_slot);
+       remove_board(p_slot, safe_removal);
        return 0;
 }
 
-static int pciehp_disable_slot(struct slot *slot)
+static int pciehp_disable_slot(struct slot *slot, bool safe_removal)
 {
        struct controller *ctrl = slot->ctrl;
        int ret;
 
        pm_runtime_get_sync(&ctrl->pcie->port->dev);
-       ret = __pciehp_disable_slot(slot);
+       ret = __pciehp_disable_slot(slot, safe_removal);
        pm_runtime_put(&ctrl->pcie->port->dev);
 
        mutex_lock(&slot->lock);
 
 #include "../pci.h"
 #include "pciehp.h"
 
+/**
+ * pciehp_configure_device() - enumerate PCI devices below a hotplug bridge
+ * @p_slot: PCIe hotplug slot
+ *
+ * Enumerate PCI devices below a hotplug bridge and add them to the system.
+ * Return 0 on success, %-EEXIST if the devices are already enumerated or
+ * %-ENODEV if enumeration failed.
+ */
 int pciehp_configure_device(struct slot *p_slot)
 {
        struct pci_dev *dev;
        return ret;
 }
 
-void pciehp_unconfigure_device(struct slot *p_slot)
+/**
+ * pciehp_unconfigure_device() - remove PCI devices below a hotplug bridge
+ * @p_slot: PCIe hotplug slot
+ * @presence: whether the card is still present in the slot;
+ *     true for safe removal via sysfs or an Attention Button press,
+ *     false for surprise removal
+ *
+ * Unbind PCI devices below a hotplug bridge from their drivers and remove
+ * them from the system.  Safely removed devices are quiesced.  Surprise
+ * removed devices are marked as such to prevent further accesses.
+ */
+void pciehp_unconfigure_device(struct slot *p_slot, bool presence)
 {
-       u8 presence = 0;
        struct pci_dev *dev, *temp;
        struct pci_bus *parent = p_slot->ctrl->pcie->port->subordinate;
        u16 command;
 
        ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n",
                 __func__, pci_domain_nr(parent), parent->number);
-       pciehp_get_adapter_status(p_slot, &presence);
 
        if (!presence)
                pci_walk_bus(parent, pci_dev_set_disconnected, NULL);