intel-iommu: Fix integer overflow in dma_pte_{clear_range,free_pagetable}()
[safe/jmp/linux-2.6] / drivers / pci / slot.c
index 4dd1c3e..8c02b6c 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * drivers/pci/slot.c
  * Copyright (C) 2006 Matthew Wilcox <matthew@wil.cx>
- * Copyright (C) 2006-2008 Hewlett-Packard Development Company, L.P.
- *     Alex Chiang <achiang@hp.com>
+ * Copyright (C) 2006-2009 Hewlett-Packard Development Company, L.P.
+ *     Alex Chiang <achiang@hp.com>
  */
 
 #include <linux/kobject.h>
@@ -52,8 +52,8 @@ static void pci_slot_release(struct kobject *kobj)
        struct pci_dev *dev;
        struct pci_slot *slot = to_pci_slot(kobj);
 
-       pr_debug("%s: releasing pci_slot on %x:%d\n", __func__,
-                slot->bus->number, slot->number);
+       dev_dbg(&slot->bus->dev, "dev %02x, released physical slot %s\n",
+               slot->number, pci_slot_name(slot));
 
        list_for_each_entry(dev, &slot->bus->devices, bus_list)
                if (PCI_SLOT(dev->devfn) == slot->number)
@@ -248,11 +248,11 @@ placeholder:
                if (PCI_SLOT(dev->devfn) == slot_nr)
                        dev->slot = slot;
 
-       /* Don't care if debug printk has a -1 for slot_nr */
-       pr_debug("%s: created pci_slot on %04x:%02x:%02x\n",
-                __func__, pci_domain_nr(parent), parent->number, slot_nr);
+       dev_dbg(&parent->dev, "dev %02x, created physical slot %s\n",
+               slot_nr, pci_slot_name(slot));
 
 out:
+       kfree(slot_name);
        up_write(&pci_bus_sem);
        return slot;
 err:
@@ -264,8 +264,8 @@ EXPORT_SYMBOL_GPL(pci_create_slot);
 
 /**
  * pci_renumber_slot - update %struct pci_slot -> number
- * @slot - %struct pci_slot to update
- * @slot_nr - new number for slot
+ * @slot: &struct pci_slot to update
+ * @slot_nr: new number for slot
  *
  * The primary purpose of this interface is to allow callers who earlier
  * created a placeholder slot in pci_create_slot() by passing a -1 as
@@ -298,9 +298,8 @@ EXPORT_SYMBOL_GPL(pci_renumber_slot);
  */
 void pci_destroy_slot(struct pci_slot *slot)
 {
-       pr_debug("%s: dec refcount to %d on %04x:%02x:%02x\n", __func__,
-                atomic_read(&slot->kobj.kref.refcount) - 1,
-                pci_domain_nr(slot->bus), slot->bus->number, slot->number);
+       dev_dbg(&slot->bus->dev, "dev %02x, dec refcount to %d\n",
+               slot->number, atomic_read(&slot->kobj.kref.refcount) - 1);
 
        down_write(&pci_bus_sem);
        kobject_put(&slot->kobj);
@@ -308,6 +307,45 @@ void pci_destroy_slot(struct pci_slot *slot)
 }
 EXPORT_SYMBOL_GPL(pci_destroy_slot);
 
+#if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)
+#include <linux/pci_hotplug.h>
+/**
+ * pci_hp_create_link - create symbolic link to the hotplug driver module.
+ * @pci_slot: struct pci_slot
+ *
+ * Helper function for pci_hotplug_core.c to create symbolic link to
+ * the hotplug driver module.
+ */
+void pci_hp_create_module_link(struct pci_slot *pci_slot)
+{
+       struct hotplug_slot *slot = pci_slot->hotplug;
+       struct kobject *kobj = NULL;
+       int no_warn;
+
+       if (!slot || !slot->ops)
+               return;
+       kobj = kset_find_obj(module_kset, slot->ops->mod_name);
+       if (!kobj)
+               return;
+       no_warn = sysfs_create_link(&pci_slot->kobj, kobj, "module");
+       kobject_put(kobj);
+}
+EXPORT_SYMBOL_GPL(pci_hp_create_module_link);
+
+/**
+ * pci_hp_remove_link - remove symbolic link to the hotplug driver module.
+ * @pci_slot: struct pci_slot
+ *
+ * Helper function for pci_hotplug_core.c to remove symbolic link to
+ * the hotplug driver module.
+ */
+void pci_hp_remove_module_link(struct pci_slot *pci_slot)
+{
+       sysfs_remove_link(&pci_slot->kobj, "module");
+}
+EXPORT_SYMBOL_GPL(pci_hp_remove_module_link);
+#endif
+
 static int pci_slot_init(void)
 {
        struct kset *pci_bus_kset;