From patchwork Tue Mar 9 05:03:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1449543 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dvjlk079Wz9sW1 for ; Tue, 9 Mar 2021 16:03:29 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lJUWh-0001rb-5x; Tue, 09 Mar 2021 05:03:23 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lJUWf-0001rV-Oh for fwts-devel@lists.ubuntu.com; Tue, 09 Mar 2021 05:03:21 +0000 Received: from d198-53-221-123.abhsia.telus.net ([198.53.221.123] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lJUWf-0004sf-51; Tue, 09 Mar 2021 05:03:21 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH] pci: move pci_device struct to fwts_pci.h Date: Mon, 8 Mar 2021 22:03:17 -0700 Message-Id: <20210309050317.345020-1-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" Signed-off-by: Alex Hung Acked-by: Colin Ian King Acked-by: Ivan Hu --- src/lib/include/fwts_pci.h | 8 ++++++++ src/pci/aspm/aspm.c | 20 ++++++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/lib/include/fwts_pci.h b/src/lib/include/fwts_pci.h index a842110b..ce4c6d53 100644 --- a/src/lib/include/fwts_pci.h +++ b/src/lib/include/fwts_pci.h @@ -185,6 +185,14 @@ typedef struct { uint16_t slot_status2; } __attribute__ ((packed)) fwts_pcie_capability; +typedef struct { + uint8_t segment; + uint8_t bus; + uint8_t dev; + uint8_t func; + uint8_t config[256]; +} fwts_pci_device; + const char *fwts_pci_description(const uint8_t class_code, const uint8_t subclass_code); #endif diff --git a/src/pci/aspm/aspm.c b/src/pci/aspm/aspm.c index 8ae89806..c13789c3 100644 --- a/src/pci/aspm/aspm.c +++ b/src/pci/aspm/aspm.c @@ -43,14 +43,6 @@ #define FWTS_PCIE_ASPM_CONTROL_L1_FIELD 0x0002 #define FWTS_PCIE_ASPM_CONTROL_FIELD (FWTS_PCIE_ASPM_CONTROL_L0_FIELD | FWTS_PCIE_ASPM_CONTROL_L1_FIELD) -struct pci_device { - uint8_t segment; - uint8_t bus; - uint8_t dev; - uint8_t func; - uint8_t config[256]; -}; - static int facp_get_aspm_control(fwts_framework *fw) { fwts_acpi_table_info *table; @@ -78,8 +70,8 @@ static int facp_get_aspm_control(fwts_framework *fw) } static int pcie_compare_rp_dev_aspm_registers(fwts_framework *fw, - struct pci_device *rp, - struct pci_device *dev) + fwts_pci_device *rp, + fwts_pci_device *dev) { fwts_pcie_capability *rp_cap, *device_cap; uint8_t rp_aspm_cntrl, device_aspm_cntrl; @@ -197,9 +189,9 @@ static int pcie_check_aspm_registers(fwts_framework *fw) if (sscanf(entry->d_name, "%" SCNx16 ":%" SCNx8 ":%" SCNx8 ".%" SCNx8, &segment, &bus, &dev, &func) == 4) { int fd; char path[PATH_MAX]; - struct pci_device *device; + fwts_pci_device *device; - device = (struct pci_device *)calloc(1, sizeof(struct pci_device)); + device = (fwts_pci_device *)calloc(1, sizeof(fwts_pci_device)); if (device == NULL) { fwts_list_free_items(&dev_list, free); closedir(dirp); @@ -231,12 +223,12 @@ static int pcie_check_aspm_registers(fwts_framework *fw) /* Check aspm registers from the list of pci devices */ for (lcur = dev_list.head; lcur; lcur = lcur->next) { - struct pci_device *cur = (struct pci_device *)lcur->data; + fwts_pci_device *cur = (fwts_pci_device *)lcur->data; /* Find PCI Bridge (PCIE Root Port) and the attached device */ if (cur->config[FWTS_PCI_CONFIG_HEADER_TYPE] & 0x01) { for (ltarget = dev_list.head; ltarget; ltarget = ltarget->next) { - struct pci_device *target = (struct pci_device *)ltarget->data; + fwts_pci_device *target = (fwts_pci_device *)ltarget->data; if (target->segment == cur->segment) { if (target->bus == cur->config[FWTS_PCI_CONFIG_TYPE1_SECONDARY_BUS_NUMBER]) { pcie_compare_rp_dev_aspm_registers(fw, cur, target);