forked from Imagelibrary/rtems
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user