[Skiboot] [PATCH] hw/occ: Only allocate what we need for pstate dt
Joel Stanley
joel at jms.id.au
Thu Feb 11 16:08:25 AEDT 2016
When constructing the pstate entries in the device tree we allocate
MAX_PSTATES, even though we know that there are nr_pstates.
Use this information to allocate nr_pstates and potentially save us some
heap.
Signed-off-by: Joel Stanley <joel at jms.id.au>
---
hw/occ.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/occ.c b/hw/occ.c
index 0e3d95366b20..ac51cd4e2ed1 100644
--- a/hw/occ.c
+++ b/hw/occ.c
@@ -191,25 +191,25 @@ static bool add_cpu_pstate_properties(s8 *pstate_nom)
/* Setup arrays for device-tree */
/* Allocate memory */
- dt_id = (u32 *) malloc(MAX_PSTATES * sizeof(u32));
+ dt_id = malloc(nr_pstates * sizeof(u32));
if (!dt_id) {
printf("OCC: dt_id array alloc failure\n");
goto out;
}
- dt_freq = (u32 *) malloc(MAX_PSTATES * sizeof(u32));
+ dt_freq = malloc(nr_pstates * sizeof(u32));
if (!dt_freq) {
printf("OCC: dt_freq array alloc failure\n");
goto out_free_id;
}
- dt_vdd = (u8 *) malloc(MAX_PSTATES * sizeof(u8));
+ dt_vdd = malloc(nr_pstates * sizeof(u8));
if (!dt_vdd) {
printf("OCC: dt_vdd array alloc failure\n");
goto out_free_freq;
}
- dt_vcs = (u8 *) malloc(MAX_PSTATES * sizeof(u8));
+ dt_vcs = malloc(nr_pstates * sizeof(u8));
if (!dt_vcs) {
printf("OCC: dt_vcs array alloc failure\n");
goto out_free_vdd;
--
2.7.0
More information about the Skiboot
mailing list