device/resource: Modify some resource allocation instances
These changes made my crude pattern matching work with
coccinelle simpler.
Change-Id: I83f3ef38b8663640594b4d726838f7a6f96a58a2
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/64698
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/src/ec/google/wilco/chip.c b/src/ec/google/wilco/chip.c
index 911eb25..2243004 100644
--- a/src/ec/google/wilco/chip.c
+++ b/src/ec/google/wilco/chip.c
@@ -161,9 +161,9 @@
size_t base, size_t size)
{
struct resource *res = new_resource(dev, index);
- res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
res->base = base;
res->size = size;
+ res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
}
static void wilco_ec_read_resources(struct device *dev)
diff --git a/src/northbridge/intel/haswell/northbridge.c b/src/northbridge/intel/haswell/northbridge.c
index 606461b..a1bd143 100644
--- a/src/northbridge/intel/haswell/northbridge.c
+++ b/src/northbridge/intel/haswell/northbridge.c
@@ -106,11 +106,11 @@
continue;
resource = new_resource(dev, mc_fixed_resources[i].index);
+ resource->base = base;
+ resource->size = size;
resource->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED |
IORESOURCE_RESERVE | IORESOURCE_ASSIGNED;
- resource->base = base;
- resource->size = size;
printk(BIOS_DEBUG, "%s: Adding %s @ %x 0x%08lx-0x%08lx.\n",
__func__, mc_fixed_resources[i].description, index,
(unsigned long)base, (unsigned long)(base + size - 1));
@@ -298,7 +298,7 @@
/* TSEG - DPR -> BGSM */
resource = new_resource(dev, index++);
resource->base = mc_values[TSEG_REG] - dpr.size * MiB;
- resource->size = mc_values[BGSM_REG] - resource->base;
+ resource->size = mc_values[BGSM_REG] - (mc_values[TSEG_REG] - dpr.size * MiB);
resource->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED |
IORESOURCE_RESERVE | IORESOURCE_ASSIGNED | IORESOURCE_CACHEABLE;
@@ -306,7 +306,7 @@
if (mc_values[BGSM_REG] != mc_values[TOLUD_REG]) {
resource = new_resource(dev, index++);
resource->base = mc_values[BGSM_REG];
- resource->size = mc_values[TOLUD_REG] - resource->base;
+ resource->size = mc_values[TOLUD_REG] - mc_values[BGSM_REG];
resource->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED |
IORESOURCE_RESERVE | IORESOURCE_ASSIGNED;
}
diff --git a/src/northbridge/intel/x4x/northbridge.c b/src/northbridge/intel/x4x/northbridge.c
index 5b61224..8a104a8 100644
--- a/src/northbridge/intel/x4x/northbridge.c
+++ b/src/northbridge/intel/x4x/northbridge.c
@@ -72,7 +72,7 @@
/* cbmem_top can be shifted downwards due to alignment.
Mark the region between cbmem_top and tomk as unusable */
- delta_cbmem = tomk - ((uint32_t)(uintptr_t)cbmem_top() >> 10);
+ delta_cbmem = tomk - ((uintptr_t)cbmem_top() >> 10);
tomk -= delta_cbmem;
uma_sizek += delta_cbmem;
diff --git a/src/soc/intel/broadwell/northbridge.c b/src/soc/intel/broadwell/northbridge.c
index 4825b88..4adf926 100644
--- a/src/soc/intel/broadwell/northbridge.c
+++ b/src/soc/intel/broadwell/northbridge.c
@@ -129,11 +129,11 @@
continue;
resource = new_resource(dev, mc_fixed_resources[i].index);
+ resource->base = base;
+ resource->size = size;
resource->flags = IORESOURCE_MEM | IORESOURCE_FIXED |
IORESOURCE_STORED | IORESOURCE_RESERVE |
IORESOURCE_ASSIGNED;
- resource->base = base;
- resource->size = size;
printk(BIOS_DEBUG, "%s: Adding %s @ %x 0x%08lx-0x%08lx.\n",
__func__, mc_fixed_resources[i].description, index,
(unsigned long)base, (unsigned long)(base + size - 1));
@@ -328,7 +328,7 @@
/* TSEG - DPR -> BGSM */
resource = new_resource(dev, index++);
resource->base = mc_values[TSEG_REG] - dpr_size;
- resource->size = mc_values[BGSM_REG] - resource->base;
+ resource->size = mc_values[BGSM_REG] - (mc_values[TSEG_REG] - dpr_size);
resource->flags = IORESOURCE_MEM | IORESOURCE_FIXED |
IORESOURCE_STORED | IORESOURCE_RESERVE |
IORESOURCE_ASSIGNED | IORESOURCE_CACHEABLE;
@@ -336,7 +336,7 @@
/* BGSM -> TOLUD */
resource = new_resource(dev, index++);
resource->base = mc_values[BGSM_REG];
- resource->size = mc_values[TOLUD_REG] - resource->base;
+ resource->size = mc_values[TOLUD_REG] - mc_values[BGSM_REG];
resource->flags = IORESOURCE_MEM | IORESOURCE_FIXED |
IORESOURCE_STORED | IORESOURCE_RESERVE |
IORESOURCE_ASSIGNED;
diff --git a/src/soc/intel/denverton_ns/lpc.c b/src/soc/intel/denverton_ns/lpc.c
index 38df892..1fc1ea3 100644
--- a/src/soc/intel/denverton_ns/lpc.c
+++ b/src/soc/intel/denverton_ns/lpc.c
@@ -405,10 +405,6 @@
res->size = 16 * 1024 * 1024; /* 16MB PCR config space */
res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED |
IORESOURCE_ASSIGNED;
- printk(BIOS_DEBUG,
- "Adding P2SB PCR config space BAR 0x%08lx-0x%08lx.\n",
- (unsigned long)(res->base),
- (unsigned long)(res->base + res->size));
/* Add MMIO resource
* Use 0xdb as an unused index for IOAPIC.
diff --git a/src/soc/intel/denverton_ns/systemagent.c b/src/soc/intel/denverton_ns/systemagent.c
index 774ab2d..116dc90 100644
--- a/src/soc/intel/denverton_ns/systemagent.c
+++ b/src/soc/intel/denverton_ns/systemagent.c
@@ -104,11 +104,11 @@
continue;
resource = new_resource(dev, mc_fixed_resources[i].index);
+ resource->base = base;
+ resource->size = size;
resource->flags = IORESOURCE_MEM | IORESOURCE_FIXED |
IORESOURCE_STORED | IORESOURCE_RESERVE |
IORESOURCE_ASSIGNED;
- resource->base = base;
- resource->size = size;
printk(BIOS_DEBUG, "%s: Adding %s @ %x 0x%08lx-0x%08lx.\n",
__func__, mc_fixed_resources[i].description, index,
(unsigned long)base, (unsigned long)(base + size - 1));
@@ -248,7 +248,7 @@
/* top_of_ram -> TSEG */
resource = new_resource(dev, index++);
resource->base = top_of_ram;
- resource->size = mc_values[TSEG_REG] - resource->base;
+ resource->size = mc_values[TSEG_REG] - top_of_ram;
resource->flags = IORESOURCE_MEM | IORESOURCE_FIXED |
IORESOURCE_STORED | IORESOURCE_RESERVE |
IORESOURCE_ASSIGNED;
@@ -256,13 +256,10 @@
/* TSEG -> TOLUD */
resource = new_resource(dev, index++);
resource->base = mc_values[TSEG_REG];
- resource->size = mc_values[TOLUD_REG] - resource->base;
+ resource->size = mc_values[TOLUD_REG] - mc_values[TSEG_REG];
resource->flags = IORESOURCE_MEM | IORESOURCE_FIXED |
IORESOURCE_STORED | IORESOURCE_RESERVE |
IORESOURCE_ASSIGNED | IORESOURCE_CACHEABLE;
- printk(BIOS_DEBUG,
- "SMM memory location: 0x%llx SMM memory size: 0x%llx\n",
- resource->base, resource->size);
/* 4GiB -> TOUUD */
base_k = 4096 * 1024; /* 4GiB */