From 1dca625116be14bea6dfbc3ed04121416c195db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Mon, 5 Dec 2016 21:26:54 +0000 Subject: [PATCH] refactoring pci_find_classcode() --- BaS_gcc/pci/pci.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BaS_gcc/pci/pci.c b/BaS_gcc/pci/pci.c index d0a6b45..6eb053d 100644 --- a/BaS_gcc/pci/pci.c +++ b/BaS_gcc/pci/pci.c @@ -506,14 +506,17 @@ int32_t pci_find_device(uint16_t device_id, uint16_t vendor_id, int index) static bool match_classcode(uint32_t handle, uint32_t classcode) { uint8_t find_mask = (classcode >> 24) & 0xff; - uint32_t value = swpl(pci_read_config_longword(handle, PCICCR)); + uint32_t value = pci_read_config_longword(handle, PCICCR); int i; - for (i = 2; i >= 0; i--) /* loop through mask */ + dbg("classcode=0x%08x, value=0x%08x\r\n", classcode, value); + + for (i = 0; i < 3; i++) /* loop through mask */ { if ((find_mask >> i) & 1) { - if (! (value >> (i * 8)) == (classcode >> (i * 8))) + dbg("compare 0x%02x against 0x%02x\r\n", (value >> (i * 8)) & 0xff, (classcode >> (i * 8)) & 0xff); + if (! (((value >> (i * 8)) & 0xff) == ((classcode >> (i * 8)) & 0xff))) return false; } }