[RFC 2/6] pseries/drcinfo: Fix bug parsing ibm,drc-info
From: Michael Bringmann
Date: Fri Dec 14 2018 - 15:50:49 EST
Replace use of of_prop_next_u32() in when parsing 'ibm,drc-info'
structure to simplify and reduce parsing code.
Signed-off-by: Michael Bringmann <mwb@xxxxxxxxxxxxxxxxxx>
Fixes: 3f38000eda48 ("powerpc/firmware: Add definitions for new drc-info firmware feature" -- end of patch series applied to powerpc next)
---
arch/powerpc/platforms/pseries/of_helpers.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c
index 6df192f..0185e50 100644
--- a/arch/powerpc/platforms/pseries/of_helpers.c
+++ b/arch/powerpc/platforms/pseries/of_helpers.c
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
+
#include <linux/string.h>
#include <linux/err.h>
#include <linux/slab.h>
@@ -6,6 +7,9 @@
#include <asm/prom.h>
#include "of_helpers.h"
+#include "pseries.h"
+
+#define MAX_DRC_NAME_LEN 64
/**
* pseries_of_derive_parent - basically like dirname(1)
@@ -65,29 +69,19 @@ int of_read_drc_info_cell(struct property **prop, const __be32 **curval,
/* Get drc-index-start:encode-int */
p2 = (const __be32 *)p;
- p2 = of_prop_next_u32(*prop, p2, &data->drc_index_start);
- if (!p2)
- return -EINVAL;
+ data->drc_index_start = of_read_number(p2++, 1);
/* Get drc-name-suffix-start:encode-int */
- p2 = of_prop_next_u32(*prop, p2, &data->drc_name_suffix_start);
- if (!p2)
- return -EINVAL;
+ data->drc_name_suffix_start = of_read_number(p2++, 1);
/* Get number-sequential-elements:encode-int */
- p2 = of_prop_next_u32(*prop, p2, &data->num_sequential_elems);
- if (!p2)
- return -EINVAL;
+ data->num_sequential_elems = of_read_number(p2++, 1);
/* Get sequential-increment:encode-int */
- p2 = of_prop_next_u32(*prop, p2, &data->sequential_inc);
- if (!p2)
- return -EINVAL;
+ data->sequential_inc = of_read_number(p2++, 1);
/* Get drc-power-domain:encode-int */
- p2 = of_prop_next_u32(*prop, p2, &data->drc_power_domain);
- if (!p2)
- return -EINVAL;
+ data->drc_power_domain = of_read_number(p2++, 1);
/* Should now know end of current entry */
(*curval) = (void *)p2;