UPSTREAM: lib: provide clearer devicetree semantics

The devicetree data structures have been available in more than just
ramstage and romstage. In order to provide clearer and consistent
semantics two new macros are provided:

1. DEVTREE_EARLY which is true when !ENV_RAMSTAGE
2. DEVTREE_CONST as a replacment for ROMSTAGE_CONST

The ROMSTAGE_CONST attribute is used in the source code to mark
the devicetree data structures as const in early stages even though
it's not just romstage. Therefore, rename the attribute to
DEVTREE_CONST as that's the actual usage. The only place where the
usage was not devicetree related is console_loglevel, but the same
name was used for consistency. Any stage that is not ramstage has
the const C attribute applied when DEVTREE_CONST is used.

BUG=none
BRANCH=none
TEST=none

Change-Id: If0409e8e9d6a203254a9f9b749de5cab70dfc842
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: e4d7abc0d4
Original-Change-Id: Ibd51c2628dc8f68e0896974f7e4e7c8588d333ed
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/19333
Original-Tested-by: build bot (Jenkins)
Original-Reviewed-by: Philippe Mathieu-Daud <philippe.mathieu.daude@gmail.com>
Original-Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/488047
This commit is contained in:
Aaron Durbin 2017-04-16 22:05:36 -05:00 committed by chrome-bot
commit 6b37867b3e
24 changed files with 90 additions and 81 deletions

View file

@ -24,7 +24,7 @@
#include <device/resource.h>
/** Linked list of ALL devices */
ROMSTAGE_CONST struct device * ROMSTAGE_CONST all_devices = &dev_root;
DEVTREE_CONST struct device * DEVTREE_CONST all_devices = &dev_root;
/**
* Given a PCI bus and a devfn number, find the device structure.
@ -33,10 +33,10 @@ ROMSTAGE_CONST struct device * ROMSTAGE_CONST all_devices = &dev_root;
* @param devfn A device/function number.
* @return Pointer to the device structure (if found), 0 otherwise.
*/
ROMSTAGE_CONST struct device *dev_find_slot(unsigned int bus,
DEVTREE_CONST struct device *dev_find_slot(unsigned int bus,
unsigned int devfn)
{
ROMSTAGE_CONST struct device *dev, *result;
DEVTREE_CONST struct device *dev, *result;
result = 0;
for (dev = all_devices; dev; dev = dev->next) {
@ -56,10 +56,10 @@ ROMSTAGE_CONST struct device *dev_find_slot(unsigned int bus,
* @param previous_dev A pointer to a PCI device structure.
* @return Pointer to the next device structure (if found), 0 otherwise.
*/
ROMSTAGE_CONST struct device *dev_find_next_pci_device(
ROMSTAGE_CONST struct device *previous_dev)
DEVTREE_CONST struct device *dev_find_next_pci_device(
DEVTREE_CONST struct device *previous_dev)
{
ROMSTAGE_CONST struct device *dev, *result;
DEVTREE_CONST struct device *dev, *result;
if (previous_dev == NULL)
previous_dev = all_devices;
@ -81,10 +81,10 @@ ROMSTAGE_CONST struct device *dev_find_next_pci_device(
* @param addr A device number.
* @return Pointer to the device structure (if found), 0 otherwise.
*/
ROMSTAGE_CONST struct device *dev_find_slot_on_smbus(unsigned int bus,
DEVTREE_CONST struct device *dev_find_slot_on_smbus(unsigned int bus,
unsigned int addr)
{
ROMSTAGE_CONST struct device *dev, *result;
DEVTREE_CONST struct device *dev, *result;
result = 0;
for (dev = all_devices; dev; dev = dev->next) {
@ -105,9 +105,9 @@ ROMSTAGE_CONST struct device *dev_find_slot_on_smbus(unsigned int bus,
* @param device Logical device number.
* @return Pointer to the device structure (if found), 0 otherwise.
*/
ROMSTAGE_CONST struct device *dev_find_slot_pnp(u16 port, u16 device)
DEVTREE_CONST struct device *dev_find_slot_pnp(u16 port, u16 device)
{
ROMSTAGE_CONST struct device *dev;
DEVTREE_CONST struct device *dev;
for (dev = all_devices; dev; dev = dev->next) {
if ((dev->path.type == DEVICE_PATH_PNP) &&