Skip to content

Commit

Permalink
device/device.h: Rename busses for clarity
Browse files Browse the repository at this point in the history
This renames bus to upstream and link_list to downstream.

Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Change-Id: I80a81b6b8606e450ff180add9439481ec28c2420
Reviewed-on: https://review.coreboot.org/c/coreboot/+/78330
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
  • Loading branch information
ArthurHeymans authored and felixheld committed Jan 31, 2024
1 parent 3138faa commit 7fcd4d5
Show file tree
Hide file tree
Showing 104 changed files with 343 additions and 348 deletions.
4 changes: 2 additions & 2 deletions src/acpi/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,8 @@ void acpi_create_ipmi(const struct device *device,

if (device->path.type == DEVICE_PATH_PCI) {
spmi->pci_device_flag = ACPI_IPMI_PCI_DEVICE_FLAG;
spmi->pci_segment_group = device->bus->segment_group;
spmi->pci_bus = device->bus->secondary;
spmi->pci_segment_group = device->upstream->segment_group;
spmi->pci_bus = device->upstream->secondary;
spmi->pci_device = device->path.pci.devfn >> 3;
spmi->pci_function = device->path.pci.devfn & 0x7;
} else if (type != IPMI_INTERFACE_SSIF) {
Expand Down
12 changes: 6 additions & 6 deletions src/acpi/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ const char *acpi_device_name(const struct device *dev)
}

/* Walk up the tree to find if any parent can identify this device */
while (pdev->bus) {
pdev = pdev->bus->dev;
while (pdev->upstream) {
pdev = pdev->upstream->dev;
if (!pdev)
break;
if (is_root_device(pdev))
Expand Down Expand Up @@ -147,8 +147,8 @@ static ssize_t acpi_device_path_fill(const struct device *dev, char *buf,
return cur;

/* Walk up the tree to the root device */
if (!is_root_device(dev) && dev->bus && dev->bus->dev)
next = acpi_device_path_fill(dev->bus->dev, buf, buf_len, cur);
if (!is_root_device(dev) && dev->upstream && dev->upstream->dev)
next = acpi_device_path_fill(dev->upstream->dev, buf, buf_len, cur);
if (next < 0)
return next;

Expand Down Expand Up @@ -182,10 +182,10 @@ const char *acpi_device_scope(const struct device *dev)
{
static char buf[DEVICE_PATH_MAX] = {};

if (!dev || !dev->bus || !dev->bus->dev)
if (!dev || !dev->upstream || !dev->upstream->dev)
return NULL;

if (acpi_device_path_fill(dev->bus->dev, buf, sizeof(buf), 0) <= 0)
if (acpi_device_path_fill(dev->upstream->dev, buf, sizeof(buf), 0) <= 0)
return NULL;

return buf;
Expand Down
8 changes: 4 additions & 4 deletions src/arch/x86/mpspec.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ void smp_write_intsrc_pci_bridge(struct mp_config_table *mc,

unsigned char dstirq_x[4];

if (!dev->link_list)
if (!dev->downstream)
return;

child = dev->link_list->children;
srcbus = dev->link_list->secondary;
child = dev->downstream->children;
srcbus = dev->downstream->secondary;

while (child) {
if (child->path.type != DEVICE_PATH_PCI)
Expand Down Expand Up @@ -476,7 +476,7 @@ void mptable_write_buses(struct mp_config_table *mc, int *max_pci_bus,
memset(buses, 0, sizeof(buses));

for (dev = all_devices; dev; dev = dev->next) {
struct bus *bus = dev->link_list;
struct bus *bus = dev->downstream;
if (!bus)
continue;
if (bus->secondary > 255) {
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/intel/haswell/haswell_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ static void configure_c_states(void)
static void configure_thermal_target(struct device *dev)
{
/* Make sure your devicetree has the cpu_cluster below chip cpu/intel/haswell! */
struct cpu_intel_haswell_config *conf = dev->bus->dev->chip_info;
struct cpu_intel_haswell_config *conf = dev->upstream->dev->chip_info;
msr_t msr;

/* Set TCC activation offset if supported */
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/intel/model_2065x/model_2065x_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

static void configure_thermal_target(struct device *dev)
{
struct cpu_intel_model_2065x_config *conf = dev->bus->dev->chip_info;
struct cpu_intel_model_2065x_config *conf = dev->upstream->dev->chip_info;
msr_t msr;

/* Set TCC activation offset if supported */
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/intel/model_206ax/model_206ax_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static void configure_c_states(void)

static void configure_thermal_target(struct device *dev)
{
struct cpu_intel_model_206ax_config *conf = dev->bus->dev->chip_info;
struct cpu_intel_model_206ax_config *conf = dev->upstream->dev->chip_info;
msr_t msr;

if (boot_cpu()) {
Expand Down
2 changes: 1 addition & 1 deletion src/device/cardbus_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void cardbus_enable_resources(struct device *dev)
u16 ctrl;

ctrl = pci_read_config16(dev, PCI_CB_BRIDGE_CONTROL);
ctrl |= (dev->link_list->bridge_ctrl & (
ctrl |= (dev->downstream->bridge_ctrl & (
PCI_BRIDGE_CTL_VGA |
PCI_BRIDGE_CTL_MASTER_ABORT |
PCI_BRIDGE_CTL_BUS_RESET));
Expand Down
50 changes: 25 additions & 25 deletions src/device/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static struct device *__alloc_dev(struct bus *parent, struct device_path *path)
dev->enabled = 1;

/* Add the new device to the list of children of the bus. */
dev->bus = parent;
dev->upstream = parent;
if (child)
child->sibling = dev;
else
Expand Down Expand Up @@ -139,13 +139,13 @@ DECLARE_SPIN_LOCK(bus_lock)
*/
static struct bus *__alloc_bus(struct device *parent)
{
if (parent->link_list)
return parent->link_list;
if (parent->downstream)
return parent->downstream;

struct bus *bus = calloc(1, sizeof(struct bus));
if (!bus)
die("Couldn't allocate downstream bus!\n");
parent->link_list = bus;
parent->downstream = bus;
bus->dev = parent;

return bus;
Expand Down Expand Up @@ -205,8 +205,8 @@ static void read_resources(struct bus *bus)
curdev->ops->read_resources(curdev);

/* Read in the resources behind the current device's links. */
if (curdev->link_list)
read_resources(curdev->link_list);
if (curdev->downstream)
read_resources(curdev->downstream);
}
post_log_clear();
printk(BIOS_SPEW, "%s %s segment group %d bus %d done\n",
Expand Down Expand Up @@ -236,7 +236,7 @@ static void set_vga_bridge_bits(void)
continue;

printk(BIOS_DEBUG, "found VGA at %s\n", dev_path(dev));
if (dev->bus->no_vga16) {
if (dev->upstream->no_vga16) {
printk(BIOS_WARNING,
"A bridge on the path doesn't support 16-bit VGA decoding!");
}
Expand Down Expand Up @@ -270,15 +270,15 @@ static void set_vga_bridge_bits(void)
/* All legacy VGA cards have MEM & I/O space registers. */
vga->command |= (PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
vga_pri = vga;
bus = vga->bus;
bus = vga->upstream;
}

/* Now walk up the bridges setting the VGA enable. */
while (bus) {
printk(BIOS_DEBUG, "Setting PCI_BRIDGE_CTL_VGA for bridge %s\n",
dev_path(bus->dev));
bus->bridge_ctrl |= PCI_BRIDGE_CTL_VGA | PCI_BRIDGE_CTL_VGA16;
bus = (bus == bus->dev->bus) ? 0 : bus->dev->bus;
bus = (bus == bus->dev->upstream) ? 0 : bus->dev->upstream;
}
}

Expand Down Expand Up @@ -343,8 +343,8 @@ static void enable_resources(struct bus *link)
}

for (dev = link->children; dev; dev = dev->sibling) {
if (dev->link_list)
enable_resources(dev->link_list);
if (dev->downstream)
enable_resources(dev->downstream);
}
post_log_clear();
}
Expand Down Expand Up @@ -391,15 +391,15 @@ static void scan_bus(struct device *busdev)

do_scan_bus = 1;
while (do_scan_bus) {
struct bus *link = busdev->link_list;
struct bus *link = busdev->downstream;
busdev->ops->scan_bus(busdev);
do_scan_bus = 0;
if (!link || !link->reset_needed)
continue;
if (reset_bus(link))
do_scan_bus = 1;
else
busdev->bus->reset_needed = 1;
busdev->upstream->reset_needed = 1;
}

scan_time = stopwatch_duration_msecs(&sw);
Expand Down Expand Up @@ -496,14 +496,14 @@ void dev_configure(void)
/* Read the resources for the entire tree. */

printk(BIOS_INFO, "Reading resources...\n");
read_resources(root->link_list);
read_resources(root->downstream);
printk(BIOS_INFO, "Done reading resources.\n");

print_resource_tree(root, BIOS_SPEW, "After reading.");

allocate_resources(root);

assign_resources(root->link_list);
assign_resources(root->downstream);
printk(BIOS_INFO, "Done setting resources.\n");
print_resource_tree(root, BIOS_SPEW, "After assigning values.");

Expand All @@ -521,8 +521,8 @@ void dev_enable(void)
printk(BIOS_INFO, "Enabling resources...\n");

/* Now enable everything. */
if (dev_root.link_list)
enable_resources(dev_root.link_list);
if (dev_root.downstream)
enable_resources(dev_root.downstream);

printk(BIOS_INFO, "done.\n");
}
Expand All @@ -546,7 +546,7 @@ static void init_dev(struct device *dev)
long init_time;

if (dev->path.type == DEVICE_PATH_I2C) {
printk(BIOS_DEBUG, "smbus: %s->", dev_path(dev->bus->dev));
printk(BIOS_DEBUG, "smbus: %s->", dev_path(dev->upstream->dev));
}

printk(BIOS_DEBUG, "%s init\n", dev_path(dev));
Expand All @@ -572,8 +572,8 @@ static void init_link(struct bus *link)
}

for (dev = link->children; dev; dev = dev->sibling)
if (dev->link_list)
init_link(dev->link_list);
if (dev->downstream)
init_link(dev->downstream);
}

/**
Expand All @@ -590,8 +590,8 @@ void dev_initialize(void)
init_dev(&dev_root);

/* Now initialize everything. */
if (dev_root.link_list)
init_link(dev_root.link_list);
if (dev_root.downstream)
init_link(dev_root.downstream);
post_log_clear();

printk(BIOS_INFO, "Devices initialized\n");
Expand Down Expand Up @@ -626,8 +626,8 @@ static void final_link(struct bus *link)
final_dev(dev);

for (dev = link->children; dev; dev = dev->sibling)
if (dev->link_list)
final_link(dev->link_list);
if (dev->downstream)
final_link(dev->downstream);
}
/**
* Finalize all devices in the global device tree.
Expand All @@ -643,7 +643,7 @@ void dev_finalize(void)
final_dev(&dev_root);

/* Now finalize everything. */
final_link(dev_root.link_list);
final_link(dev_root.downstream);

printk(BIOS_INFO, "Devices finalized\n");
}
16 changes: 8 additions & 8 deletions src/device/device_const.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ static DEVTREE_CONST struct device *dev_find_slot(unsigned int bus,
result = 0;
for (dev = all_devices; dev; dev = dev->next) {
if ((dev->path.type == DEVICE_PATH_PCI) &&
(dev->bus->secondary == bus) &&
(dev->bus->segment_group == 0) &&
(dev->upstream->secondary == bus) &&
(dev->upstream->segment_group == 0) &&
(dev->path.pci.devfn == devfn)) {
result = dev;
break;
Expand Down Expand Up @@ -210,7 +210,7 @@ DEVTREE_CONST struct device *find_dev_nested_path(
if (nested_path_length == 1 || !child)
return child;

return find_dev_nested_path(child->link_list, nested_path + 1, nested_path_length - 1);
return find_dev_nested_path(child->downstream, nested_path + 1, nested_path_length - 1);
}

DEVTREE_CONST struct device *pcidev_path_behind(
Expand All @@ -234,8 +234,8 @@ DEVTREE_CONST struct device *pcidev_path_on_bus(unsigned int bus, pci_devfn_t de
dev = dev->next;
continue;
}
if (dev->bus->secondary == bus && dev->bus->segment_group == 0)
return pcidev_path_behind(dev->bus, devfn);
if (dev->upstream->secondary == bus && dev->upstream->segment_group == 0)
return pcidev_path_behind(dev->upstream, devfn);
dev = dev->next;
}
return NULL;
Expand All @@ -253,7 +253,7 @@ DEVTREE_CONST struct bus *pci_root_bus(void)
if (!pci_domain)
return NULL;

pci_root = pci_domain->link_list;
pci_root = pci_domain->downstream;
return pci_root;
}

Expand All @@ -277,7 +277,7 @@ DEVTREE_CONST struct device *pcidev_path_behind_pci2pci_bridge(
return NULL;
}

return pcidev_path_behind(bridge->link_list, devfn);
return pcidev_path_behind(bridge->downstream, devfn);
}

DEVTREE_CONST struct device *pcidev_path_on_root_debug(pci_devfn_t devfn, const char *func)
Expand Down Expand Up @@ -317,7 +317,7 @@ DEVTREE_CONST struct device *dev_find_slot_on_smbus(unsigned int bus,
result = 0;
for (dev = all_devices; dev; dev = dev->next) {
if ((dev->path.type == DEVICE_PATH_I2C) &&
(dev->bus->secondary == bus) &&
(dev->upstream->secondary == bus) &&
(dev->path.i2c.device == addr)) {
result = dev;
break;
Expand Down

0 comments on commit 7fcd4d5

Please sign in to comment.