From df15dcfc8acc83591889fa3b33100734a6b6bdb7 Mon Sep 17 00:00:00 2001 From: Jordan Niethe Date: Fri, 9 Aug 2019 14:12:18 +1000 Subject: pci: Use a macro for accessing PCI BDF Bus Number Currently when the Bus Number bits of a BDF are needed the bit operations to get it are free coded. There are many places where the Bus Number is used, so make a macro to use instead of free coding it everytime. Signed-off-by: Jordan Niethe Signed-off-by: Oliver O'Halloran --- hw/phb3.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'hw/phb3.c') diff --git a/hw/phb3.c b/hw/phb3.c index ee127c1..03bcee8 100644 --- a/hw/phb3.c +++ b/hw/phb3.c @@ -126,7 +126,7 @@ static int64_t phb3_pcicfg_check(struct phb3 *p, uint32_t bdfn, * error state if we try to probe beyond that, so let's * avoid that and just return an error to Linux */ - if ((bdfn >> 8) == 0 && (bdfn & 0xff)) + if (PCI_BUS_NUM(bdfn) == 0 && (bdfn & 0xff)) return OPAL_HARDWARE; /* Check PHB state */ @@ -3278,7 +3278,7 @@ static int64_t phb3_err_inject_cfg(struct phb3 *p, uint64_t pe_number, if (prefer == 0xffffull) { if (is_bus_pe) { m = PHB_PAPR_ERR_INJ_MASK_CFG; - prefer = SETFIELD(m, 0x0ull, (bdfn >> 8)); + prefer = SETFIELD(m, 0x0ull, PCI_BUS_NUM(bdfn)); } else { m = PHB_PAPR_ERR_INJ_MASK_CFG_ALL; prefer = SETFIELD(m, 0x0ull, bdfn); @@ -3293,7 +3293,7 @@ static int64_t phb3_err_inject_cfg(struct phb3 *p, uint64_t pe_number, } if (is_bus_pe && - GETFIELD(PHB_PAPR_ERR_INJ_MASK_CFG, addr) == (bdfn >> 8)) { + GETFIELD(PHB_PAPR_ERR_INJ_MASK_CFG, addr) == PCI_BUS_NUM(bdfn)) { a = addr; break; } -- cgit v1.1