From f9fbb3336ff4e9044795e02b2847bbc1206674f5 Mon Sep 17 00:00:00 2001 From: Daniel Hellstrom Date: Wed, 30 Aug 2017 11:01:38 +0200 Subject: libpci: fix pci device allocation The refactoring of pci_dev_create() was incorrect since the code relied on different defines before including pci/cfg.h. This reverts back to the original code having two pci_dev_create() one in auto and one in read library. confdefs.h selectes between the two libraries so both there is no link conflict. Updates #3029 --- cpukit/libpci/Makefile.am | 1 - cpukit/libpci/pci_cfg_auto.c | 16 ++++++++++++++++ cpukit/libpci/pci_cfg_read.c | 16 ++++++++++++++++ cpukit/libpci/pci_dev_create.c | 33 --------------------------------- cpukit/libpci/pci_internal.h | 3 --- 5 files changed, 32 insertions(+), 37 deletions(-) delete mode 100644 cpukit/libpci/pci_dev_create.c (limited to 'cpukit') diff --git a/cpukit/libpci/Makefile.am b/cpukit/libpci/Makefile.am index cf336ed094..cff25b35c0 100644 --- a/cpukit/libpci/Makefile.am +++ b/cpukit/libpci/Makefile.am @@ -28,7 +28,6 @@ libpci_a_SOURCES += pci_cfg_print_code.c libpci_a_SOURCES += pci_cfg_read.c libpci_a_SOURCES += pci_cfg_static.c libpci_a_SOURCES += pci_cfg_peripheral.c -libpci_a_SOURCES += pci_dev_create.c libpci_a_SOURCES += pci_find.c libpci_a_SOURCES += pci_find_dev.c libpci_a_SOURCES += pci_for_each.c diff --git a/cpukit/libpci/pci_cfg_auto.c b/cpukit/libpci/pci_cfg_auto.c index 2f227b116a..60708106a0 100644 --- a/cpukit/libpci/pci_cfg_auto.c +++ b/cpukit/libpci/pci_cfg_auto.c @@ -267,6 +267,22 @@ static void pci_dev_free(struct pci_dev *dev) } #endif +static struct pci_dev *pci_dev_create(int isbus) +{ + void *ptr; + int size; + + if (isbus) + size = sizeof(struct pci_bus); + else + size = sizeof(struct pci_dev); + + ptr = calloc(1, size); + if (!ptr) + rtems_fatal_error_occurred(RTEMS_NO_MEMORY); + return ptr; +} + static void pci_find_devs(struct pci_bus *bus) { uint32_t id, tmp; diff --git a/cpukit/libpci/pci_cfg_read.c b/cpukit/libpci/pci_cfg_read.c index 16c2928bab..07837431b0 100644 --- a/cpukit/libpci/pci_cfg_read.c +++ b/cpukit/libpci/pci_cfg_read.c @@ -36,6 +36,22 @@ /* The Host Bridge bus is initialized here */ extern struct pci_bus pci_hb; +static struct pci_dev *pci_dev_create(int isbus) +{ + void *ptr; + int size; + + if (isbus) + size = sizeof(struct pci_bus); + else + size = sizeof(struct pci_dev); + + ptr = calloc(1, size); + if (!ptr) + rtems_fatal_error_occurred(RTEMS_NO_MEMORY); + return ptr; +} + /* Check if address is accessible from host */ static int pci_read_addressable(struct pci_dev *dev, struct pci_res *res) { diff --git a/cpukit/libpci/pci_dev_create.c b/cpukit/libpci/pci_dev_create.c deleted file mode 100644 index 4e84397214..0000000000 --- a/cpukit/libpci/pci_dev_create.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Device allocator helper used by PCI Auto/Read Configuration Library - * - * COPYRIGHT (c) 2010 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#include -#include -#include - -#include -#include - -#include "pci_internal.h" - -struct pci_dev *pci_dev_create(int isbus) -{ - void *ptr; - int size; - - if (isbus) - size = sizeof(struct pci_bus); - else - size = sizeof(struct pci_dev); - - ptr = calloc(1, size); - if (!ptr) - rtems_fatal_error_occurred(RTEMS_NO_MEMORY); - return ptr; -} diff --git a/cpukit/libpci/pci_internal.h b/cpukit/libpci/pci_internal.h index a89e8f1f4b..d0bb83ca14 100644 --- a/cpukit/libpci/pci_internal.h +++ b/cpukit/libpci/pci_internal.h @@ -9,6 +9,3 @@ /* Number of buses */ extern int pci_bus_cnt; - -/* Allocate a PCI device for a standard device or a bridge device */ -struct pci_dev *pci_dev_create(int isbus); -- cgit v1.2.3