554int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
555 const char *name)
556{
557 int result;
558 struct pci_slot *pci_slot;
559
560 if (slot == NULL)
561 return -ENODEV;
562 if ((slot->info == NULL) || (slot->ops == NULL))
563 return -EINVAL;
564 if (slot->release == NULL) {
565 dbg("Why are you trying to register a hotplug slot "
566 "without a proper release function?\n");
567 return -EINVAL;
568 }
569
570 mutex_lock(&pci_hp_mutex);
571
572
573
574
575
576
577 pci_slot = pci_create_slot(bus, slot_nr, name, slot);
578 if (IS_ERR(pci_slot)) {
579 result = PTR_ERR(pci_slot);
580 goto out;
581 }
582
583 slot->pci_slot = pci_slot;
584 pci_slot->hotplug = slot;
585
586 list_add(&slot->slot_list, &pci_hotplug_slot_list);
587
588 result = fs_add_slot(pci_slot);
589 kobject_uevent(&pci_slot->kobj, KOBJ_ADD);
590 dbg("Added slot %s to the list\n", name);
591out:
592 mutex_unlock(&pci_hp_mutex);
593 return result;
594}