From e4e2aa9cc2cbaab9c6c0ee3a1f4e36292128762a Mon Sep 17 00:00:00 2001 From: Jordan Niethe Date: Fri, 9 Aug 2019 14:12:20 +1000 Subject: pci: Use a macro for accessing PCI BDF Function Number Currently when the Function Number bits of a BDF are needed the bit operations to get it are free coded. There are many places where the Function 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/npu2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'hw/npu2.c') diff --git a/hw/npu2.c b/hw/npu2.c index f561386..06eaf4d 100644 --- a/hw/npu2.c +++ b/hw/npu2.c @@ -584,10 +584,10 @@ static int npu2_assign_gmb(struct npu2_dev *ndev) * the highest bdfn (fn = 6) and count back until we find a * npu2_dev. */ for (bdfn = (ndev->bdfn & ~0x7) | NPU2_LINKS_PER_CHIP; - (bdfn & 0x7) != 0x7; bdfn = (bdfn & ~0x7) | ((bdfn & 0x7) - 1)) + PCI_FUNC(bdfn) != 0x7; bdfn = (bdfn & ~0x7) | (PCI_FUNC(bdfn) - 1)) if (npu2_bdf_to_dev(p, bdfn)) break; - peers = bdfn & 0x7; + peers = PCI_FUNC(bdfn); npu2_get_gpu_base(ndev, &base, &size); @@ -625,7 +625,7 @@ static int npu2_assign_gmb(struct npu2_dev *ndev) assert(0); } - mode += ndev->bdfn & 0x7; + mode += PCI_FUNC(ndev->bdfn); val = SETFIELD(NPU2_MEM_BAR_MODE, val, mode); gmb = NPU2_GPU0_MEM_BAR; -- cgit v1.1