From 6d67361b59b70d930144b47f6fbbef956ca2fb40 Mon Sep 17 00:00:00 2001 From: Oliver O'Halloran Date: Fri, 15 Sep 2017 15:40:48 +1000 Subject: [PATCH] core/pci-slots: Move slot-label construction to a helper Move this out of the astbmc specific part into a generic helper. This allows us to use it more commonly. Signed-off-by: Oliver O'Halloran Signed-off-by: Stewart Smith --- core/pci-slot.c | 30 ++++++++++++++++++++++++++++++ include/pci-slot.h | 3 +++ platforms/astbmc/slots.c | 34 ++-------------------------------- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/core/pci-slot.c b/core/pci-slot.c index 69bdb86abaeb..6d3ed6cb9cb7 100644 --- a/core/pci-slot.c +++ b/core/pci-slot.c @@ -212,3 +212,33 @@ struct pci_slot *pci_slot_find(uint64_t id) slot = pd ? pd->slot : NULL; return slot; } + +void pci_slot_add_loc(struct pci_slot *slot, + struct dt_node *np, const char *label) +{ + char tmp[8], loc_code[LOC_CODE_SIZE]; + struct pci_device *pd = slot->pd; + struct phb *phb = slot->phb; + + if (!np) + return; + + /* didn't get a real slot label? generate one! */ + if (!label) { + snprintf(tmp, sizeof(tmp), "S%04x%02x", phb->opal_id, + pd->secondary_bus); + label = tmp; + } + + /* Make a -