summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2017-08-30 11:01:38 +0200
committerDaniel Hellstrom <daniel@gaisler.com>2017-09-29 13:36:44 +0200
commitf9fbb3336ff4e9044795e02b2847bbc1206674f5 (patch)
treed74bd69e94b597ea75e8b82e78d6950905219b4e /cpukit
parentbsp/bf537Stamp: Fix warning (diff)
downloadrtems-f9fbb3336ff4e9044795e02b2847bbc1206674f5.tar.bz2
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
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/libpci/Makefile.am1
-rw-r--r--cpukit/libpci/pci_cfg_auto.c16
-rw-r--r--cpukit/libpci/pci_cfg_read.c16
-rw-r--r--cpukit/libpci/pci_dev_create.c33
-rw-r--r--cpukit/libpci/pci_internal.h3
5 files changed, 32 insertions, 37 deletions
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 <rtems.h>
-#include <stdlib.h>
-#include <rtems/bspIo.h>
-
-#include <pci.h>
-#include <pci/cfg.h>
-
-#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);